Hi,
I am toying around with my Raspberry Pi B Rev 2, Java ME, Java SE and Device I/O. I've come a long way, but I stumble upon an inexplicable exception in GPIOLEDSample.java.
To build and install Device I/) on my Raspberry Pi, I follo0wed the instructions given at https://wiki.openjdk.java.net/display/dio/Getting+Started
The sample program (located in dio-samples.jar) lets an LED blink for a while by "opening" it via two alternative ways:
a) By using an ad-hoc GPIOPinConfig in the DeviceManager.open() method, and
b) By using a device id in the DeviceManager.open(int id) method.
By figuring out how to supply the java.policy and dio.properties file, I managed to run the program to let the LED blink through method (a).
Unfortunately, the program exits with an AccessControl exception as follows:
Exception in thread "main" java.security.AccessControlException: access denied ("jdk.dio.DeviceMgmtPermission" "*:18" "open")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
at java.security.AccessController.checkPermission(AccessController.java:884)
at jdk.dio.DeviceManager.open(DeviceManager.java:469)
at jdk.dio.DeviceManager.open(DeviceManager.java:410)
at jdk.dio.DeviceManager.open(DeviceManager.java:362)
at GPIOLEDSample.blinkLEDByDeviceId(GPIOLEDSample.java:82)
my java.policy section for the samples file is this:
grant codeBase "file:./dio-samples.jar" {
permission jdk.dio.DeviceMgmtPermission "*:*";
permission jdk.dio.gpio.GPIOPinPermission "*:*";
};
and the dio.properties file is this:
# RPi rev2 P1 header pins
1 = deviceType: gpio.GPIOPin, pinNumber:4, name:GPIO4, predefined:true
2 = deviceType: gpio.GPIOPin, pinNumber:7, name:GPIO7, mode:4, direction:1, predefined:true
3 = deviceType: gpio.GPIOPin, pinNumber:17, name:GPIO17, predefined:true
4 = deviceType: gpio.GPIOPin, pinNumber:18, name:GPIO18, mode:4, direction:1, predefined:true
5 = deviceType: gpio.GPIOPin, pinNumber:22, name:GPIO22, predefined:true
6 = deviceType: gpio.GPIOPin, pinNumber:23, name:GPIO23, mode:4, direction:1, predefined:true
7 = deviceType: gpio.GPIOPin, pinNumber:24, name:GPIO24, mode:4, direction:1, predefined:true
8 = deviceType: gpio.GPIOPin, pinNumber:25, name:GPIO25, mode:4, direction:1, predefined:true
9 = deviceType: gpio.GPIOPin, pinNumber:27, name:GPIO27, predefined:true
300 = deviceType: spibus.SPIDevice, name:SPI0.0, controllerNumber:0, address:0, csActive:1, wordLength:8, clockFrequency:500000, clockMode:1, bitOrdering:1, predefined:true
100 = deviceType: uart.UART, controllerName:ttyAMA0, name:ttyAMA0, baudRate:19200, dataBits:8, parity:0, stopBits:1, flowControl:0, predefined:true
gpio.GPIOPin = initValue:0, controllerNumber:0, direction:0, mode:1, trigger:0, predefined:true
uart.UART = baudRate:19200, parity:0, dataBits:8, stopBits:1, flowControl:0, predefined:true
I have two questions:
(a) Can you explain the access control exception for the DeviceManager.open(int id) method call?
(b) Why does the sample code use "18" as a device id, where the dio.properties file declares the device id for GPIO pin 18 to be "4"? When I run a cross-check programm via Java ME 8.2 with DeviceManager..open(int id), I have to use device id 4 to get the same GPIO pin to glink the LED?
(c) When modifying the sample program to use the device id 4, it seem to make no difference, except for the access control exception to refer to "*:4" instead :-(