Hello,
I have a Java Program that registers a UsbServiceListener to monitor USB devices that are being attached/detached dynamically.
When running this program under a Linux container (e.g. CentOS), the methods usbDeviceAttached/usbDeviceDetached in my listener does not get any event or notified from USB device attach/detach and manually callings into UsbHostManager to get the attached devices and iterating thru them will not give the fresh list of devices either. When running my Java Program in non-container Linux or host environment, I have no issue and I can get events for dynamically attached/detached devices
I made sure 'udevd' is running in my Linux container and I can see both 'KERNEL' and 'UDEV' events in the container when I connect or disconnect a USB device using 'udevadm monitor'.
Just to confirm that us4Java Low-Level API has the same issue, when calling LibUsb.getDeviceList(), it is also not detecting dynamic device attach/detach and never updates its list.
If LibUsb.init() is called after device is connected/disconnected, then the list gets updated and event is fired to my listener but this is not a solution.
I compared the usb tree of connected devices in Linux host environment vs. Linux container. The Linux host environment is simple, i.e. just 1 root hub, but in the case of container, it is a bit complex and has nested level of hub. I have included the dump of lsusb below for my host environment (working one) vs. container (non-working).
Has anyone run into this issue and/or know whether what I am facing is a libusb issue at container level or it is usb4java library issue?
Thanks for any help or clue anyone can provide me to solve this issue.
Regards
Eliza
Linux host (working)
$ lsusb
Bus 001 Device 011: ID 04e6:5116 SCM Microsystems, Inc. SCR331-LC1 / SCR3310 SmartCard Reader
Bus 001 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
$ lsusb -t
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/12p, 12M
|__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M
|__ Port 2: Dev 11, If 0, Class=Chip/SmartCard, Driver=, 12M ß card reader detected when dynamically connected
Linux Container (not working)
# lsusb
Bus 001 Device 002: ID 8087:07e6 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 009: ID 04e6:511d SCM Microsystems, Inc. SCR3311 Smart Card Reader
Bus 001 Device 010: ID 413c:2005 Dell Computer Corp. RT7D50 Keyboard
# lsusb -t
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/8p, 480M
|__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/4p, 480M
|__ Port 2: Dev 3, If 0, Class=hub, Driver=hub/4p, 480M
|__ Port 1: Dev 9, If 0, Class=scard, Driver=, 12M ß card reader not detected when dynamically connected
|__ Port 4: Dev 10, If 0, Class=HID, Driver=usbhid, 1.5M ß keyboard not detected when dynamically connected