我已经下载了ceSerial并成功与串口通信。我已成功将数据写入端口,但我无法从端口读取数据。它已连接到端口但无法读取值。下面是我从端口读取数据的代码片段。
from time import sleep
import ceserial
ser = ceserial.Serial(port="COM1:",baudrate=9600,bytesize=8,stopbits=ceserial.STOPBITS_ONE,parity=ceserial.PARITY_EVEN)
print("connected to: " + ser.portstr)
#data = ''
while True:
data = ser.read(9999)
if len(data) > 0:
print 'Got:', data
sleep(0.5)
#print 'not blocked'
ser.close()