afanofosc wrote:I am not convinced that the problems you both are encountering are not user-error. For one thing, trying to execute listener.nxc when you don't understand what it is supposed to do or how it works is a recipe for disaster. For another thing, if the latest compiler and firmware work just fine to talk to an NXTBee at baud rates ranging from 1200 to 115200 then can you give me a reason for it not working with another RS485 device at 9600 baud?
I wouldn't be surprised if user error is to blame (I've been in this game long enough to know that!) but for the life of me I could not figure out what I was missing in the code I wrote. I would point out that just because the firmware talks to a NXTBee doesn't imply anything about it's ability to talk to a DiWifi sensor. Two different sensors, potentially two entirely different RS485 stacks in the microcontroller on the sensor itself.
I looked at Mark's code last night and it has many issues that could cause it to fail. I would never try to figure out what was going wrong without first getting rid of all his logging code - to rule that out as a problem causer - and simplify the test harness as much as possible. Xander's RobotC code leaves off all LF characters while Mark's code follows the DIWIFI docs by always ending a command with CRLF. Which one works? Which one is right?
If you can see that many issues that would cause it to fail then please let me know what they are so I can correct them and hence learn in the process. The debug code was added to generate verbose log files on the NXT that allowed me to trace what was going on in the program. It was the only way I could figure out what was going on and when. You can disable the logging by setting a boolean to false at the top of the listener.nxc file. By default a text file named listener.txt is generated on the NXT. The logging library is not rocket science and is explained here http://www.mastincrosbie.com/Marks_LEGO_projects/Debug_Library_in_NXC.html
I even went so far as to write a DiWifi simulator program that ran on a second NXT (in NXC) and spoke to the primary NXT over RS485. As far as I could tell the code I wrote in listener.nxc behaved correctly when run with this "simulated" DiWifi sensor.
As for CRLF vs. LF: I tried both approaches with no reliable results from either in NXC.
Did Matt put the NXT into DATA_MODE_NXT or leave it in its default DATA_MODE_RAW configuration?
I tried both modes and saw that only DATA_MODE_RAW would work.
I spent the guts of a month every evening for hours on end trying to get NXC and the DiWifi to work reliably with each. I almost abandoned the whole project numerous times out of sheer frustration. I would love to get this to work reliably, so if you can assist in any way I would greatly appreciate it.