c++clinuxgpioposix-select

How does C/C++ select work with gpio under Linux?


How does select work with gpio under Linux?

Is it possible to use select to create a kind of interrupt driven program, maybe with the help of some threads?

And what shall I think about when I use the select call?

Thanks


Note: I have read the man page on select, but I think I need some more help on this topic.


Update: The gpio is exposed in the sysfs gpio block. But I don't know if I can use that with select.


Solution

  • Apparently you can use select() on a GPIO exposed through sysfs, but only if it can be configured to generate an interrupt. Your platform may have this or not.

    What you want to read though is Documentation/gpio.txt in your kernel source, which mentions how to enable an interrupt for a pin if the kernel driver allows it.