# gpioService - changeCallBack gets called while the pin state doesn't change

**URL:** <https://forum.legato.io/t/gpioservice-changecallback-gets-called-while-the-pin-state-doesnt-change/3872>\
**Category:** Legato Application Framework\
**Created:** [November 9, 2018, 4:17pm UTC](https://forum.legato.io/t/gpioservice-changecallback-gets-called-while-the-pin-state-doesnt-change/3872 "2018-11-09T16:17:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![annaertd](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@annaertd](https://forum.legato.io/u/annaertd)\
**Post date:** [November 9, 2018, 4:17pm UTC](https://forum.legato.io/t/gpioservice-changecallback-gets-called-while-the-pin-state-doesnt-change/3872/1 "2018-11-09T16:17:59Z")

</div>

Hi,  
my application runs on a custom board with WP76xx and a Legato system based upon 18.08.  
I’ve built gpioService with debug information.  
My application configures a WP76xx GPIO pin as an input pin, and adds a changeCallBack handler that gets triggered on both edge changes.  
When the input pin signal gets triggered (via a button), my log information shows the consecutive state values.  
Apparently, the function gpioSysfs\_InputMonitorHandlerFunc gets called more than once even with the same pin state value.

I do not understand why the callback handler is triggered different times for the same pin value when it is configured on both edges.

greetings,  
annaertd

[gpiosysfs\_logfile](https://forum.legato.io/uploads/short-url/mdmyX6dgzM2Y2hFopaKwhaf0Ut2) (2.6 KB)

[WP76\_GPIO\_source](https://forum.legato.io/uploads/short-url/soQReZBh9MvoQEIgubDOGeBM5uF) (786 Bytes)

---

<div class="post-metadata">

**Author:** ![riotc](https://avatars.discourse-cdn.com/v4/letter/r/65b543/32.png) [@riotc](https://forum.legato.io/u/riotc)\
**Post date:** [November 14, 2018, 3:15pm UTC](https://forum.legato.io/t/gpioservice-changecallback-gets-called-while-the-pin-state-doesnt-change/3872/2 "2018-11-14T15:15:29Z")

</div>

Hello @annaertd, Can you check if there is a change in gpio value when the callback handler gets triggered by issuing cat /sys/class/gpio/gpioxy/value (replace the xy with the gpioPin#) ?  
You can also refer to the sample code available at [GPIO Sample](https://github.com/nhonchu/Legato-GPIO-sample).

---

<div class="post-metadata">

**Author:** ![annaertd](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@annaertd](https://forum.legato.io/u/annaertd)\
**Post date:** [November 20, 2018, 3:29pm UTC](https://forum.legato.io/t/gpioservice-changecallback-gets-called-while-the-pin-state-doesnt-change/3872/3 "2018-11-20T15:29:05Z")

</div>

Hi,

I’ve used _cat /sys/class/gpio/gpio7/value_ to check the value of pin 7 when I toggle the connected button.  
The value is 0 or 1 depending on the pressed or released status of my button.  
The callback handler gets triggered and shows the same value as the cat command.

But, the question stays:  
when the button is pressed and hold down, the callback handler gets triggered 2, 3, 4 or more times and it returns always the same value.  
The callback handler is configured for both pin edges, so, I would expect that it only gets triggered each time the pin state value is changing.

In case of a debouncing issue, I understand that a callback handler can get triggered several times, but, then the returned value would toggle each time (eg 0 1 0 1 0 1 0 …)

greetings,  
annaertd

---

<div class="post-metadata">

**Author:** ![riotc](https://avatars.discourse-cdn.com/v4/letter/r/65b543/32.png) [@riotc](https://forum.legato.io/u/riotc)\
**Post date:** [November 21, 2018, 2:13pm UTC](https://forum.legato.io/t/gpioservice-changecallback-gets-called-while-the-pin-state-doesnt-change/3872/5 "2018-11-21T14:13:10Z")

</div>

Hello @annaertd, Can you share your observations after executing the application on a mangoH board? I executed the [GPIO Sample app](https://github.com/nhonchu/Legato-GPIO-sample) on mangoH red by configuring the call back handler for both Edges but did not find the issue that you mentioned.
