For a small project i am using libudev to get notification for USB devices plug-in/plug-out. Is there any way of knowing which USB port was used to plug in the device via libudev. Actually there are multiple ports available and it is necessary to know which one was used. Any hints would be highly appreciated!
2 Answers
2
votes
Using the lsusb
command and doing a grep
to find the line with the name of the device. This command will output all sorts of useful information about all connected USB devices. You can also use lsusb -v
to get very detailed info.
Check out the manpage for lsusb http://manpages.ubuntu.com/manpages/hardy/man8/lsusb.8.html
1
votes
After a bit of a research i found that it is possible using libusb.
From here, libusb can be used to get a list of all devices plugged in , now the devices discovered using libudev can be checked in the list of devices available via libusb_get_device_list
.
Further libusb_get_port_number
could be used to get the port number for the same device.