It looks like you're new here. If you want to get involved, click one of these buttons!
Hi, is there a Java API for using RPI3 GPIO ?
https://help.emteria.com/kb/devices-rpi-3
`# GPIO
Accessing GPIO is possible just the same way you would do it in Linux (via sysfs). We are also planning on adding proper Java API for that, but it will take a while.`
Hope we could use such API near in the future. Waiting for it!
How is the GPIO access possible from within an Android (Java) app? How do we need to set permissions to access sysfs?
The Java method
public boolean activationPin(){ String command = String.format("echo %d > /sys/class/gpio/export", this.pin); try { Runtime.getRuntime().exec(new String[] {"su", "-c", command}); return true; } catch (IOException e) { return false; } }
public boolean activationPin(){
String command = String.format("echo %d > /sys/class/gpio/export", this.pin);
try {
Runtime.getRuntime().exec(new String[] {"su", "-c", command});
return true;
} catch (IOException e) {
return false;
}
leads to the exception "java.io.IOException: Cannot run program "su": error=13, Permission denied"
After calling "su" you will see a permission dialog. You need to confirm it once.
Comments
https://help.emteria.com/kb/devices-rpi-3
`# GPIO
Accessing GPIO is possible just the same way you would do it in Linux (via sysfs). We are also planning on adding proper Java API for that, but it will take a while.`
Hope we could use such API near in the future. Waiting for it!
How is the GPIO access possible from within an Android (Java) app? How do we need to set permissions to access sysfs?
The Java method
public boolean activationPin(){
String command = String.format("echo %d > /sys/class/gpio/export", this.pin);
try {
Runtime.getRuntime().exec(new String[] {"su", "-c", command});
return true;
} catch (IOException e) {
return false;
}
}
leads to the exception "java.io.IOException: Cannot run program "su": error=13, Permission denied"
After calling "su" you will see a permission dialog. You need to confirm it once.