Menu

#157 Conflicting edge detection

New
None
Medium
Defect
2020-07-29
2018-01-29
No

Hello,

I have a bigger application , where reading the a hall effect sensor is just one part - upon development I'm encountering a Conflicting edge resolution already enabled for this GPIO channel.
My code:

class FlowReader:

    __impulse = 0
    __start_counter = 0

    def __init__(self, port):
        self.__port = port
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(port, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        try:
            GPIO.add_event_detect(port, GPIO.FALLING, callback=self.__count_pulse)
        except Exception as e:
            print "GPIO event detect:", e.message

    def fetch(self):
        self.__impulse = 0
        self.__start_counter = 1
        time.sleep(1)
        flow = (self.__impulse / 7.5)
        self.__start_counter = 0
        return flow

    def __count_pulse(self, channel):
        if self.__start_counter == 1:
            self.__impulse += 1

And from an outer class I call:

class SensorReader:
    def __init__(self):
        self.__flow_reader_22 = FlowReader(22)
        self.__flow_reader_27 = FlowReader(27)

The problem is that I am not able to clean this up. I tried (called manually and also called atexit )
GPIO.cleanup(),
GPIO.clean(port1, port2),
* GPIO.remove_event_detect(port)

In the application there is only one instance of FlowReader thus, the event detect gets added only once. However, if the application is stopped, I cannot re-run the FlowReader correctly, I get no value here. Restarting the RPI0 does not help at all.

I am now in a state where I can't measure any more the pulses, either the event detect, or the pull up is persisted.
I think it is a bug in the cleanup / remove_event_detect methods. Could you please check?

Discussion

  • Misiu

    Misiu - 2019-10-15

    Is there a chance this could be fixed?
    It's fifth day of pulling out my hair becasue I can't get reliable readings in simple door-bell solution.
    This issue is more that 1,5 years old.
    I've searched over Home Assistant (it is using this library) forums for solutions and essentialy every one dump gpio's in favour of ESP8266 and MQTT. Other solution I found involved 555 timer.
    It can't be that complex to detect simple button press.

     
  • Misiu

    Misiu - 2020-07-29

    Any updates?

     

Log in to post a comment.