【发布时间】:2017-08-13 16:15:33
【问题描述】:
我的树莓派通过串行引脚连接到微控制器。我正在尝试从串口读取数据。该脚本读取数据几秒钟。但是,它会终止抛出以下异常
serial.serialutil.SerialException:设备报告已准备好读取但未返回数据(设备已断开连接?)
我使用了以下python代码
#!/usr/bin/python
import serial
import time
serialport = serial.Serial("/dev/ttyAMA0", 115200, timeout=.5)
while 1:
response = serialport.readlines(None)
print response
time.sleep(.05)
serialport.close()
【问题讨论】:
标签: python python-2.7 serial-port raspberry-pi