I used the following code to get the manufacturerCode of the usb device attached to the system. I added the jsr80-1.0.1 jar. And I got the following error javax.usb.UsbException:
Properties file javax.usb.properties not found.
Any suggestions?
import java.io.UnsupportedEncodingException;
import java.util.*;
import javax.usb.*;
public class USBListener {
public static void main(String[] args) {
try{
UsbServices services = UsbHostManager.getUsbServices();
UsbHub root = services.getRootUsbHub();
listDevices(root);
} catch (Exception e) {
System.out.println(e);
}
}
public static void listDevices(UsbHub hub) throws UnsupportedEncodingException, UsbException {
List devices = hub.getAttachedUsbDevices();
Iterator iterator = devices.iterator();
while(iterator.hasNext()) {
UsbDevice device = (UsbDevice)iterator.next();
describe(device);
if(device.isUsbHub()) {
System.out.println("is hub");
}
}
}
public static void describe(UsbDevice device)
throws UnsupportedEncodingException, UsbException {
UsbDeviceDescriptor descriptor = device.getUsbDeviceDescriptor();
byte manufacturerCode = descriptor.iManufacturer();
System.out.println("Manufacturer index: " + manufacturerCode);
System.out.println("Manufacturer String: " + device.getString(manufacturerCode));
System.out.println("USB version: " + decodeBCD(descriptor.bcdUSB()));
System.out.println("Maximum control packet size: " + descriptor.bMaxPacketSize0());
}
public static String decodeBCD(short bcd) {
int upper = (0xFF00 & bcd) >> 8;
int middle = (0xF0 & bcd) >> 4;
int lower = 0x0F & bcd;
return upper + "." + middle + "." + lower;
}
}