Menu

#72 wait_for_edge() fails after "too many" calls in 0.5.6

Fixed
None
Critical
Patch
2014-12-13
2014-08-22
human-being
No

The user sees the error message "Error #3 waiting for edge" after wait_for_edge() has been called a large number of times. (Reports indicate somewhere under 1024 times.)

I've read older related closed issues on here ([#38] and [#39]) and Google Code, and it looks like this commit introduced the changes that lead to the C code being unable to open the "/sys/class/gpio/gpio*/value" file for input. open_value_file in event_gpio.c is where the bug surfaces.

I am really rusty with my C code, but I did observe some things.

When the bug occurs, I can fire up a second instance of my code and not see the bug until the requisite number of calls has happened, so the limit is not something at the OS level; it's within a given session of the program that uses the GPIO library.

I tried some simple timing tests. I made each wait_for_edge() call after a delay, and this didn't fix the bug. Similarly, I tried a timeout and retry to re-open the GPIO file, but this didn't help, either.

Related

Tickets: #38
Tickets: #39
Tickets: #72

Discussion

  • human-being

    human-being - 2014-08-22

    This was tested against release 0.5.6, but I've tested it in 0.5.5 as well.

     
  • human-being

    human-being - 2014-09-01

    I am unable to reproduce the issue in 0.5.4. Anyone else having this issue should try 0.5.4 as well.

     
  • human-being

    human-being - 2014-09-02

    I did some further testing. My previous tests have been with python 2.7, which show that v0.5.4 doesn't have the bug, but v0.5.5 and v0.5.6 do. With python 3.2, I can reproduce the bug in version 0.5.4 as well.

    I will submit a unit test patch that 1) reproduces the bug in this report, and 2) works with python 2.x and 3.x.

     
  • human-being

    human-being - 2014-09-02

    I finished testing versions 0.5.4, 0.5.5, and 0.5.6 against python 2.7 and python 3.2. All combinations exhibit the bug except 0.5.4 x 2.7. For some reason, it works perfectly.

     
  • human-being

    human-being - 2014-09-04

    See https://sourceforge.net/p/raspberry-gpio-python/code/merge-requests/1/ for a merge request that adds the ability to test for this issue in your default testing environment.

     
    • Ben Croston

      Ben Croston - 2014-09-04

      I might have fixed it in the latest development version - I have just introduced a unit test for lots of edges that passes. Could you test the development version in the source code library to see if it fixes your problems.

      I will add your test to the unit test script. Hopefully I will release 0.5.7 in the next few da.

      Ben

      On 4 September 2014 19:16:20 GMT+01:00, human-being human-being@users.sf.net wrote:

      See
      https://sourceforge.net/p/raspberry-gpio-python/code/merge-requests/1/
      for a merge request that adds the ability to test for this issue in
      your default testing environment.


      [tickets:#72] wait_for_edge() fails after "too many" calls in
      0.5.6

      Status: New
      Created: Fri Aug 22, 2014 07:31 PM UTC by human-being
      Last Updated: Tue Sep 02, 2014 08:22 PM UTC
      Owner: nobody

      The user sees the error message "Error #3 waiting for edge" after
      wait_for_edge() has been called a large number of times. (Reports
      indicate somewhere under 1024 times.)

      I've read older related closed issues on here ([#38] and [#39]) and
      Google
      Code
      ,
      and it looks like this
      commit

      introduced the changes that lead to the C code being unable to open the
      "/sys/class/gpio/gpio*/value" file for input. open_value_file in
      event_gpio.c is where the bug surfaces.

      I am really rusty with my C code, but I did observe some things.

      When the bug occurs, I can fire up a second instance of my code and not
      see the bug until the requisite number of calls has happened, so the
      limit is not something at the OS level; it's within a given session of
      the program that uses the GPIO library.

      I tried some simple timing tests. I made each wait_for_edge() call
      after a delay, and this didn't fix the bug. Similarly, I tried a
      timeout and retry to re-open the GPIO file, but this didn't help,
      either.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/raspberry-gpio-python/tickets/72/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      Sent from my Android device with K-9 Mail. Please excuse my brevity.

       

      Related

      Tickets: #38
      Tickets: #39
      Tickets: #72

  • human-being

    human-being - 2014-09-04

    Cool. Just to be clear, do you mean for me to test in default/tip? Looks like 7/28 was the latest commit there.

     
  • human-being

    human-being - 2014-09-04

    In a mini version of the test, it fails before doing edge detection:

    pi@pi2 ~/u-human-being-raspberry-gpio-python $ sudo python2.7 test/bobtest.py 
    test/bobtest.py:52: RuntimeWarning: No channels have been set up yet - nothing to clean up!  Try cleaning up at the end of your program instead!
      GPIO.cleanup()
    .........
    Tests that we can perform more than 510 consecutive rise/fall detections.
    FAILURE: Conflicting edge detection events already exists for this GPIO channel after 1 iterations out of 4000
    F.....
    ======================================================================
    FAIL: testRiseFallLoop (__main__.TestEdgeDetection)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test/bobtest.py", line 153, in testRiseFallLoop
        self.assertEqual(iterations, iterations_max)
    AssertionError: 1 != 4000
    
    ----------------------------------------------------------------------
    Ran 15 tests in 15.781s
    
    FAILED (failures=1)
    

    I noticed the same error when trying the bleeding edge version in my project. I assumed I deserved what I got for not using a release :)

     
  • Ben Croston

    Ben Croston - 2014-09-13
    • status: New --> Fixed
    • assigned_to: Ben Croston
     
  • Ben Croston

    Ben Croston - 2014-09-13

    This should be fixed in release 0.5.7 - please confirm!

     
  • human-being

    human-being - 2014-09-15

    I am unable to test because there's a new bug blocking this one, as I reported earlier:
    RuntimeError: Conflicting edge detection events already exists for this GPIO channel

     
  • human-being

    human-being - 2014-09-15

    If you grab my merge request, it includes a test for this issue. You'll see where it fails.

     
    • Ben Croston

      Ben Croston - 2014-09-16

      I'll take another look - thanks for keeping me informed!

      Ben Croston

      On 15 September 2014 23:53:55 GMT+01:00, human-being human-being@users.sf.net wrote:

      If you grab my merge request, it includes a test for this issue. You'll
      see where it fails.


      [tickets:#72] wait_for_edge() fails after "too many" calls in
      0.5.6

      Status: Fixed
      Created: Fri Aug 22, 2014 07:31 PM UTC by human-being
      Last Updated: Mon Sep 15, 2014 10:51 PM UTC
      Owner: Ben Croston

      The user sees the error message "Error #3 waiting for edge" after
      wait_for_edge() has been called a large number of times. (Reports
      indicate somewhere under 1024 times.)

      I've read older related closed issues on here ([#38] and [#39]) and
      Google
      Code
      ,
      and it looks like this
      commit

      introduced the changes that lead to the C code being unable to open the
      "/sys/class/gpio/gpio*/value" file for input. open_value_file in
      event_gpio.c is where the bug surfaces.

      I am really rusty with my C code, but I did observe some things.

      When the bug occurs, I can fire up a second instance of my code and not
      see the bug until the requisite number of calls has happened, so the
      limit is not something at the OS level; it's within a given session of
      the program that uses the GPIO library.

      I tried some simple timing tests. I made each wait_for_edge() call
      after a delay, and this didn't fix the bug. Similarly, I tried a
      timeout and retry to re-open the GPIO file, but this didn't help,
      either.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/raspberry-gpio-python/tickets/72/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      Sent from my Android device with K-9 Mail. Please excuse my brevity.

       

      Related

      Tickets: #38
      Tickets: #39
      Tickets: #72

  • DerpCoder

    DerpCoder - 2014-09-27

    Hello,

    I'm wondering if this issue have been addressed and will be fixed on the next version?

    I just got my new Raspberry Pi and been having this issue with Version 0.5.7

     
  • turbosnute

    turbosnute - 2014-10-02

    I'm still experiencing this error in version 0.5.7.
    If i try to fall wait_for_edge more than one (like the example below) time i get the error "RuntimeError: Conflicting edge detection events already exists for this GPIO channel".

    GPIO.wait_for_edge(24, GPIO.FALLING)
    time.sleep(1)
    GPIO.wait_for_edge(24, GPIO.RISING)

     
  • Ben Croston

    Ben Croston - 2014-10-04

    The 'Conflicting edge' exception is a new issue and I have opened a new ticket here -->
    https://sourceforge.net/p/raspberry-gpio-python/tickets/78

     
  • human-being

    human-being - 2014-10-04

    I think it's confusing that this is marked Fixed, since the issue in #78 blocks the ability to test #72. You may get fewer queries about #72 if it's re-opened.

     
  • Ben Croston

    Ben Croston - 2014-10-04

    A fix for issue 78 is now available. To install it so that you can test:
    $ 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

    To uninstall it and return to the latest release in Raspbian:
    $ sudo pip uninstall RPi.GPIO
    $ sudo pip-3.2 uninstall RPi.GPIO
    $ sudo apt-get install python-rpi-gpio python3-rpi.gpio

     

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.