MATLAB: How to flush the RS-232 buffers in xPC Target

buffersclearfifoi/oqueueserialSimulink Real-Time

I am using the xPC Target RS-232 driver blocks, and would like to flush both the send and receive buffers.

Best Answer

The ability to flush the RS-232 send and receive buffers is not available in xPC Target software.
Typically, send and receive buffers should be mostly empty during model execution. This is because your model must be able to process data faster than it arrives, and send data faster than data is ready to be sent.
As a workaround:
  • On the "receive" side, to empty the buffer, you can read and discard incoming data until the buffer is empty.
  • On the "send" side, there is no workaround.