how to resolve jdk.dio-CloseDeviceException [message #1714353] |
Thu, 12 November 2015 06:52 |
Akash Babu Venkatesh 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)
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03534 seconds