Setting up DI Wifi Sensor --Problems

Discussion specific to projects ideas and support.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Setting up DI Wifi Sensor --Problems

Post by afanofosc »

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.

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);
}
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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
markcrosbie
Posts: 34
Joined: 30 Sep 2010, 09:56
Location: Ireland
Contact:

Re: Setting up DI Wifi Sensor --Problems

Post by markcrosbie »

Hi John,

I downloaded the firmware file you linked to and used the MCRS485ReadEx function and the sample code you posted does again seem to work fine. The August 8th firmware works ok talking to the DiWifi. I also verified that a new device was assigned a DHCP address on my router, which I assume is the wifi sensor (it responds to pings in any case). So good news there.

I don't have much free time at the moment (we have builders in doing work in our house so my office is jammed full of boxes) but what I'd like to do is modify my original listener.nxc web server file and try this new firmware with your MCRS485ReadEx function and see how it performs. It will probably be the weekend before I have a chance to do that.

Regards,
Mark
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Setting up DI Wifi Sensor --Problems

Post by afanofosc »

I received the new DIWIFI device and it seems to be working fine. John's echo off test works for me. So I will dig in and finish up my diwifi.h header file for NXC which includes API functions for every single AT command supported by the device.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
jdc2106
Posts: 12
Joined: 13 Oct 2010, 12:41

Re: Setting up DI Wifi Sensor --Problems

Post by jdc2106 »

Matt Allen (http://mattallen37.wordpress.com/) and John Hansen have done some really great work this the past few weeks. We've posted a preliminary set of drivers and examples in our downloads section for the Wifi that seem to work really well (thanks Matt and John!).

You can see it on our website here:

http://www.dexterindustries.com/download.html#DIWIFI

If anyone has any troubles with this driver package, please post back here! Thanks everyone!!
John Cole

Dexter Industries
http://www.dexterindustries.com
abcde13
Posts: 10
Joined: 29 Sep 2010, 03:22

Re: Setting up DI Wifi Sensor --Problems

Post by abcde13 »

Thanks for the update.

You guys are awesome. Thanks for putting a lot of work into this. I'll be sure to know this code like the back of my hand before I come back with any problems.

Anyway, now I can try and get back to my project.

Thanks again for all the help!
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest