好的,我实际上得到了一些我喜欢的东西。使用
read()无超时和
inWaiting()方法的组合:
#Modified pre from main loop: s = serial.Serial(5)#Modified pre from thread reading the serial portwhile 1: tdata = s.read()# Wait forever for anything time.sleep(1) # Sleep (or inWaiting() doesn't give the correct value) data_left = s.inWaiting() # Get the number of characters ready to be read tdata += s.read(data_left) # Do the read and combine it with the first character ... #Rest of the pre
这似乎可以提供我想要的结果,我想这种功能在Python中不存在为单个方法
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)