'RuntimeError: Failed to add edge detection' when running script for 2nd time with raspi-gpio 0.6.4 #687
Description
Operating system: e.g. Raspbian Stretch
Pi model: Pi 3 Model B+
GPIO Zero version: 1.4.1
Pin factory used: e.g. RPiGPIO
I'm testing a simple GPIO push button script. After a fresh reboot the first time the script is run it works great. However, after stopping the script than trying to run it again I get error RuntimeError: Failed to add edge detection.
Do I need to remove the edge detection interrupt? I though gpiozero should do this automatically? I've tried running the script as root.
I'm experiencing the same as #232 but updating rpi.gpio did not fix the issue, I'm already running the latest version available on Stretch (0.6.4). The issue could be re-occurrence of #38?
Update: I first noticed the issue after updating to the default latest version of rpi-gpio 0.6.4 (released 21st Oct 18), downgrading to rpi-gpio 0.6.3 fixed the issue:
$ sudo pip install RPi.GPIO==0.6.3
How should I proceed with this? As far as I understand this seems to be an issue with rpi-gpio rather than gpiozero? Should I open this issue with rpi-gpio?
Interestingly apt-get is still showing python-rpi.gpio 0.6.4 is still installed:
sudo apt-get install python-rpi.gpio
python-rpi.gpio is already the newest version (0.6.4~stretch-1).
Sorry I don't fuilly understand the between the apt-get package and pip? It seems I've currently got installed pip rpi.gpio==0.6.3 and apt-get python-rpi.gpio=0.6.4
from gpiozero import Button
from signal import pause
print ("Push button test")
def buttonPressLong():
print ("long press")
def buttonPress():
print "short press"
push_btn = Button(23, pull_up=False, hold_time=5, bounce_time=0.1)
push_btn.when_pressed = buttonPress
push_btn.when_held = buttonPressLong
pause()
Traceback (most recent call last):
File "push_and_hold.py", line 16, in <module>
push_btn = Button(23, pull_up=False, hold_time=5, bounce_time=0.1)
File "/usr/lib/python2.7/dist-packages/gpiozero/devices.py", line 95, in __call__
self = super(GPIOMeta, cls).__call__(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/gpiozero/input_devices.py", line 303, in __init__
pin, pull_up, bounce_time, pin_factory=pin_factory
File "/usr/lib/python2.7/dist-packages/gpiozero/mixins.py", line 338, in __init__
super(HoldMixin, self).__init__(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/gpiozero/input_devices.py", line 100, in __init__
self.pin.when_changed = self._fire_events
File "/usr/lib/python2.7/dist-packages/gpiozero/pins/__init__.py", line 388, in <lambda>
lambda self, value: self._set_when_changed(value),
File "/usr/lib/python2.7/dist-packages/gpiozero/pins/pi.py", line 289, in _set_when_changed
self._enable_event_detect()
File "/usr/lib/python2.7/dist-packages/gpiozero/pins/rpigpio.py", line 219, in _enable_event_detect
bouncetime=self._bounce)
RuntimeError: Failed to add edge detection
uname -a
Linux emonpi 4.14.71-v7+ #1145 SMP Fri Sep 21 15:38:35 BST 2018 armv7l GNU/Linux