用python写了个最简单的读串口的程序,因为工作中经常需要读串口
放原始代码
import serial
ser = serial.Serial('com3',baudrate=115200, bytesize=8,parity='N', stopbits=1,xonxoff=0, timeout=1)
while( True ):
a = ser.read(100)
print a
用完需要ser.close(),否则其他串口就无法再使用该串口,因为该串口会一直被占用。