在我的生命中,我无法想出如何使用我的Raspberry Pi在Python 3中进行非阻塞串行读取。
这是我的代码:
import serial #for pySerial
ser = serial.Serial('/dev/ttyUSB0', 9600) #open serial port
print ('serial port = ' + ser.name) #print the port used
while (True):
if (ser.in_waiting>0):
ser.read(ser.in_waiting)
结果:AttributeError: 'Serial' object has no attribute 'in_waiting'
这是我正在引用的引用页,它告诉我“inúu waiting”存在:http://pyserial.readthedocs.io/en/latest/pyserial_api.html
目前没有回答
相关问题 更多 >
编程相关推荐