# 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中將最后要發(fā)送的數(shù)據(jù)轉換成bytes后下位機會報錯?
如下是Python2的代碼,向串口發(fā)送數(shù)據(jù),請問如何改為Python3?
慕田峪4524236
2019-02-20 05:36:24