Menu

#78 'Conflicting edge' exception with GPIO.wait_for_edge()

Done
None
High
Defect
2014-11-11
2014-10-04
Ben Croston
No

Occurs when waiting for a different edge type to the first time GPIO.wait_for_edge() was called.

Discussion

  • Ben Croston

    Ben Croston - 2014-10-04

    Fix pushed to source code library. Will be in next release.

     
  • Ben Croston

    Ben Croston - 2014-10-04
    • status: Accepted --> Started
     
  • Ben Croston

    Ben Croston - 2014-10-11

    Bug found with the following code:

    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()
    

    This produces a continuous output of:
    Button 1 Pressed
    Button 1 Released
    Button 1 Pressed
    Button 1 Released
    Button 1 Pressed
    ...etc.etc...

    See http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=88951

     
  • Ben Croston

    Ben Croston - 2014-10-11

    Have added fix to get it to ignore the initial edge when changing edges. Fix is in source code library.

     
  • Joel Ebel

    Joel Ebel - 2014-10-21

    Perhaps I'm misunderstanding how this is to be used, but if I use your code above, but just trigger on a single GPIO.BOTH within the while loop, I get stuck in a continuous loop. I would have expected it to cycle the loop only when I press or release the button.

    I ran some other tests. Any single wait_for_edge() in a loop starts a continuous loop as soon as the first matching edge is triggered. You have to wait for a different edge type in order for the first edge type to trigger again.

    In my case, I really just want to trigger on falling to start a loop of code, but I need a way to reset it at the end of the loop without having to wait for rising again, since that might have happened while I was in the middle of the loop.

     
  • Ben Croston

    Ben Croston - 2014-11-11
    • status: Started --> Done
     
  • Ben Croston

    Ben Croston - 2014-11-11

    Fixed in release 0.5.8

     
  • human-being

    human-being - 2014-11-11

    With 0.5.8-1, I get this now after one button press:

    RuntimeError: Conflicting edge detection events already exists for this GPIO channel

    No further button presses work. Should I open a new bug?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.