pyserial - How to read the last line sent from a serial device

前端 未结 10 1809
再見小時候
再見小時候 2020-12-02 07:12

I have an Arduino connected to my computer running a loop, sending a value over the serial port back to the computer every 100 ms.

I want to make a Python scr

10条回答
  •  星月不相逢
    2020-12-02 08:02

    Using .inWaiting() inside an infinite loop may be problematic. It may hog up the entire CPU depending on the implementation. Instead, I would recommend using a specific size of data to be read. So in this case the following should be done for example:

    ser.read(1024)
    

提交回复
热议问题