Buffer overflow in API mode

I’m looking at page 15 of the DigiMesh pro 2.4 manual and they mention overflow in the serial receive buffer, but they really don’t go into remedies for this. I’m interfacing to the modems via C++ and I’m creating the read and write threads. I’ve noticed that after sending about 120 packets, the read thread doesn’t seem to ever have data. I keep writing packets to the write thread, but the read thread doesn’t seem to have anything to read. A few packets later, it appears to be back to doing the read/write okay. Any ideas? Thanks.

Three ideas:

  1. use RTS/CTS flow control. This allows the XBee to ‘block’ you when its buffers fill.

  2. use API mode, then you actually get a ‘TX Status’ response after each outgoing message is successfully ‘handed off’ to another node. If you only send a new message AFTER the previous one was sent, you’ll never over-run the XBee receive buffer.

  3. make sure your baud rate is low - say 9600 or 19200. Setting 115k on the serial port GUARRENTTES that your C++ can send data to the XBee/DM faster than the radio can move it! So you are promising yourself buffer problems!

If you are using AT transparent mode, then RTS/CTS is your only option and error detection/recover will be very difficult.