How to clean up Serial port buffer

tuxduino:
Why ? After all, implementing serialEvent() is equivalent to write if (Serial.available() > 0) { ... }
The three dots are what would go into serialEvent().

I think it's just obscure. Why not make it explicit?

void loop ()
  {
  if (Serial.available ())
     processOneByte ();

  // other stuff
  }

Then the OP starts making the serialEvent call wait for more than one character, which hides the fact that s/he has blocked what loop is doing.

And we get this confusion:

But i believe that avr serial port register is left dirty when i am exiting from the serialEvent().