把我的程序从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
赢了,没关系。输出:
0.9
128 ************************************************
在 Ubuntu 上,起初似乎与 win 相同。但是,当我用 Ctrl+C 终止并重新启动它时。
time will be 3s and even more
can receive all the 128B content I send.
我在和ser.flush()
之前添加。没变化。write
read
其中有什么问题?有什么特殊原因导致ubuntu和xp之间的区别吗?