2
votes

How to get a USB device's path like /dev/ttyACM0 or /dev/ttyUSB0 according to its idVedor and idProduct? The subsequent function needs this path instead of its idVendor and idProduct.

Notice: by C/C++ code, not by Command.

I am using Qt and CentOS.

1
Depends on the device. What kind of device is it? Some USB devices won't have a device node, some will have several. - user149341
It is a Arduino device. In my comuter, it shows /dev/ttyACM. - Jeff

1 Answers

1
votes

You can use libusbp, a USB abstraction library, to do that. See the port_name example that comes with libusbp. This will definitely work for USB CDC ACM devices (e.g. /dev/ttyACM0) but I'm not sure if it will work for devices that use a different driver. If you try it, please post a comment here about whether it worked.