[SOLVED]Flush serial input buffer

"why serial_flush() is not clearing the buffer?"

well because serial_flush() does not clear the buffer. I believe all it does is WAIT until you finish sending data on that serial.