Python pyserial不';t工作一次,以“结束”;ctrl+;",;,只有在重新启动之前才能恢复?

Python pyserial不';t工作一次,以“结束”;ctrl+;",;,只有在重新启动之前才能恢复?,python,ubuntu,serial-port,Python,Ubuntu,Serial Port,将我的程序从winxp移动到ubuntu,遇到一个奇怪的问题 我这样测试它: #!/usr/bin/python import time from platform import system import serial if system()=="Windows": serId =2 else: serId = '/dev/ttyUSB0' ser= serial.Serial(serId, 115200, timeout=1) while True: star

将我的程序从winxp移动到ubuntu,遇到一个奇怪的问题

我这样测试它:

#!/usr/bin/python

import time
from platform import system
import serial
if system()=="Windows":
    serId =2
else:
    serId = '/dev/ttyUSB0'


ser= serial.Serial(serId, 115200, timeout=1)

while True:
    start=time.time()
    ser.write('1')
    t=ser.read(128)
    print time.time()-start
    print len([i for i in t if i != '']), t
赢了,没关系。 输出:

在Ubuntu上, 起初,似乎和胜利一样。 但是,当我用Ctrl+C终止并重新启动它时

time will be 3s and even more
can receive all the 128B content I send.
我将
ser.flush()
添加到
write
read
之前。没有什么变化

怎么了?ubuntu和xp之间的差异有什么特殊原因吗

time will be 3s and even more
can receive all the 128B content I send.