Reading serial data in realtime in Python

前端 未结 4 1440
渐次进展
渐次进展 2020-12-02 08:35

I am using a script in Python to collect data from a PIC microcontroller via serial port at 2Mbps.

The PIC works with perfect timing at 2Mbps, also the FTDI usb-seri

4条回答
  •  孤街浪徒
    2020-12-02 09:14

    From the manual:

    Possible values for the parameter timeout: … x set timeout to x seconds

    and

    readlines(sizehint=None, eol='\n') Read a list of lines, until timeout. sizehint is ignored and only present for API compatibility with built-in File objects.

    Note that this function only returns on a timeout.

    So your readlines will return at most every 2 seconds. Use read() as Tim suggested.

提交回复
热议问题