WebIOPi与I2C设备警报无关

问题描述 投票:-2回答:1

我在Raspberry Pi 2上使用WebIOPi。树莓通过I2C连接到Arduino Nano(Python脚本与Nano配合良好 - 网页上的按钮可以打开或关闭LED)。

当与Arduino的连接断开时(如果线路/线路I2C断开),是否可以发出诊断Javascript警报?

谢谢。

arduino communication webiopi
1个回答
0
投票

解决了低级别(python脚本+返回一些值)。示例python脚本:

try:
    bus.write_byte(address, int(value))
    time.sleep(0.01)
    number = bus.read_byte(address)
    flag = number
except IOError:
    number = 11 #error value (my fantasy)
    flag = number

javascript中用于识别连接状态的“flag”变量,如果flag = 11则报警(“无连接”)

© www.soinside.com 2019 - 2024. All rights reserved.