Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB error -1: My error message : Other Error #74

Open
worapolburaphan opened this issue Aug 27, 2019 · 1 comment
Open

USB error -1: My error message : Other Error #74

worapolburaphan opened this issue Aug 27, 2019 · 1 comment

Comments

@worapolburaphan
Copy link

worapolburaphan commented Aug 27, 2019

Environment:

  • OS: macOS Mojave version 10.14.6

  • openjdk version "12.0.2" 2019-07-16

  • OpenJDK Runtime Environment (build 12.0.2+10)

  • OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
    Macintoshs-MacBook-Air:HegFrontSite macintoshhd$

  • usb4java version 1.3.0

Bug description
Error when i tried to call LibUsb.getDeviceList(null, myList);
I get error from compiler

Caused by: org.usb4java.LibUsbException: USB error -1: Unable to find usb devices: Other error

Reproduction

DeviceList deviceList = new DeviceList();
        int result = LibUsb.getDeviceList(null, deviceList);

        if(result != LibUsb.SUCCESS) throw new LibUsbException("Unable to find usb devices", result);

Expected behavior
It should return me with device list.

@median1st
Copy link

median1st commented Nov 16, 2022

UPDATE:

The bug is not in the library, but in the user program. The method LibUSB.getDeviceList() returns the number of devices copied to the DeviceList, in my case fourteen devices - that's why I got result == 14. Changed the test to (result < 0) and now I'm getting the whole list without problems.
The constructor of LibUSBException changes the errorCode sign, which makes the exception message to appear as USB Error: -14. The negative number led me to a wrong conclusion that there had been an error.

Previous comment:
I can confirm this behavior on Fedora 33 (stock kernel 5.14.18-100.fc33.x86_64), OpenJDK Runtime Environment (build 1.8.0_312-b07), libusb version 1.0.24.11584, usb4java version 1.3.0 from Maven central. Even tried to compile the libusb4java.so from sources (successfully) and replace it within the classpath, but to no success. The error code returned by LibUSB.getDeviceList is -14 and the debugging output is

[ 0.004276] [001d0eff] libusb: debug [libusb_get_device_list]  
[ 0.004286] [001d0eff] libusb: debug [discovered_devs_append] need to increase capacity
Exception in thread "main" org.usb4java.LibUsbException: USB error -14: Other error

I succeeded to get the device list using the same libusb in a simple C program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants