Hand Shaking

The most frustrating thing about working with xbee radios is how hard it is to actually see what’s going on between them. The code is fairly simple, when you follow the tutorial available from the slides, but when a hiccup happens, and you’re not sure where the bug is, it becomes a whole production to implement debug statements between getting information from the arduino, the radio hooked up to the arduino, and the processing script. In the future, I should look into maybe making the onboard LED blink upon transmission or something, as well as sending debug messages for processing to print without counting it in its “received” data.

Another unexpected issue was that the whole thing didn’t work unless the server radio was plugged into port 5. I thought maybe it might be the processing script failing to pick up the active port, but even CoolTerm refused to connect to anything that wasn’t port 5. I have yet to identify the cause of this.

One of the things about this handshake method that I’m not fond of is that the order of which program starts first seems to matter. It shouldn’t. The radio hooked up to the arduino should be sending nothing but the message to establish contact which should be picked up by the radio which is hooked up to the processing sketch, but for some reason, if the arduino radio is plugged in first, the processing radio never establishes contact with it. It doesn’t even try. I have a suspicion that it’s caused by the fact that the radio being plugged in at all is what Serial1.available() is looking for, so that the processing sketch is already 5 steps behind (ie, the arduino “established contact” already) by the time processing fires up.

Update: I was right, and i actually forgot to check for the request from processing before stopping sending hellos. The loop now makes sure to check for a question from the processing radio, but it seems to stall after two or three questions. Will update with further debugging.



Update II: It’s probably because the processor radio only sends a request after it receives a packet from the arduino radio. If that request gets lost during transfer, the arduino processor will never know it was requested.

further work: implement an easy debug script please this will save you so much time.

further work II: implement a timer to send another request if no further paquets are received from the arduino radio after a set amount of time.

Leave a Reply