8 years, 7 months ago.

BufferedSerial::writeable member function

The BufferedSerial::writeable member function always returns 1. This is causing a problem as my large data and slow 9600 baud comms means that I am experiencing the issue mentioned in the API documentation where previous tx buffer content can be overwritten if the buffer is too small or comms too slow. I have made the buffer as large as I can and have implemented an inelegant workaround that uses delays so that the buffer has time to empty but this is inefficient. Any suggestions on how I can perform an actual writeable check would be appreciated.

Peter

I've been thinking about removing the Buffer class for the mbed CircBuffer. That maybe one way. Any thoughts if this would be a better or worse solution from your use case?

posted by Sam Grove 16 Sep 2015

Thanks Sam, CircBuffer::isFull may be better as it appears to be a test more appropriate to my needs.

posted by Peter Ampt 17 Sep 2015

1 Answer

8 years, 7 months ago.

The TX buffer's .available function will return 0 either if it is empty, or if it will overwrite a received value. So you can use that, but you will need to have a method to know if it is empty or completely full.

Accepted Answer

Thanks Erik, Buffer::available may work for me; I'll give it a try.

posted by Peter Ampt 17 Sep 2015