1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-20 04:43:21 +00:00

implementation and close #75 - enabling a timeout for the wait_for_edge function

This commit is contained in:
Robert Wolterman
2017-09-03 21:43:59 -05:00
parent a0b2ac12a6
commit e3a077bf82
8 changed files with 26 additions and 11 deletions

View File

@ -1027,7 +1027,7 @@ void event_cleanup(void)
}
// blocking_wait_for_edge assumes the caller has ensured the GPIO is already exported.
int blocking_wait_for_edge(int gpio, unsigned int edge)
int blocking_wait_for_edge(int gpio, unsigned int edge, int timeout)
// standalone from all the event functions above
{
int fd = fd_lookup(gpio);
@ -1082,7 +1082,7 @@ int blocking_wait_for_edge(int gpio, unsigned int edge)
// epoll for event
for (i = 0; i<2; i++) // first time triggers with current state, so ignore
{
if ((n = epoll_wait(epfd, &events, 1, -1)) == -1)
if ((n = epoll_wait(epfd, &events, 1, timeout)) == -1)
{
gpio_event_remove(gpio);
return 5;