Discussion:
sd_event_add_io with EPOLLPRI option
(too old to reply)
Yong Li
2017-08-24 00:21:47 UTC
Permalink
Raw Message
Hi all,

I want to use the sd_event_add_io API to monitor a GPIO pin status
change. This pin supports intrrupts(echo both > edge). And it works
using the epoll code at https://gist.github.com/jadonk/2587524: The
callback function will be called if there is data change on the pin.

However, the sd_event_add_io does not work: the callback will always
be triggered(without pin status change). I am using this example:
http://0pointer.net/blog/introducing-sd-event.html. Just replace the
fd = open("/sys/class/gpio/gpio34/value", O_RDWR | O_NONBLOCK); and
replace EPOLLIN using EPOLLPRI.

Any suggestions/comments?


Thanks,
Yong
Yong Li
2017-08-24 17:24:25 UTC
Permalink
Raw Message
I found the root cause: I did not read the data in my callback function!
Note that an event source set to SD_EVENT_ON will fire continuously
unless data is read from or written to the file descriptor to reset
the mask of events seen.
Post by Yong Li
Hi all,
I want to use the sd_event_add_io API to monitor a GPIO pin status
change. This pin supports intrrupts(echo both > edge). And it works
using the epoll code at https://gist.github.com/jadonk/2587524: The
callback function will be called if there is data change on the pin.
However, the sd_event_add_io does not work: the callback will always
http://0pointer.net/blog/introducing-sd-event.html. Just replace the
fd = open("/sys/class/gpio/gpio34/value", O_RDWR | O_NONBLOCK); and
replace EPOLLIN using EPOLLPRI.
Any suggestions/comments?
Thanks,
Yong
Lennart Poettering
2017-08-29 14:45:58 UTC
Permalink
Raw Message
Post by Yong Li
I found the root cause: I did not read the data in my callback function!
Note that an event source set to SD_EVENT_ON will fire continuously
unless data is read from or written to the file descriptor to reset
the mask of events seen.
BTW, you can use SD_EVENT_ONESHOT for events that shall be fired only
once, and are disabled automatically for the next iteration when its
callback is invoked.

Lennart
--
Lennart Poettering, Red Hat
Loading...