Reading serial data in realtime in Python

前端 未结 4 1430
渐次进展
渐次进展 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:16

    You need to set the timeout to "None" when you open the serial port:

    ser = serial.Serial(**bco_port**, timeout=None, baudrate=115000, xonxoff=False, rtscts=False, dsrdtr=False) 
    

    This is a blocking command, so you are waiting until you receive data that has newline (\n or \r\n) at the end: line = ser.readline()

    Once you have the data, it will return ASAP.

提交回复
热议问题