# coding=utf-8import serial
cmd = [0xa5, 0x00, 0x09, 0x0a, 0xcc, 0x33, 0xc3, 0x3c, 0xa6]with serial.Serial('/dev/ttyAMA0', 115200, timeout=1) as ser: for i in cmd:
k = chr(i)
ser.write(k)
s = ser.read(10)
print(s)既然Python2传进去str的是Python3的bytes,为什么我在Python3中将最后要发送的数据转换成bytes后下位机会报错?
添加回答
举报
0/150
提交
取消