本文摘自:https://blog.csdn.net/colcloud/article/details/42490867
import serial
import string
import binascii
s=serial.Serial('com4',9600)
s.open()
#接收
n=s.inwaiting()
if n:
data= str(binascii.b2a_hex(s.read(n)))[2:-1]
print(data)
#发送
d=bytes.fromhex('10 11 12 34 3f')
s.write(d)
s.close()
“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill
标 题: Python3 串口接收与发送16进制数据包