Hello,
I'm working on a system where I have some stations that are a couple meters apart. I'm using Teensys and Xbee 802.15.4 for communication.
I have a master xbee that sends broadcast to the other xbees that are receivers (and never send anything back)
At the moment I'm sending an array of bytes using Serial1.write(buffer, length) and on the receiving side I'm using Serial.readBytes(buffer, length)
The problem I have is that if I power the sender first and the receivers last, the byte order seems to get mixed. Same happens if I shut down one of the receivers briefly and power it back on, it seems to loose track of the correct order.
Is there a way around this ? More specific code here:
That's my send code (I currently send a 2 byte array)
And this is on the receiving side:
I'm working on a system where I have some stations that are a couple meters apart. I'm using Teensys and Xbee 802.15.4 for communication.
I have a master xbee that sends broadcast to the other xbees that are receivers (and never send anything back)
At the moment I'm sending an array of bytes using Serial1.write(buffer, length) and on the receiving side I'm using Serial.readBytes(buffer, length)
The problem I have is that if I power the sender first and the receivers last, the byte order seems to get mixed. Same happens if I shut down one of the receivers briefly and power it back on, it seems to loose track of the correct order.
Is there a way around this ? More specific code here:
That's my send code (I currently send a 2 byte array)
Code:
Serial1.write(frame, 2);
And this is on the receiving side:
Code:
byte frame[2];
if (Serial1.available() == 2)
{
Serial1.readBytes(frame, 2);
}