add query history feature & fix serial port's infinite blocking write