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

前端 未结 10 1812
再見小時候
再見小時候 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 07:58

    You can use ser.flushInput() to flush out all serial data that is currently in the buffer.

    After clearing out the old data, you can user ser.readline() to get the most recent data from the serial device.

    I think its a bit simpler than the other proposed solutions on here. Worked for me, hope it's suitable for you.

提交回复
热议问题