Abdellazizhammami / arduino

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

With Arduino v1.0 Serial.flush() not work in setup() #733

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

void Setup() {

...                     // Configure Pins MatrixLED

 Serial.begin(1200) ;   // 1200bauds 7N1
 UCSR0C = B00000100 ;   // My External Device needs 7 bit DATA

 delay (10000);         // Tx Data to Arduino board i.e. HOLA<CR>
                        // My code output wellcome scroll Msg Text to Matrix LED 

 Serial.println( Serial.available() ); // Output = 5 
 Serial.flush();
 Serial.println( Serial.available() ); // Output = 5 
}

Gracias!

What is the expected output? -->  5 & 0
What do you see instead?   ---->  5 & 5

O.S. -----> Ubuntu 11.04
Board ----->  Serial with MAX232 & ATMEGA328 . (I select Duemilanove/328 in IDE)
With IDE v1.0  Serial.flush() not work in setup().
With IDE v0.23 alpha works fine.

Original issue reported on code.google.com by txu...@gmail.com on 2 Dec 2011 at 12:51

GoogleCodeExporter commented 8 years ago
The behavior of Serial.flush() changed in Arduino 1.0, so this is expected.  
Now it waits for outgoing characters to be sent, instead of dropping any 
received characters.

Original comment by dmel...@gmail.com on 17 Dec 2011 at 1:14

GoogleCodeExporter commented 8 years ago
Ok, but my sketch only Rx data, and due to hardware conexions i can't Tx 
anything.
And i need clear the buffer Rx.
Solution with v1.0:
   while(Serial.available()>0) Serial.read();

Original comment by txu...@gmail.com on 17 Dec 2011 at 1:51

GoogleCodeExporter commented 8 years ago
Actual (21/12/2011) Copy&Paste from: http://arduino.cc/en/Serial/Flush

Flushes the buffer of incoming serial data. Any call to Serial.read() or 
Serial.available() will return only data received after all the most recent 
call to Serial.flush().

Serial.flush() waits for outgoing data to transmit before clearing the buffer 
contents.

Original comment by txu...@gmail.com on 21 Dec 2011 at 5:00