Hello,
I have 2 xbee pros, relatively close to each other however I still often get dupe messages from one end or the other.
For example:
[ 2018-01-16 17:51:48 ] From Xbee (length: 100) [RAW]:
M23
RDY,0821,28,5,40,2,0,23
RDY,0,0,8,21,30,15,40,2,0,23
RDY,0,0,8,21,30,26,40,2,0,2
My setup is the following: Arduoino + Xbee < > Xbee + Raspberry pi 2
The rpi 2 sending commands and the arduino on the other end executes them and responds. In this example the only line I should’ve gotten back was:
RDY,0,0,8,21,30,26,40,2,0,2
The rest is garbage which either stuck in on the SENDER side Xbee or on the RECEIVER side. I hope that this is the rest because the SENDER side circuit is built in and difficult to disassemble.
So my question is, is it possible from C to send a flush command to the RECEIVER Xbee to flush it’s buffer after each successful command reception?
int serialport_flush(int fd)
{
sleep(2);
return tcflush(fd, TCIOFLUSH);
}
Does this have any effect?
So before sending out messages to the Arduino side my code always does:
serialport_flush(fd1);
serialport_write(fd1, buf);
At receiving messages it cannot really know if there is a junk in the receiver buffer before it writes that out to the serial.