Update code

fix some bugs about serial.
Revert "Update code"

This reverts commit 9db04e879f6b9b878971be53a0f60a776ad33898.
Revert "Revert "Update code""

This reverts commit e07a2b5e6e0f8ca98f96b81613c0adc3c7f9ec52.