leo25 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

serial flush() not clearing the RX buffer in 1.0-beta1 #593

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
the serial.flush() function in 1.0-beta1 is not clearing the rx-buffer any 
more....

if you are using this function in a lib to clear the rx-buffer if needed, this 
will not longer work.

i think serial.flush() should do the same thing it ever did.
add a function like flushTX() to clear the TX buffer.
or add two new functions flushTX() and flushRX()
something like this:

void HardwareSerial::flushRX()
{
  _rx_buffer->head = _rx_buffer->tail;  
}

// this is the code
void HardwareSerial::flushTX()
{
 while (_tx_buffer->head != _tx_buffer->tail);
}

Original issue reported on code.google.com by Chef.Me...@gmail.com on 23 Aug 2011 at 7:21

GoogleCodeExporter commented 9 years ago
Sorry, this was one of those things we decided to break from 0022 to 1.0 in 
order to make it more consistent with the usual meaning of the flush() function 
in other languages / APIs.

Original comment by dmel...@gmail.com on 10 Oct 2011 at 4:38

GoogleCodeExporter commented 9 years ago
So how can we clear rx buffer from now on?

I would prefer to avoid modify hardware serial source code to do this

Original comment by magn...@gmail.com on 8 May 2012 at 5:25