I have a simple ledTest.java program that reproduces the problem:
public static void main(String[] args) {
BlinkStick[] bsDevices = BlinkStick.findAll();
for (BlinkStick bs:bsDevices) {
System.out.println("\n"+bs.getProduct()+" - "+bs.getManufacturer());
System.out.println("Serial:"+bs.getSerial());
System.out.println("Mode:"+bs.getMode());
System.out.println("info-block-1:"+bs.getInfoBlock1());
}
}
BlinkStick.java:
public static BlinkStick[] findAll() {
List blinkstickList = new ArrayList();
HIDDeviceInfo[] infos = findAllDescriptors();
for (HIDDeviceInfo info : infos) {
BlinkStick blinkstick = new BlinkStick();
try {
blinkstick.setDevice(info.open());
blinkstickList.add(blinkstick);
} catch (Exception e) {
}
}
return blinkstickList.toArray(new BlinkStick[blinkstickList.size()]);
}
Test steps:
-
Run ledTest and output shows:
BlinkStick - Agile Innovative Ltd
Serial:BS042431-2.3
Mode:2
info-block-1: -
Reboot PC
-
Run ledTest and output shows:
Serial:
Mode:-1
info-block-1:
Note: The info.open() returned null - why?
-
One of the following actions take place
a. Unplug and replug blinkstick device
b. Plug in USB drive
c. Eject USB drive -
Run ledTest and output shows:
BlinkStick - Agile Innovative Ltd
Serial:BS042431-2.3
Mode:2
info-block-1:
How can I resolve this after a reboot when info.open() is returning null?
Don’t want to rely on a physical plug/unplug action.
Also, info is a HIDDevice object and has a getRelease_number() method.
What is this release number? Is it reliable to use this to distinguish
between two different led devices?