Menu

#142 Event detection callback should get the edge / pin level as parameter

New
nobody
None
Medium
Enhancement
2019-12-11
2016-11-12
Axel Gembe
No

If I just read the value inside my callback, I often do not get the true value of the pin. For example I have a pin set up to trigger on both edges and give me the level, which produces this output:

Set up pin 26
Pin 26 was triggered 0
Pin 26 was triggered 0
Pin 26 was triggered 0
Pin 26 was triggered 0

What I would expect is this:

Set up pin 26
Pin 26 was triggered 0
Pin 26 was triggered 1
Pin 26 was triggered 0
Pin 26 was triggered 1

From what I can see you use poll to wait for the event from the kernel. The kernel writes the logic level that caused the event to the file, so you either read 0 or 1. If this value could be passed on to the callback then we would always know if a rising or a falling edge was the source of the trigger.

Discussion

  • Martin Sohmen

    Martin Sohmen - 2019-12-11

    When using event with edge-mode GPIO.BOTH it is required to get the reason for the event.
    Polling with GPIO.input(channel) inside the callback does unfortunately not work when the switch at the GPIO-Port is bouncing.
    I would be very grateful if you could forward the logic level of the event from kernel to the callbackfunction.

     

    Last edit: Martin Sohmen 2019-12-11

Log in to post a comment.