Skip to content

Commit 930f053

Browse files
committed
Changing Serial.flush() to write outgoing data, not drop incoming data.
This brings it in line with most other uses of flush(), both in and out of Arduino. http://code.google.com/p/arduino/issues/detail?id=497
1 parent 5aa5454 commit 930f053

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

hardware/arduino/cores/arduino/HardwareSerial.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -359,16 +359,8 @@ int HardwareSerial::read(void)
359359

360360
void HardwareSerial::flush()
361361
{
362-
// don't reverse this or there may be problems if the RX interrupt
363-
// occurs after reading the value of rx_buffer_head but before writing
364-
// the value to rx_buffer_tail; the previous value of rx_buffer_head
365-
// may be written to rx_buffer_tail, making it appear as if the buffer
366-
// don't reverse this or there may be problems if the RX interrupt
367-
// occurs after reading the value of rx_buffer_head but before writing
368-
// the value to rx_buffer_tail; the previous value of rx_buffer_head
369-
// may be written to rx_buffer_tail, making it appear as if the buffer
370-
// were full, not empty.
371-
_rx_buffer->head = _rx_buffer->tail;
362+
while (_tx_buffer->head != _tx_buffer->tail)
363+
;
372364
}
373365

374366
void HardwareSerial::write(uint8_t c)

0 commit comments

Comments
 (0)