Python程序运行时无串口数据的解决方法
本帖最后由 hzxc 于 2023-3-3 10:32 编辑现象:
BXY中串口有数据,Python程序运行时无数据。
BXY程序:
from microbit import *
while True:
print(temperature())
sleep(500)Python程序:
import serial
ser=serial.Serial()
ser.baudrate=115200
ser.port="COM3"
ser.open()
while True:
print(ser.readline())原因:
设备程序运行已停止,进入了命令行交互模式,可能是在BXY串口中点击了停止,或者是其他异常情况。
解决方法(任选其一):
[*]haoda:bit重新开关机
[*]在BXY串口中点击重置,重启micro:bit内置程序,然后关闭BXY
重新运行Python程序就能正常看到数据了。
页:
[1]