Skip to content
Advertisement

How to get port information for usb ports using libudev?

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!

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement