Trying to see the incoming data through the serial

The implementation of USARTSerial on the Particles does already use a circular buffer, so adding your own would not solve your problem.
You’d always face the problem that your data is coming in faster than you read it out. Either new data can’t be stored and will get lost since there still is some unread data present, or you start corrupting data form behind, when you overwrite unread data that might be part of a packet that is already in the process if being read.

An option would be to extend the size of the buffer, but this can only be done when building locally.

So you will need to go one of the two ways I suggested:

  • Slow down/flow control your sender
  • Always flush the buffer before read and wait for new data to arrive in your clean buffer
2 Likes