4

I am trying to get usb4java package to work. I get the basic connection, but when I try to get the product, Serial Number, or Manufacturer, I get USB error 12 or 8. I think I may have the libraries messed up.

I am using Win 7 Pro 64 bit OS Service Pack 1. Eclipse Version: Luna Service Release 2 (4.4.2) Build id: 20150219-0600.
The following are the libraries I have:

Libraries Referenced:

The Code:

` import java.io.; import java.util.; import javax.usb.*;

public class PrettyUSBDeviceLister 
{
    public static void main(String[] args) throws UnsupportedEncodingException,  UsbException
    {
        UsbServices services = UsbHostManager.getUsbServices();
        UsbHub root = services.getRootUsbHub();
        System.out.println(" USB Root Hub: ");
        listDevices(root);
    } // main

    public static void listDevices(UsbHub hub) 

    {
        String prod = "";
        String sn   = "";
        String man  = "";

        List<UsbDevice> devices = hub.getAttachedUsbDevices();
    Iterator<UsbDevice> iterator = devices.iterator();
        while ( iterator.hasNext())
        {
            UsbDevice device = iterator.next();

        if((device.isUsbHub())) 
            {
            System.out.println("HUB: ");
                listDevices((UsbHub)device);            
            }

            try {
                prod = device.getProductString();
            } catch (UnsupportedEncodingException e) {
                prod = "UEE";
            } catch (UsbException e) {
                String ts = e.getLocalizedMessage();
                System.out.println(" USB e L msg = "+ts);
                prod = "UsbException\n " + e.toString();
            } catch (UsbDisconnectedException e) {
                prod = "USBdis";
            }

            System.out.println("Product : "+prod);

            try {
                sn = device.getSerialNumberString();
            --similar to the above--
            }

            System.out.println("Serial #: "+sn);

            try {
                man = device.getManufacturerString();
            --similar to the above--
            }

            System.out.println("Manufact: "+man);
            System.out.println();
        }
        System.out.println(" ... end Hub ....");
    } // static void listdevices(UsbHub root)
} // class PrettyUSBDeviceLister 

` I have include one of eacn of the errors below. I get error 8, 13, or NULL for all the calls to get the Product, Serial Number, or Manufacturer,

Program output:

USB Root Hub: 

USB e L msg = USB error 12: Can't open device Bus 008 Device 002: ID 1058:1078: Operation not supported or unimplemented on this platform Product : UsbException USB error 12 Serial #: UsbException USB error 12 javax.usb.UsbPlatformException: USB error 12: Can't open device Bus 008 Device 002: ID 1058:1078: Operation not supported or unimplemented on this platform at org.usb4java.javax.ExceptionUtils.createPlatformException(ExceptionUtils.java:39) at org.usb4java.javax.AbstractDevice.open(AbstractDevice.java:226) at org.usb4java.javax.AbstractDevice.getLanguages(AbstractDevice.java:538) at org.usb4java.javax.AbstractDevice.getUsbStringDescriptor(AbstractDevice.java:507) at org.usb4java.javax.AbstractDevice.getString(AbstractDevice.java:526) at org.usb4java.javax.AbstractDevice.getManufacturerString(AbstractDevice.java:304) at PrettyUSBDeviceLister.listDevices(PrettyUSBDeviceLister.java:65) at PrettyUSBDeviceLister.main(PrettyUSBDeviceLister.java:17) Manufact: UsbException USB error 12

USB e L msg = USB error 8: Unable to get string descriptor languages: Overflow Product : UsbException USB error 8: Serial #: null javax.usb.UsbPlatformException: USB error 8: Unable to get string descriptor languages: Overflow at org.usb4java.javax.ExceptionUtils.createPlatformException(ExceptionUtils.java:39) at org.usb4java.javax.AbstractDevice.getLanguages(AbstractDevice.java:544) at org.usb4java.javax.AbstractDevice.getUsbStringDescriptor(AbstractDevice.java:507) at org.usb4java.javax.AbstractDevice.getString(AbstractDevice.java:526) at org.usb4java.javax.AbstractDevice.getManufacturerString(AbstractDevice.java:304) at PrettyUSBDeviceLister.listDevices(PrettyUSBDeviceLister.java:65) at PrettyUSBDeviceLister.main(PrettyUSBDeviceLister.java:17) Manufact: UsbException USB error 8:

How can I avoid this and get the read data?
Thank you for your help Cliff

cliff2310
  • 570
  • 2
  • 15
  • 28
  • I don't know if there is something wrong with the libs but as side note: Hubs are not really the best things to use with libusb because they are highly regulated by the OS. One time one faulty (or not supported?) hub in my system made libusb unusable. I had to remove it to get libusb to work again. – dryman May 04 '16 at 12:22
  • I think my Libs are OK. I found another way of doing this, see http://stackoverflow.com/questions/37674969/i-try-to-read-from-a-usb-device-i-get-usb-error-5-unable-to-read-data-entity-n This should work and I still would like to know what is worng or why it should not work. – cliff2310 Jun 16 '16 at 23:02
  • I have tracked down some information on the -8 error. It seems that LibUSB is not compatible with HID Devices, you need to install a special driver. I have not been able to verify this. – cliff2310 Jun 16 '16 at 23:34
  • Yes on Windows you need to install a backend like libusb-win32, libusbK or WinUSB. I recommend Zadig for installation and driver creation. But I still don't get what you want from the Hub because I recommend you don't install libusb for a Hub if thats even possible. – dryman Jun 17 '16 at 07:11
  • @dryman I downloaded Zadig, but have not used it. At the moment I am just trying to use the USBlister to learn how to talk to the USB devices. – cliff2310 Jun 17 '16 at 22:29
  • If you want to sniff how the original software communicates with the device that is the right approach. Only if you want to start communicating with the device yourself a compatible driver is mandatory on Windows. – dryman Jun 20 '16 at 07:48

0 Answers0