aboutsummaryrefslogtreecommitdiff
path: root/cores
diff options
context:
space:
mode:
authorDavid A. Mellis <d.mellis@arduino.cc>2011-05-07 12:05:27 -0400
committerDavid A. Mellis <d.mellis@arduino.cc>2011-05-07 12:05:27 -0400
commitc7c7302d9df5451e6b134d8228bee6c551ca2125 (patch)
treefa2d56442919372eeebae52e58c03c16832ea762 /cores
parent1cac0f3eb738119f53b8fdd07bcd6d1158235476 (diff)
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
Diffstat (limited to 'cores')
-rw-r--r--cores/arduino/HardwareSerial.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp
index 1154ae7..74a0641 100644
--- a/cores/arduino/HardwareSerial.cpp
+++ b/cores/arduino/HardwareSerial.cpp
@@ -359,16 +359,8 @@ int HardwareSerial::read(void)
void HardwareSerial::flush()
{
- // don't reverse this or there may be problems if the RX interrupt
- // occurs after reading the value of rx_buffer_head but before writing
- // the value to rx_buffer_tail; the previous value of rx_buffer_head
- // may be written to rx_buffer_tail, making it appear as if the buffer
- // don't reverse this or there may be problems if the RX interrupt
- // occurs after reading the value of rx_buffer_head but before writing
- // the value to rx_buffer_tail; the previous value of rx_buffer_head
- // may be written to rx_buffer_tail, making it appear as if the buffer
- // were full, not empty.
- _rx_buffer->head = _rx_buffer->tail;
+ while (_tx_buffer->head != _tx_buffer->tail)
+ ;
}
void HardwareSerial::write(uint8_t c)