Try flushing serial port to prevent reading old junk data
Move flush statement to after port is opened
Instead of flushing serial port, just ignore data that comes before the header is recieved