我陷入了Python包 RPi中的wait_for_edge函數。 我添加了多個事件檢測落下的GPIO的,並且只要回調函數包含不喜歡Raspberry Pi RPi.GPIO錯誤與威脅回調
os.system("mpc pause")
然後腳本錯誤消息就死機COMAND一切正常:「RunetimeError:錯誤#5等候邊緣」 有人知道,這個錯誤消息想說什麼?或者我可以在這裏查找這樣的東西?
具體地說此代碼的工作:
def next(channel):
print "In 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()
但這個代碼犯規:
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()
它推動連接到端口buttonstop按鈕後崩潰。
這可能聽起來很愚蠢,但嘗試重新啓動Pi。幾次GPIO引腳有這樣的奇怪的錯誤對我來說,重新啓動修復它 – DeadChex
不幸的是,重新啓動沒有幫助。我注意到os命令是在腳本崩潰之前完成的。 – Thorsten