|
From: Alan S. <st...@ro...> - 2011-06-30 17:00:42
|
On Thu, 30 Jun 2011, Michael Bauer wrote: > Hi there, > > i think i am missing somethin obvious here, but i've looked into this topic for several days now without a solution. I hope you can give me some hint :-) > > I want to make a tool which can be invoked by an udev rule to configure certain USB devices after they are plugged in. Problem is that i need to find the link between the information available through udev and the information availble from libusb to access the device through libusb. > > This is what i get from udev: > E:DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3:1.0/input/input7/event7 This devpath is the pointer to the input device, not the USB device. The path you want is just: /devices/pci0000:00/0000:00:02.1/usb1/1-1/1-1.4/1-1.4.3/ > E: MAJOR=13 > E: MINOR=71 > E: DEVNAME=/dev/input/event7 > E: SUBSYSTEM=input > E: ID_INPUT=1 > E: ID_INPUT_JOYSTICK=1 > E: ID_VENDOR=Logitech > E: ID_VENDOR_ENC=Logitech > E: ID_VENDOR_ID=046d > E: ID_MODEL=Logitech_Driving_Force > E: ID_MODEL_ENC=Logitech\x20Driving\x20Force > E: ID_MODEL_ID=c294 > E: ID_REVISION=1106 > E: ID_SERIAL=Logitech_Logitech_Driving_Force > E: ID_TYPE=hid > E: ID_BUS=usb > E: ID_USB_INTERFACES=:030000: > E: ID_USB_INTERFACE_NUM=00 > E: ID_USB_DRIVER=usbhid > E: ID_PATH=pci-0000:00:02.1-usb-0:1.4.3:1.0 > E: DEVLINKS=/dev/input/by-id/usb-Logitech_Logitech_Driving_Force-event-joystick /dev/input/by-path/pci-0000:00:02.1-usb-0:1.4.3:1.0-event-joystick /dev/input/DF > > I want to also support multiple connected devices, so ideally i would do the following: > 1. Pass the DEVPATH of the connected device into my tool > 2. use libUSB to get access to the device based on the DEVPATH or DEVNAME (maybe double-check that the correct device is found by comparing VENDOR_ID and MODEL_ID) > 3. do some stuff with device > > Problem is: The DEVPATH/DEVNAME seems unavailable in libusb interface, so i did not find any way to make sure that i open the correct device. I only found "libusb_get_bus_number" and "libusb_get_device_address", but the information i get here is not matching anything i would get from udev... > > So i am pretty much stuck - Do you have any suggestion how i could do this? If you look in the /sys/devices/pci0000:00/0000:00:02.1/usb1/1-1/1-1.4/1-1.4.3/ directory, you'll find files named "busnum" and "devnum". They contain the bus number and device address values you can pass to libusb. Alan Stern |