itm / wsn-device-drivers

Drivers for Wireless Sensor Network Devices
Other
6 stars 4 forks source link

Exception when detaching device if drivers are connected to it #101

Open danbim opened 12 years ago

danbim commented 12 years ago

If you detach a device from the USB port the driver will throw an exception like this:

2011-12-27 17:13:36,860 | [urn:local:0xb2a6]-Thread 2    | InputStreamCopyRunnable        | ERROR | IOException while reading from device InputStream: java.io.IOException: Device not configured in nativeavailable
java.io.IOException: Device not configured in nativeavailable
    at gnu.io.RXTXPort.nativeavailable(Native Method)
    at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1532)
    at de.uniluebeck.itm.wsn.drivers.core.concurrent.InputStreamCopyRunnable.copyAvailableBytes(InputStreamCopyRunnable.java:81)
    at de.uniluebeck.itm.wsn.drivers.core.concurrent.InputStreamCopyRunnable.run(InputStreamCopyRunnable.java:62)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)

It would be nice if that exception would be handled in some clean way, e.g. by throwing a typed exception or producing some event indicating that the device has been detached.