linux / libusb get usb device path

流过昼夜 提交于 2019-12-05 04:00:55

Since libusb 1.0.12, they have introduced libusb_get_port_path(), and in 1.0.16 replaced it with libusb_get_port_numbers() which allows you to query the bus topology.

premal

Overall summery of the sysfs structure path:

1-1.3:1.0

|_usb root hub - bus number - 1
  |_ port number - 1 of root hub
    |_port number - 3 of intermediate hub
      |_current configuration number - 1
        |_ current interface number - 0

More information here

It's possible, like here.

Just scan all USB devices at all busses. When you find needed VID/PID — that's your device.

Or you can do simpler: write an udev-rule which would create symlink like /dev/thermoX when you attach you device. All you need after is to open needed /dev/thermoX.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!