import serial
ser=serial.Serial("COM3",115200,timeout=0.5) #打开串口
print("我要开始了:")
while (1):
ch=ser.read()
str1=ch.decode("iso-8859-15") #bytes转str
if(str1): #判断数据是否为空,很重要
l=ord(str1) #str转int,方便数据计算和处理
print("%x" % l)
pass
python中串口数据的处理
最新推荐文章于 2024-11-22 16:31:30 发布