Python3 串口接收与发送16进制数据包的实例

时间:2021-03-01 16:21:59   收藏:0   阅读:168

Python3 串口接收与发送16进制数据包的实例

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()

 

原文:https://www.cnblogs.com/ksxh/p/14462967.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!