Re: Setting up DI Wifi Sensor --Problems
Posted: 10 Jan 2012, 19:33
It is frustrating that I can't get my code to work but it works for others. I think it is the right library to use with the DIWIFI device for NXC users, with some tweaks to get the string functions to actually return values. Hopefully I'll get a replacement soon. Thanks John for making that happen. I'll send my old one back to you this week.
Mark, I screwed up on that whole #ifdef/#else/#endif thing since, of course with #define USE_RS385READ_EX it is defined whether its value is 0 or 1. I will fix that goof.
I will get a newer build of the compiler for Mac OS X up on the web later today. In the meantime, you can still call RS485ReadEx with the version you have with a little work.
I implemented the firmware changes that support this on August 3rd so the July 8th build is too old. Please can you try your existing code with the latest firwmare in the test_releases folder. According to John Cole his tests were run with the October 19th firmware version (http://bricxcc.sourceforge.net/test_rel ... 9_1659.rfw) so I am very hopeful that it will work fine for you with that build. The fact that I changed the definition of the structure that you pass into the CommHSRead system call function might be an issue if you use an older compiler with the newer firmware but I am hopeful that it is not. Actually, looking at the OP_SYSCALL code in the firmware it looks like you could have severe problems with any firmware built after August 3rd if you try to call RS485Read unless you use code like the above. The other way around is okay (i.e., too many fields in the struct) but if you have fewer than the system call function expects it will read past the end of the struct and the results are likely to be unpredictable.
RS485Read in newer compiler builds simply sets BufferLen to 0xFF which will make it read all the available bytes from the hi-speed incoming buffer.
John Hansen
Mark, I screwed up on that whole #ifdef/#else/#endif thing since, of course with #define USE_RS385READ_EX it is defined whether its value is 0 or 1. I will fix that goof.
I will get a newer build of the compiler for Mac OS X up on the web later today. In the meantime, you can still call RS485ReadEx with the version you have with a little work.
Code: Select all
struct MCHSReadExType {
char Status;
byte Buffer[];
byte BufferLen;
};
//#define CommHSRead 47
char MCRS485ReadEx(byte & buf[], byte len)
{
MCHSReadExType args;
args.BufferLen = len;
SysCall(CommHSRead, args);
buf = args.Buffer; // copy data out
return args.Status;
}
task main()
{
byte buffer[];
MCRS485ReadEx(buffer, 1);
}
RS485Read in newer compiler builds simply sets BufferLen to 0xFF which will make it read all the available bytes from the hi-speed incoming buffer.
John Hansen