相关疑难解决方法(0)

pyserial - 如何读取从串行设备发送的最后一行

我有一个Arduino连接到运行循环的计算机,每100毫秒通过串口发送一个值回计算机.

我想制作一个Python脚本,每隔几秒就会从串口读取一次,所以我希望它能看到从Arduino发送的最后一件事.

你是怎么做Pyserial的?

这是我尝试过的代码不起作用的代码.它按顺序读取行.

import serial
import time

ser = serial.Serial('com4',9600,timeout=1)
while 1:
    time.sleep(10)
    print ser.readline() #How do I get the most recent line sent from the device?
Run Code Online (Sandbox Code Playgroud)

python serial-port arduino pyserial

19
推荐指数
4
解决办法
9万
查看次数

标签 统计

arduino ×1

pyserial ×1

python ×1

serial-port ×1