Troubleshooting:
In the linux environment, use python to read serial port (/dev/ttyUSB0) data, ser.inWaiting() always returns 0, use cutecom to confirm that the serial port number and baud rate are correct, and the data can be read normally in linux .
But in the code, the value of ser.inWaiting() is always 0, which makes it impossible to make the next judgment:
Solution
Add a delay time.sleep() when reading serial data: