Trying to manage GPIO accessing/dev/mem through JNI on my android app.
I need to be able to manage GPIO to:
- Read values of gpios
- Write values of gpios
- Set direction (read/write) of gpio
- Set edges interruption and get events
- Optional: Set pull up o pull down
- Use any existing lib to access GPIO, like wiringPi, pigpio, raspi-gpio
- Import it to android using JNI
Can't get access to /dev/mem through JNI on my android app.
Especifically, I'm try to: "open("/dev/mem", O_RDWR | O_SYNC)"
but it doesn't work. In one of my tests, I tried to change the access permissions of the file to 777 but nothing changed, always got -1.
Do you have any idea of how I can access it?
I read in this forum, "To open /dev/mem you need both regular access permissions on the device file and the security capability CAP_SYS_RAWIO, or to be root"
In other forum says,
1) Run the program via "sudo" (this will be the most common advice given on this forum)
2) Make the program setuid root - or setgid kmem
3) Make pi be in the kmem group (and reboot to make it take effect)
But I can't run the program as root and setuid is not a valid command on the shell of emteria OS.
Do you know if I can "setuid root" to an App on Emteria?
Does Emteria OS have any libs to be able to manage GPIO?
I found this C pigpio lib that use /dev/gpiomem. This lib has a mininum manage of GPIO.
So through JNI, I could manage my gpio in Java.
Now I'm trying to use interrupts in C to be able to call java callbacks.
I'm using version 1.1.37 on a Pi 3, and raspi-gpio is not installed. Is there a recommended way to install packages on the system?
The recommended way is to install the OS update (and maybe to test it with a different sdcard first).
from this you can give permission access to Gpio pin 2 and 3 and can set and get direction and value.