CTS flow control doesn't work

Using an Xbee Series 2 Pro End device and Coordinator set to 9600 at both ends.

A test program sends 6 byte messages continuously from the End Device.

It only sends a message if CTS is low. It if’t high, it waits until it’s low.

When run, I can see the CTS line going high and low to flow control the program, BUT I still get lost data at the Coordinator end.

How come when CTS goes low, the Xbee still looses data? There are supposed to be 34 bytes available in the buffer when CTS goes low.

Is there some way to check to see if the buffer is empty?

You have that back words. CTS is active Low. That is when it is Low, it is clear to send the data. When it is High, you need to hold off.

Correct, that is what I am doing. I only send if CTS is low.

So how come when CTS has gone low, the Xbee still looses data?

It depends on how you are sending the data.

Are you sending the data one byte at a time, and checking the CTS?

Or are you sending the whole packet then checking the CTS?

The CTS flag is active when there are only 16 bytes left in the buffer on the xbee. Though you have to take into consideration that your uart driver/module might have a buffer of its own. In that case, you might fill up your local buffer, and by the time the CTS flag activates you have 16+ bytes in your buffer that is still trying to dump into the XBee buffer. Thus causing the buffer to overflow. Then the Xbee buffer has been overwritten, thus messing up the packet structure.

That is how you could be losing data.

Check to see how the hardware handles CTS/RTS.
If it is still not working, try it without any buffers in the uart driver/module and listen to the CTS line yourself. Try it byte by byte, it should work then.

Obviously, you’ll want your uart driver/module to handle the CTS line for you, but you probably don’t have it linked up correctly.