没有合适的资源?快使用搜索试试~ 我知道了~
首页python 串口读取+存储+输出处理实例
python 串口读取+存储+输出处理实例
需积分: 36 2.5k 浏览量
更新于2023-05-28
评论 4
收藏 31KB PDF 举报
研究了一晚上的成果。 import serial import win32com.client import matplotlib.pyplot as plt import numpy as np ser = serial.Serial("COM6", 115200, bytesize = 8,timeout=0.5) # 打开串口 print("我要开始了:") res=[] while (1): ch = ser.readline(1) result = '' hLen = len(ch) for i in range(hLen): hv
资源详情
资源评论
资源推荐

python 串口读取串口读取+存储存储+输出处理实例输出处理实例
研究了一晚上的成果。
import serial
import win32com.client
import matplotlib.pyplot as plt
import numpy as np
ser = serial.Serial("COM6", 115200, bytesize = 8,timeout=0.5) # 打开串口
print("我要开始了:")
res=[] while (1):
ch = ser.readline(1)
result = ''
hLen = len(ch)
for i in range(hLen):
hvol = ch[i] hhex = '%02x' % hvol
result += hhex + ' '
sz=[] res.append(result)
if len(res)==100:
j=0
for i in range(len(res)-1):
# 十六进制转十进制
if "fc" in res[i]:
print(i)
sz.append(int(res[i + 1], 16)*256+int(res[i],16))
#print(sz)
else:
continue
print("asd")
print(type(sz[1]))
speaker = win32com.client.Dispatch("SAPI.SpVoice")
speaker.Speak("请保持均匀呼吸")
x = [] for i in range(0, len(sz)):
x.append(i)
plt.plot(x, sz)
plt.show()
print(res)
break
以上这篇python 串口读取+存储+输出处理实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多
支持软件开发网。
您可能感兴趣的文章您可能感兴趣的文章:使用Python串口实时显示数据并绘图的例子python3 实现调用串口功能Python 实现Serial 与STM32J进
行串口通讯

















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0