I am working with the DragonBoard 410C using the Android 5.1 build 99 from the 96Boards website that I installed. I’m writing an example application in Kotlin with a simple UI to turn LEDs on and off as well as to blink them.
I am using the sysfs interface reading and writing to the GPIO pin pseudo files in /sys/class/gpio.
Now I want to detect the pressing of a momentary contact switch on the breadboard and when the switch press event is detected to then do something like update the displayed information on the screen or blink an LED.
I have posted a question in StackOverFlow that provides the details as to what I am doing.
android - how to use poll(2) or select(2) service call to watch a pseudo file for changes with Kotlin - Stack Overflow
And this is an article I am updating to document what I’m doing.
Using Windows 10 for Development with DragonBoard 410C and Android - CodeProject
The basics are to set up the proper environment:
- set the event criteria in /edge pseudo file of the GPIO pin, as in “rising” for a rising edge as event trigger
- start a poll(2) on the /value pseudo file of the GPIO pin
When I press the switch, the kernel should detect the rising voltage on the pin and then update the /value pseudo file which causes the poll(2) to return indicating that a POLLIN event for the file descriptor has been received.
However in my testing, that does not seem to be what is happening. Instead the poll(2) call immediately returns back with both POLLIN and POLLERR set as events.
The poll(2) functionality is in a Native C++ function using JNI which is then loaded into Kotlin for use.
My question is does the sysfs interface in the Android 5.1 build 99 supports using poll(2) with a /sys/class/gpio pseudo file?