I started doing C programming with Linux and embedded systems (router hardware and openwrt). I have interupts on GPIO that are enabled, using a survey works ... almost.
I can use poll (), and if I press the button to cause an interrupt, the poll () function will return with a value> 0. So far so good. Now I'm trying to use polling () on several GPIOs at the same time and therefore want to analyze the sources of each potential interrupt source. Even though the interrupt seems to work, I am returning POLLPRI and POLLERR, and I do not understand why. Reducing the pollfd structure to 1 record does not change anything.
char value;
int fd_btn1 = open("/sys/class/gpio/gpio14/value", O_RDONLY);
int fd_left = open("/sys/class/gpio/gpio12/value", O_RDONLY);
int fd_right = open("/sys/class/gpio/gpio13/value", O_RDONLY);
struct pollfd fds[3];
fds[0].fd = fd_btn1;
fds[1].fd = fd_left;
fds[2].fd = fd_right;
fds[0].events = POLLPRI;
fds[1].events = POLLPRI;
fds[2].events = POLLPRI;
read(fd_btn1, &value, 1);
read(fd_left, &value, 1);
read(fd_right, &value, 1);
ret = poll(fds, 1, 10000);
//debugging purpose
printf("ret: %i - revents[0]: %i", ret, fds[0].revents);
If a button is pressed (interrupt triggered): ret = 1d, revents = 10d
, , 0d