The code I'm trying to run looks something like this:

import RPi.GPIO as GPIO

def cb(r):#r is just accept the argument passed by add_event_detect
    if c!=sensor:
        print "do something if timeout happens before next signal"


When I run this I get RuntimeError: Conflicting edge detection events already. I've found this website https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=88951 which solves the case where two competing wait_for_edge cases are run simultaneously but:

I wasn't sure if this was would work for an event_detect and a wait_for_edge

I also wasn't sure if this would work with my specific hard/software specs. I'm running a Pi zero version 1.3 with what I assume is the latest version of Jesse that I downloaded last week from https://www.raspberrypi.org/downloads/raspbian/.

And furthermore I'm not the best at linux and don't want to damage my new PI.


I ended up side stepping this issue by using a thread and a class. Like so:

import time
import timeit.default_timer as tm
import threading.thread as TH
import RPi.GPIO as GPIO

class wd(object):
    def __init__(self):
    def cb(self):
        ct==tm() #see import
        TH(self.waiter,args=(ct,)).start() #see import
    def waiter(self,ct):
        if self.t==ct:
            print "do something if timeout happens before next signal"

The because this is threaded, the class has a chance to update self.t before it compares ct to self.t

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.