#2 add helper in Device class to retrieve string descriptors

open
nobody
5
2012-12-06
2009-05-20
No

I need to get string descriptors from the device. To be precise i need to have the serial number of the device (when supported by the device itself) so i can specifically address that device even if it changes bus or filename.

Now i can do something like this:
long handle = LibusbJava.usb_open(dev);
if(dev.getDescriptor().getIManufacturer() > 0) {
String manufacturer = LibusbJava.usb_get_string_simple(handle, dev.getDescriptor().getIManufacturer());
if(manufacturer == null) {
manufacturer = "unable to fetch manufacturer string";
}
}
LibusbJava.usb_close(handle);

But working this way renders using the Device class a bit dangerous because there's the risk to open the device twice and so on.
If i have to work this way i will rather rewrite a MyDevice class that handle all things like i want.

Solution proposals:

solution 1)
add a getUsbDevHandle method to class Device so we can directly call LibusbJava methods.
This will also give the ability to access all the low level api.

solution 2)
add an high level api to call LibusbJava.usb_get_string_simple.
This will solve this problem specifically.

Personally i vote for solution 1 because it gives the necessary power to those who need to do nasty things on the device without the need to modify the high level api each time.

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks