Skip to Main Content

Embedded Technologies

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java SE and OpenJDK Device I/O GPIOLEDSample problem

user11260292Dec 25 2015 — edited Jan 7 2016

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 :-(

Comments

John Edward Scott
Answer
Hello Pau,

Take a look at my blog post on backing up Apex applications, available here -

http://jes.blogs.shellprompt.net/2006/12/12/backing-up-your-applications/

I show how you can use the command-line APEXExport tool to export your applications, which can be easily scripted and extended to automatically check-in the Subversion etc.

Also, Dimitri wrote a post on SQLDeveloper and Subversion integration here -

http://dgielis.blogspot.com/2008/05/using-subversion-in-sql-developer-easy.html

I actually use the automated export a lot, since it's nice to know that you always have copies of your apps incase the 'worst' should happen.

Hope this helps,

John.
--------------------------------------------
http://jes.blogs.shellprompt.net
http://www.apex-evangelists.com
Marked as Answer by 616733 · Sep 27 2020
616733
Thanks John.

BTW you have given me answer for another question we had about the automatic deployment ;-)

So, thanks again.
John Edward Scott
Hi Pau,

No problem, glad to help.

Does that mean I get double-points for answering the other question too? ;)

John.
--------------------------------------------
http://jes.blogs.shellprompt.net
http://www.apex-evangelists.com
1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Feb 4 2016
Added on Dec 25 2015
2 comments
2,469 views