Fix a bug for serial communication