Hi,
how can I flush or discardbuffer or clear incoming data on serial port? I found, that Serial.flush() doesn't flush serial, but it waits for incoming communication.
So how can I clear the in buffer?
Thanks.
(sorry for my english)
Hello,
Just read characters until there is nothing left in the buffer
while( Serial.available() > 0 )
Serial.read();
Serial.end() will wait until the transmit buffer is empty, shut down the receiver and transmitter, and clear the receive buffer. Call Serial.begin(baudrate) to resume receiving.
You could also loop until the receive buffer is empty:
while(Serial.read() != -1);
Please explain why you want to throw away random amounts of unread data.