gary-rowe / hid4java

A cross-platform Java Native Access (JNA) wrapper for the libusb/hidapi library. Works out of the box on Windows/Mac/Linux.
MIT License
223 stars 70 forks source link

Unable to open connection to multiple identical devices #136

Closed timautin closed 3 months ago

timautin commented 1 year ago

Hello,

Thank you very much for your library!

I'm trying to use it to communicate with 3 Elgato StreamDeck connected on a PC through a Lindy USB hub.

On my Ubuntu 16.04 LTS development PC, it works flawlessly.

On the Ubuntu 22.04 LTS production PC though, I can only connect 2 StreamDecks. When connecting the 3rd one, hid4java fails to open the connection (HidDevice.open() returns false). The 3 devices are successfully listed in getAttachedHidDevices(), and their serial number are correctly reported. I'm using libusb with HidApi.useLibUsbVariant = true.

Any idea of what could cause this?

EDIT: this is my /etc/udev/rules.d/70-streamdeck.rules files's content (4 lines to support the 4 different StreamDeck models):

SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0060", TAG+="uaccess", MODE="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0063", TAG+="uaccess", MODE="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006c", TAG+="uaccess", MODE="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006d", TAG+="uaccess", MODE="666", GROUP="plugdev"

EDIT 2: I tried using hidraw rather than libusb by removing the HidApi.useLibUsbVariant = true call and updating my udev rules to this according to https://github.com/libusb/hidapi/blob/master/udev/69-hid.rules:

KERNEL=="hidraw*", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0060", TAG+="uaccess", MODE="666", GROUP="plugdev"
KERNEL=="hidraw*", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0063", TAG+="uaccess", MODE="666", GROUP="plugdev"
KERNEL=="hidraw*", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006c", TAG+="uaccess", MODE="666", GROUP="plugdev"
KERNEL=="hidraw*", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006d", TAG+="uaccess", MODE="666", GROUP="plugdev"

With this configuration the 3rd connected StreamDeck is not even listed, and the app crashes sometimes (sigsegv in the C++ code).

EDIT 3: when plugging the 3rd StreamDeck on another USB port on the PC (leaving the two others on the hub), it works. That will do it for now, it would be more practical to have the 3 StreamDecks connected on the hub.

gary-rowe commented 3 months ago

Closing due to inactivity (by me)