2

So I'm accessing a GPIO Chip in Linux using /dev/gpiochipX and ioctls on Linux 4.14. I'd like to get an event from a pin and then very quickly afterwards read the pin value as well.

Right now, I can get the event by registering a line request for events, and catching the event by polling for it, with poll(2), through something like this:

returnValue = ioctl(fileDescriptor, GPIO_GET_LINEEVENT_IOCTL, &requestEvent);

I'd like to have a line request for values for the same pin ready in the background, so that I can check the pin state as quickly as possible after getting the event.

However, when I try to register the line request for values for the same pin with something like this:

returnValue = ioctl(fileDescriptor, GPIO_GET_LINEHANDLE_IOCTL, &requestValue);

the Linux returns Device or resource busy error.

As far as I can see, I have to release the GPIO Line request for event, register the new line request for value, and then check the value.

So am I missing something, or is it really impossible to have a line request for events and for value active at the same time?

AndrejaKo
  • 1,721
  • 5
  • 25
  • 41

0 Answers0