[libhid-discuss] example program kills hiddev device node

Tino Keitel tino.keitel at tikei.de
Sun Nov 11 21:17:03 UTC 2007


Hi folks,

I tried to use a tool called hidmon to control man TFT over USB. That
worked a few times, but now I noticed that the hiddev device node in
/dev/usb/ went away. I didn't kow why. I rebooted the computer, changed
from Linux 2.6.23.1 to 2.6.22, powercycled the TFT, without luck. As
soon as I use hidmon, the device node is gone.

Now I compiled the libhid test program test_libhid.c and got the same
effect. It seems like hid_force_open() kills the device, as udev
receives a remote udevent. Here is what I did:

$ ls -l /dev/usb
total 0
crw-rw---- 1 root root 180, 96 Nov 11 20:27 hiddev0
crw-rw---- 1 root root 180, 97 Nov 11 21:50 hiddev1
crw-rw---- 1 root lp   180,  0 Nov 11 21:30 lp0

$ sudo ./test_libhid
 NOTICE: hid_init(): libhid 0.2.15+20060325.0.0 is being initialized.
  TRACE: hid_init(): initialising USB subsystem...
  TRACE: hid_init(): scanning for USB busses...
  TRACE: hid_init(): scanning for USB devices...
 NOTICE: hid_init(): successfully initialised HID library.
  TRACE: hid_new_HIDInterface(): creating a new HIDInterface
instance...
  TRACE: hid_force_open(): forcefully opening a device interface
according to matching criteria...
  TRACE: hid_get_usb_handle(): acquiring handle for a USB device...
  TRACE: hid_find_usb_device(): enumerating USB busses...
  TRACE: hid_find_usb_device(): enumerating USB devices on bus 001...
  TRACE: hid_find_usb_device(): inspecting USB device 001/056[0]...
  TRACE: hid_compare_usb_device(): comparing match specifications to
  USB device...
  TRACE: hid_compare_usb_device(): inspecting vendor ID...
  TRACE: hid_compare_usb_device(): match on vendor ID: 0x056d.
  TRACE: hid_compare_usb_device(): inspecting product ID...
  TRACE: hid_compare_usb_device(): match on product ID: 0x0002.
  TRACE: hid_compare_usb_device(): no custom matching function
  supplied.
 NOTICE: hid_find_usb_device(): found a matching USB device 001/056[0].
  TRACE: hid_force_open(): claiming USB device 001/056[0].
  TRACE: hid_os_force_claim(): failed to claim USB device 001/056[0],
  trying 2 more time(s)...
  TRACE: hid_os_force_claim(): detaching kernel driver from USB device
  001/056[0]...
  TRACE: hid_os_force_claim(): trying again to claim USB device
  001/056[0]...
 NOTICE: hid_force_open(): successfully claimed USB device 001/056[0].
  TRACE: hid_init_parser(): initialising the HID parser for USB Device
001/056[0]...
  TRACE: hid_init_parser(): allocating space for HIDData structure...
  TRACE: hid_init_parser(): successfully allocated memory for HIDData
  strcture.
  TRACE: hid_init_parser(): allocating space for HIDParser structure...
  TRACE: hid_init_parser(): successfully allocated memory for HIDParser
  strcture.
 NOTICE: hid_init_parser(): successfully initialised the HID parser for
USB Device 001/056[0].
  TRACE: hid_prepare_hid_descriptor(): initialising the HID descriptor
for USB device 001/056[0]...
  TRACE: hid_prepare_hid_descriptor(): retrieving HID descriptor for
USB device 001/056[0]...
WARNING: hid_prepare_hid_descriptor(): failed to get HID descriptor for
USB device 001/056[0]
  TRACE: hid_close(): closing USB device 001/056[0]...
  TRACE: hid_close(): closing handle of USB device 001/056[0]...
 NOTICE: hid_close(): successfully closed USB device 001/056[0].
  TRACE: hid_reset_parser(): resetting the HID parser for USB device
001/056[0]...
  TRACE: hid_close(): freeing memory allocated for HID parser...
  TRACE: hid_close(): resetting HIDInterface...
hid_force_open failed with return code 13

$ ls -l /dev/usb
total 0
crw-rw---- 1 root root 180, 96 Nov 11 20:27 hiddev0
crw-rw---- 1 root lp   180,  0 Nov 11 21:30 lp0

While i was doing the above, I also had udevmonitor running:

$ sudo udevmonitor --kernel
udevmonitor will print the received events for:
UEVENT the kernel uevent

UEVENT[1194814320.814394] remove
/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.3/1-1.3:1.0/usb/hiddev1
(usb)
UEVENT[1194814320.814458] remove
/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.3/1-1.3:1.0/usb_endpoint/usbdev1.56_ep81
(usb_endpoint)
UEVENT[1194814320.814477] add
/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.3/1-1.3:1.0/usb_endpoint/usbdev1.56_ep81
(usb_endpoint)
UEVENT[1194814320.814494] remove
/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.3/1-1.3:1.0/usb_endpoint/usbdev1.56_ep81
(usb_endpoint)
UEVENT[1194814320.814511] add
/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1.3/1-1.3:1.0/usb_endpoint/usbdev1.56_ep81
(usb_endpoint)

Anyone knows what's going on here, and how to fix it?

Please CC: me on replies to the list, as I'm not subscribed.

Regards,
Tino



More information about the libhid-discuss mailing list