ezieragabriel / arduino

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

Serial.flush() does not function properly #911

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. When Serial.available() reports more than 1 byte calling Serial.flush() does 
not free the buffer.

Arduino software 1.0 on WindowsXP with an Arduino Uno board.

if you code something like this:

while(Serial.available() > 0){
   char c = Serial.read();
   Serial.println(c);
   Serial.flush();
}

if you send, via SerialMonitor something like this:
ABCDEF
You receive:
A
B
C
D
E
F
So there is no flush() at all.

Original issue reported on code.google.com by servando...@gmail.com on 8 May 2012 at 12:08

GoogleCodeExporter commented 9 years ago
The behavior of the flush() command changed in 1.0.  (This may not have been a 
great idea.)  It now waits for outgoing serial data to finish transmitting; it 
doesn't empty the incoming buffer.

Original comment by dmel...@gmail.com on 9 May 2012 at 12:28