Page 1 of 1

"RuntimeError: Conflicting edge detection events already"

Posted: Fri Oct 10, 2014 1:06 pm
by sander2
I get "RuntimeError: Conflicting edge detection events already exists for this GPIO channel" with an easy piece of GPIO code (based on the code on http://makezine.com/projects/tutorial-r ... nd-python/ )

Code: Select all

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
while True:
	GPIO.wait_for_edge(23, GPIO.RISING)
	print("Button 1 Pressed")
	GPIO.wait_for_edge(23, GPIO.FALLING)
	print("Button 1 Released")

GPIO.cleanup()
Problem occurs as soon as I disconnect wire GPIO23 from 3V3. And it happens every time.
Python GPIO version is RPi.GPIO-0.5.7

Code: Select all

$ sudo python pin23-flank.py 
Button 1 Pressed
Traceback (most recent call last):
  File "pin23-flank.py", line 7, in <module>
    GPIO.wait_for_edge(23, GPIO.FALLING)
RuntimeError: Conflicting edge detection events already exists for this GPIO channel
Seems related to:
http://sourceforge.net/p/raspberry-gpio ... ickets/72/
http://blog.scribblechunks.com/raspberry-pi-gpio-issue/

Tips how to solve this or how to proceed?

Re: "RuntimeError: Conflicting edge detection events already

Posted: Fri Oct 10, 2014 1:25 pm
by croston
I have developed the fix for this - it will be in the next release. In the meantime, you can install a development version that contains the fix:

http://sourceforge.net/p/raspberry-gpio ... age=1#ccfb

Let me know if it solves your problem!

Re: "RuntimeError: Conflicting edge detection events already

Posted: Fri Oct 10, 2014 2:15 pm
by sander2
EDIT:

Even after the "sudo apt-get remove python-rpi.gpio python3-rpi.gpio" followed by the pip / pip-3.2 install, the program goes into a loop.

I will rerun the whole procedure just to be sure



Older message:


Thanks. I did that; from my history:

Code: Select all

sudo python pin23-follow-based-on-polling.py
sudo apt-get install python-dev python3-dev
sudo apt-get install mercurial
sudo apt-get install python-pip python3-pip

sudo apt-get remove python-rpi.gpio python3-rpi.gpio

sudo pip install -e hg+http://hg.code.sf.net/p/raspberry-gpio-python/code#egg=RPi.GPIO
sudo pip-3.2 install -e hg+http://hg.code.sf.net/p/raspberry-gpio-python/code#egg=RPi.GPIO

The code now runs without errors, but just one "button press" (+release) results in an endless automatic list of
Button 1 Released
Button 1 Pressed
Button 1 Released
Button 1 Pressed
Button 1 Released
Button 1 Pressed
Button 1 Released
Button 1 Pressed
Button 1 Released
Button 1 Pressed
Button 1 Released
Button 1 Pressed
Button 1 Released
Button 1 Pressed
Button 1 Released
Button 1 Pressed
Button 1 Released
Button 1 Pressed
Button 1 Released
... until I press Control C

That's not good, is it?

Re: "RuntimeError: Conflicting edge detection events already

Posted: Fri Oct 10, 2014 2:27 pm
by sander2
Uninstall RPi.GPIO:

Code: Select all

[email protected] ~/pinnetje $ sudo pip uninstall RPi.GPIO
Uninstalling RPi.GPIO:
Proceed (y/n)? y
  Successfully uninstalled RPi.GPIO
You have new mail in /var/mail/pi
[email protected] ~/pinnetje $ sudo pip-3.2 uninstall RPi.GPIO
Uninstalling RPi.GPIO:
Proceed (y/n)? y
  Successfully uninstalled RPi.GPIO
and then:

Code: Select all

[email protected] ~/pinnetje $ python
Python 2.7.3 (default, Mar 18 2014, 05:13:23) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO
>>> 
How is that possible? Uninstalled, but still there?

:shock:

Re: "RuntimeError: Conflicting edge detection events already

Posted: Sat Oct 11, 2014 8:10 pm
by croston
Sorry - it turns out that my instructions were wrong. To get out of the weird problem where it doesn't uninstall properly:

sudo nano /usr/local/lib/python2.7/dist-packages/easy-install.pth
Delete the line containing rpi.gpio
sudo nano /usr/local/lib/python3.2/dist-packages/easy-install.pth
Delete the line containing rpi.gpio

I have fixed your latest problem of the repeating edges (https://sourceforge.net/p/raspberry-gpi ... s/78/#82b0).

To test the fix:

Code: Select all

sudo apt-get install python-dev python3-dev
sudo apt-get install mercurial
sudo apt-get install python-pip python3-pip
sudo apt-get remove python-rpi.gpio python3-rpi.gpio
sudo pip install hg+http://hg.code.sf.net/p/raspberry-gpio-python/code#egg=RPi.GPIO
sudo pip-3.2 install hg+http://hg.code.sf.net/p/raspberry-gpio-python/code#egg=RPi.GPIO
Note the lack of the '-e' in the pip install commands that was there before - this is what was causing the problems uninstalling.

To uninstall and return back to the standard version in Raspbian:

Code: Select all

sudo pip uninstall RPi.GPIO
sudo pip-3.2 uninstall RPi.GPIO
sudo apt-get install python-rpi.gpio python3-rpi.gpio
It should work properly this time. I'm sure you'll let me know if it doesn't!

Re: "RuntimeError: Conflicting edge detection events already

Posted: Sun Oct 12, 2014 7:03 pm
by sander2
Trying to install, I get:

Code: Select all

[email protected] ~/pinnetje $ sudo pip install hg+http://hg.code.sf.net/p/raspberry-gpio-python/code#egg=RPi.GPIO
Requirement already satisfied (use --upgrade to upgrade): RPi.GPIO from hg+http://hg.code.sf.net/p/raspberry-gpio-python/code in ./src/rpi.gpio
Cleaning up...
[email protected] ~/pinnetje $ sudo pip-3.2 install hg+http://hg.code.sf.net/p/raspberry-gpio-python/code#egg=RPi.GPIO
Requirement already satisfied (use --upgrade to upgrade): RPi.GPIO from hg+http://hg.code.sf.net/p/raspberry-gpio-python/code in ./src/rpi.gpio
Cleaning up...
So I tried:

Code: Select all

[email protected] ~/pinnetje $ sudo pip install --upgrade hg+http://hg.code.sf.net/p/raspberry-gpio-python/code#egg=RPi.GPIO
Requirement already up-to-date: RPi.GPIO from hg+http://hg.code.sf.net/p/raspberry-gpio-python/code in ./src/rpi.gpio
Cleaning up...
[email protected] ~/pinnetje $ 
[email protected] ~/pinnetje $ sudo pip-3.2 install --upgrade hg+http://hg.code.sf.net/p/raspberry-gpio-python/code#egg=RPi.GPIO
Requirement already up-to-date: RPi.GPIO from hg+http://hg.code.sf.net/p/raspberry-gpio-python/code in ./src/rpi.gpio
Cleaning up...
[email protected] ~/pinnetje $ 
No error message, but:

Code: Select all

[email protected] ~/pinnetje $ python
Python 2.7.3 (default, Mar 18 2014, 05:13:23) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named RPi.GPIO
>>> 
So not good. :(

Tips how to proceed?

Re: "RuntimeError: Conflicting edge detection events already

Posted: Sun Oct 12, 2014 7:16 pm
by sander2
Ah ... got it working!

There was a 'src' directory owned by root in the working directory. It seemed to contain RPi.GPIO stuff.
I removed it, and to be sure, created a dummy working directory:

Code: Select all

sudo rm -rf src
mkdir dummy
cd dummy/
sudo pip install 'hg+http://hg.code.sf.net/p/raspberry-gpio-python/code#egg=RPi.GPIO'
sudo pip-3.2 install hg+http://hg.code.sf.net/p/raspberry-gpio-python/code#egg=RPi.GPIO
Bingo! The code below is now working and report power consumption ... :)

Code: Select all

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
while True:
	GPIO.wait_for_edge(23, GPIO.RISING)
	print("Button 1 Pressed")
	GPIO.wait_for_edge(23, GPIO.FALLING)
	print("Button 1 Released")

GPIO.cleanup()
Thank you for your help and your code.

Re: "RuntimeError: Conflicting edge detection events already

Posted: Mon Oct 13, 2014 7:37 pm
by sander2
Question: why is waiting for GPIO.RISING only (as in the second code snippet) not enough? Only waiting for GPIO.RISING will print an endless of "up" after the first GPIO.RISING trigger. I would expect that print only to happen once at the GPIO.RISING trigger, and then not until the following GPIO.RISING trigger?

In other words: why do I need to explicitly wait for the GPIO.FALLING?

Working if waiting for GPIO.RISING and then waiting for GPIO.FALLING:

Code: Select all

#!/usr/bin/env python
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
########## Main Loop 
while True:
	# wait for pin going up
	GPIO.wait_for_edge(23, GPIO.RISING)
	print "up"
	# and wait for pin going down
	GPIO.wait_for_edge(23, GPIO.FALLING)
	print "down"
Not working if only waiting for GPIO.RISING:

Code: Select all

#!/usr/bin/env python
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
########## Main Loop 
while True:
	# wait for pin going up
	GPIO.wait_for_edge(23, GPIO.RISING)
	print "up"

Re: "RuntimeError: Conflicting edge detection events already

Posted: Mon Oct 13, 2014 7:39 pm
by croston
I'll take a look when I get back from the pub!

Re: "RuntimeError: Conflicting edge detection events already

Posted: Mon Oct 13, 2014 7:53 pm
by sander2
croston wrote:I'll take a look when I get back from the pub!
In the pub? Good for you! But ... no 'phone stacking' in place, I guess? ;)

Re: "RuntimeError: Conflicting edge detection events already

Posted: Wed Oct 15, 2014 12:13 pm
by sander2
Hi Croston, any news on this?

FWIW: I'm just suprised, and I have it working with the extra FALLING, so no big deal if it must stay that way.

Re: "RuntimeError: Conflicting edge detection events already

Posted: Sat Oct 18, 2014 3:29 am
by jbebel
Same thing here. I'm just calling GPIO.wait_for_edge(state_change, GPIO.FALLING), without having a corresponding GPIO.RISING wait, and it gets stuck in a loop as soon as it sees the first falling edge. Is this a bug, or an inappropriate way to use the library?

Re: "RuntimeError: Conflicting edge detection events already

Posted: Sat Oct 18, 2014 1:18 pm
by sander2
I have put my code on github: https://github.com/sanderjo/GPIO-counter

Full description: https://github.com/sanderjo/GPIO-counte ... /README.md

Code: Select all

$ sudo ./gpio-counter.py 
./gpio-counter.py <gpio-pin-number> <filename> [debug]
Example usage: 
./gpio-counter.py 23 /path/to/mylogfile
./gpio-counter.py 23 /path/to/mylogfile debug
If you use it, I would like to hear feedback.

Thanks

Re: "RuntimeError: Conflicting edge detection events already

Posted: Tue Nov 18, 2014 1:18 pm
by GeofP
There is still a problem with RPi.GPIO 0.5.8. Please see my comments at: http://www.raspberrypi.org/forums/viewt ... 19#p642319.
After detecting the falling edge,

Code: Select all

while True:
      GPIO.wait_for_edge(23, GPIO.FALLING)
the following code loops without any further edge changes.