Petomni
Posts: 5
Joined: Thu Nov 08, 2012 8:19 pm

Error #3 waiting for edge

Fri Apr 05, 2013 10:46 pm

Using GPIO.VERSION 0.5.1a I set up some code that listens to output from a PIR sensor that goes low when motion is detected. The code times how long the signal is low and records it.

Code: Select all

while GPIO.input(PIN_BUTTON):
    GPIO.wait_for_edge(PIN_MOTION, GPIO.FALLING)
    #motion detected
    MotionStarted = datetime.now()
    GPIO.wait_for_edge(PIN_MOTION, GPIO.RISING)
    #motion ended
    MotionEnded = datetime.now()
    #write to file
    LogFile.write(str((MotionStarted - BeginMonitoring).total_seconds()))
    LogFile.write('\t')
    LogFile.write(str((MotionEnded - MotionStarted).total_seconds()))
    LogFile.write('\n')
Everything works for quite some time, hours even, but then randomly it will halt with the message "RuntimeError: Error #3 waiting for edge" at line 54 which confuses me as well because that line the comment "#motion detected"

Could anyone tell me what causes Error 3 waiting for edge?

User avatar
croston
Posts: 700
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: Error #3 waiting for edge

Sat Apr 06, 2013 5:34 am

I'll have a look later today. It could well be something internal to the RPi.GPIO library and not your script that is at fault.

Petomni
Posts: 5
Joined: Thu Nov 08, 2012 8:19 pm

Re: Error #3 waiting for edge

Mon Apr 08, 2013 1:01 am

So I found this https://code.google.com/p/raspberry-gpi ... 167c2a#573

and line 573 seems like it's what would be triggering this response.

Code: Select all

   Py_BEGIN_ALLOW_THREADS // disable GIL
   result = blocking_wait_for_edge(gpio, edge);
   Py_END_ALLOW_THREADS   // enable GIL

   if (result == 0) {
      Py_INCREF(Py_None);
      return Py_None;
   } else if (result == 2) {
      PyErr_SetString(AddEventException, "Edge detection events already enabled for this GPIO channel");
      return NULL;
   } else {
      sprintf(error, "Error #%d waiting for edge", result);
      PyErr_SetString(PyExc_RuntimeError, error);
      return NULL;
   }
But I really have no idea if this is relevant or what this means but hopefully someone here does?

Thanks

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Error #3 waiting for edge

Mon Apr 08, 2013 12:27 pm

Petomni wrote:But I really have no idea if this is relevant or what this means but hopefully someone here does?
Someone might. :lol:

Croston, who already replied to you, wrote RPi.GPIO, so it's highly probable he's the best man to help you. :ugeek:
Alex Eames RasPi.TV, RasP.iO

ericvrp
Posts: 3
Joined: Sat Mar 23, 2013 5:01 pm

Re: Error #3 waiting for edge

Wed May 15, 2013 5:34 am

I'm having the same problem.

bahex
Posts: 2
Joined: Mon Jun 17, 2013 6:44 am

Re: Error #3 waiting for edge

Mon Jun 17, 2013 6:47 am

Hi Guys,

I have the same problem using the version 0.5.2a.

Thanks for any help on this...

ahmedhussain85
Posts: 2
Joined: Tue Apr 29, 2014 8:33 am

Re: Error #3 waiting for edge

Tue Apr 29, 2014 1:53 pm

Hi

I have the same problem but after 1000+ interrupts. The code I am using now works perfect until 1000+ interrupts and then crashes badly and gives RunTimeError # 3 waiting for edge...

I am using GPIO.cleanup() and I am also using latest version of RPi.GPIO

Any help would be appreciated.

Thanks a lot!

Ahmed: [email protected]

Helmi Romdhani
Posts: 1
Joined: Fri Dec 26, 2014 12:58 pm

Re: Error #3 waiting for edge

Fri Dec 26, 2014 1:01 pm

Hi guys!
Just add time.sleep(0.01) before the waiting for edge line to avoid blocking the processor.

Return to “Python”