树莓皮零售物价指数威胁调用出错

2024-05-23 18:18:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在使用Python包中的wait_for_edge函数 RPi。 我为下降的gpio添加了多个事件检测,只要回调函数不包含comand-like,一切正常

 os.system("mpc pause") 

然后脚本崩溃并显示错误消息:“RunetimeError:error#5 waiting for edge” 有人知道这个错误信息想说什么吗?或者我可以在哪里查到这样的东西?在

具体地说,这一准则起作用:

^{pr2}$

但这段代码并没有:

def next(channel):
    print "In next"
    os.system("mpc next")

GPIO.add_event_detect(buttonnext,GP.FALLING,callback=next,bouncetime=200)

os.system("mpc play")
try:
    GPIO.wait_for_edge(buttonstop, GP.FALLING)
    os.system("mpc stop")
except keyboardInterrupt:
    GPIO.cleanup()
    os.system("mpc stop")
GPIO.cleanup()

它在按下连接到端口按钮stop的按钮后崩溃。在


Tags: 函数forgpioos按钮systemrpinext
1条回答
网友
1楼 · 发布于 2024-05-23 18:18:45

超级骇客,但就在操作系统打电话,如果你取消绑定事件,然后马上重新绑定,它似乎有效。在

def next(channel):
    print "In next"
    os.system("mpc next")
    GPIO.remove_event_detect(buttonnext)
    GPIO.add_event_detect(buttonnext,GP.FALLING,callback=next,bouncetime=200)

相关问题 更多 >