pyserial - 使用 pyserial 从 COM 端口读取数据,但输出为空
问题描述
我想从温度测量中读取数据。该设备通过 USB 连接到 PC。下面显示的代码仅提供此输出:
Serial port is open
b''
b''
b''
b''
有人对我有帮助吗,我已经查找了所有熟悉的问题及其解决方案,但没有一个可以帮助我:/
import serial
ser = serial.Serial(port='COM10', baudrate = 9600, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE,timeout=2)
try:
ser.isOpen()
print("Serial port is open")
except:
print("ERROR")
exit()
if(ser.isOpen()):
try:
while( True ) :
print(ser.read())
except:
print("error")
else:
print("Cannot open serial port")
解决方案
推荐阅读
- node.js - 为什么 ng build 在 Angular 应用程序中不起作用?
- java - 如何通知一个对象另一个对象的事件?爪哇
- angular - @ng-bootstrap、*ngFor 和动态列
- python - TensorFlow多元线性回归占位符和矩阵乘法错误
- python-3.x - fit() 缺少 1 个必需的位置参数:“theta”
- flutter - 如何获得不同的列表
- security - 使用 JHipster UAA 服务的自定义令牌端点
- azure - 使用证书的 Azure AD OAuth 2.0 身份验证代码令牌交换
- javascript - 使用 RequireJS 的网站上的 UMD 不起作用?
- r - 如何根据是否包含某个字符串进行子集化