Use python to read serial port data, ser.inWaiting() always returns 0 [Solved]

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:
![Insert picture description here](https://img-blog.csdnimg.cn/bfb8dfd235a840e59c0cd0571cf5bfeb.png#pic_center )

Solution

Add a delay time.sleep() when reading serial data:
insert image description here

Guess you like

Origin blog.csdn.net/Feizhai2/article/details/131291953