Moved input buffer flushing into the open_serial_port() function