Johan
Johan

Reputation: 20763

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.

Upvotes: 3

Views: 2465

Answers (2)

Torp
Torp

Reputation: 7924

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.

Upvotes: 4

vpit3833
vpit3833

Reputation: 7951

It should be possible to write multi-threaded program that looks for interrupts and does something when they occur. This blog highlights what can be done when you are hitting the limitations of select. I have not worked with GPIOs but from what I read up, GPIO should not be very different from the telephony/network card discussed in the blog mentioned above.

Upvotes: 1

Related Questions