問題タブ [lsusb]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c - Check USB device ID and connected port from C application
I need to be able to identify a plugged USB device (USB3 and/or USB2) and which port is connected to in the hub from a C program. I'm working on a embedded Linux system Yocto based.
I'm able to get this info from the command line with lsusb. E.g. I've got connected two USB cameras, one USB3 and the other USB2 and if I run lsusb -t
I can see the port connections tree:
With this I know easily that the USB3 camera is connected to Port 4 and the USB2 one to Port 3 (using a 4 ports HUB). If I run only lsusb
got the IDs and names:
How could I easily scan the hub ports and see what device (name or ID) is connected where (hub port number) from a C application?
Apologise if this already answer somewhere but I couldn't find a specific answer.
Thanks in advance.