Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » how to resolve jdk.dio-CloseDeviceException(can some one please help me out with jdk.dio.CloseDeviceException ???)
how to resolve jdk.dio-CloseDeviceException [message #1714353] Thu, 12 November 2015 06:52 Go to next message
Akash Babu Venkatesh is currently offline Akash Babu VenkateshFriend
Messages: 2
Registered: November 2015
Junior Member
this is how my code looks like:
package org.eclipse.kura.examples.gpioCheck;

import java.io.IOException;

import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.DeviceManager;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.gpio.GPIOPin;

public class GpioTry {

Device<?> pin1,pin2,pin3,pin4,pin5,pin6,pin7,pin8,pin9;
GPIOPin led1,led2,led3,led4,led5,led6,led7,led8,led9;
protected void activate(){
try {
pin1 = DeviceManager.open(17);
pin2 = DeviceManager.open(14);
pin3 = DeviceManager.open(15);
pin4 = DeviceManager.open(16);
pin5 = DeviceManager.open(7);
pin6 = DeviceManager.open(0);
pin7 = DeviceManager.open(1);
pin8 = DeviceManager.open(4);
pin9 = DeviceManager.open(21);
} catch (Exception e){
e.printStackTrace();
}
led1 = (GPIOPin)pin1;
led2 = (GPIOPin)pin2;
led3 = (GPIOPin)pin3;
led4 = (GPIOPin)pin4;
led5 = (GPIOPin)pin5;
led6 = (GPIOPin)pin6;
led7 = (GPIOPin)pin7;
led8 = (GPIOPin)pin8;
led9 = (GPIOPin)pin9;
blink();
}

protected void ledOn(){
try {
led1.setValue(true);
led2.setValue(true);
led3.setValue(true);
led4.setValue(true);
led5.setValue(true);
led6.setValue(true);
led7.setValue(true);
led8.setValue(true);
led9.setValue(true);
} catch (UnavailableDeviceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClosedDeviceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

protected void ledOff(){

try {
led1.setValue(false);
led2.setValue(false);
led3.setValue(false);
led4.setValue(false);
led5.setValue(false);
led6.setValue(false);
led7.setValue(false);
led8.setValue(false);
led9.setValue(false);
} catch (UnavailableDeviceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClosedDeviceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

protected void blink(){

for(int i = 0; i < 10; i++){
try {
ledOn();
Thread.sleep(1000);
ledOff();
Thread.sleep(1000);
} catch (Exception e){
e.printStackTrace();
}
}
}

protected void ledClose(){
try {
led1.close();
led2.close();
led3.close();
led4.close();
led5.close();
led6.close();
led7.close();
led8.close();
led9.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

protected void deactivate(){
ledClose();
}

}



and then the error:
jdk.dio.ClosedDeviceException
at com.oracle.dio.impl.AbstractPeripheral.checkOpen(AbstractPeripheral.java:134)
at com.oracle.dio.gpio.impl.GPIOPinImpl.setValue(GPIOPinImpl.java:130)
at org.eclipse.kura.examples.gpioCheck.GpioTry.ledOff(GpioTry.java:68)
at org.eclipse.kura.examples.gpioCheck.GpioTry.blink(GpioTry.java:94)
at org.eclipse.kura.examples.gpioCheck.GpioTry.startConnection(GpioTry.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
Re: how to resolve jdk.dio-CloseDeviceException [message #1714458 is a reply to message #1714353] Thu, 12 November 2015 18:57 Go to previous messageGo to next message
David Woodard is currently offline David WoodardFriend
Messages: 420
Registered: July 2014
Senior Member
Hello,

Did you setup these pins in the jdk.dio.properties file? If so, can you please post the contents of that file? More documentation can be found here: http://eclipse.github.io/kura/doc/kura-dio-apis.html .

Thanks,
--Dave
Re: how to resolve jdk.dio-CloseDeviceException [message #1714484 is a reply to message #1714458] Fri, 13 November 2015 05:37 Go to previous messageGo to next message
Akash Babu Venkatesh is currently offline Akash Babu VenkateshFriend
Messages: 2
Registered: November 2015
Junior Member
hey thanx for ur reply david.

- no i hvnt changed anything in my jdk.dio.properties file..
once i tried it, but i culdnt find the jdk.dio.properties file.
so i wud be glad if u cud help me locate the file.

thank you
Re: how to resolve jdk.dio-CloseDeviceException [message #1715186 is a reply to message #1714484] Fri, 20 November 2015 01:03 Go to previous messageGo to next message
David Woodard is currently offline David WoodardFriend
Messages: 420
Registered: July 2014
Senior Member
The best first step would be to manually get one of your pins working before modifying the jdk.dio.properties file. The documentation describes how to do this, but the relevant code should look something like:

GPIOPinConfig pinConfig = new GPIOPinConfig(
    DeviceConfig.DEFAULT,                       //GPIO Controller number or name
    17,                                                 //GPIO Pin number
    GPIOPinConfig.DIR_INPUT_ONLY,               //Pin direction
    GPIOPinConfig.MODE_INPUT_PULL_DOWN,     //Pin resistor
    GPIOPinConfig.TRIGGER_BOTH_EDGES,       //Triggers
    false                                           //initial value (for outputs)
);


Thanks,
--Dave
Re: how to resolve jdk.dio-CloseDeviceException [message #1782768 is a reply to message #1714353] Thu, 01 March 2018 08:17 Go to previous message
Ahmed Gharssellaoui is currently offline Ahmed GharssellaouiFriend
Messages: 31
Registered: February 2018
Member
Hello Akash,
How did you manage to add the jdk.dio library to your work space ?
I couldn't find it in my dependencies

Thanks
Previous Topic:LED not blinking on Raspberry pi
Next Topic:LED not blinking on RPI3
Goto Forum:
  


Current Time: Thu Sep 20 10:58:00 GMT 2018

Powered by FUDForum. Page generated in 0.01751 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top