위협적 인 콜백으로 rspberry pi rpi.gpio 오류가 발생했습니다
-
20-12-2019 - |
문제
파이썬 패키지에서 WAIT_FOR_EDGE 기능으로 멈추고 있습니다. rpi . 나는 GPIO가 떨어지는 여러 이벤트 탐지를 추가하며 콜백 함수가
와 같은 comand가 아닌 한편으로 모든 것이 잘 작동합니다. os.system("mpc pause")
.
오류 메시지와 함께 스크립트가 충돌합니다. "runetimeError : ERROR # 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에 연결된 버튼을 누르면 충돌합니다.
해결책
슈퍼 해킹,하지만 OS.System 호출 직후에, 이벤트를 바꾸지 않고 바로 리 바인드하면 작동하는 것 같습니다.
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)
. 제휴하지 않습니다 StackOverflow