python串口通信
首先用USB线连上串口设备,然后确认是哪个COM口,下面用COM3为例。
import serial
t=serial.Serial('COM3',115200)
command = "aabbccddee" //十六进制字符串
t.write(command.decode("hex")) //转换成十六进制发送,否则设备不认识
print t.read(16)
如果发送的信息“aabbccddee”是奇数,decode函数会报错
发布时间: 2012-12-24 10:43:13 作者: rapoo
python串口通信
首先用USB线连上串口设备,然后确认是哪个COM口,下面用COM3为例。
import serial
t=serial.Serial('COM3',115200)
command = "aabbccddee" //十六进制字符串
t.write(command.decode("hex")) //转换成十六进制发送,否则设备不认识
print t.read(16)
如果发送的信息“aabbccddee”是奇数,decode函数会报错