linux - What would be the C++ equivalent of this bash script to list USB devices? -
below bash script lists serial port along usb device friendly name. i'd exact same thing in c++ , without using dependency libusb.
#!/bin/bash sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); ( syspath="${sysdevpath%/dev}" devname="$(udevadm info -q name -p $syspath)" [[ "$devname" == "bus/"* ]] && continue eval "$(udevadm info -q property --export -p $syspath)" [[ -z "$id_serial" ]] && continue echo "/dev/$devname "$id_serial"" ) done
i have encountered other c/c++ code use various apis none able friendly name , /dev/ttyport above script. example, output of above script is:
/dev/input/event13 razer_razer_mamba_tournament_edition /dev/input/event14 razer_razer_mamba_tournament_edition /dev/input/mouse0 razer_razer_mamba_tournament_edition /dev/input/event4 razer_razer_mamba_tournament_edition /dev/video0 chicony_electronics_co._ltd._integrated_camera_0001 /dev/input/event10 chicony_electronics_co._ltd._integrated_camera_0001 /dev/ttyacm0 3d_robotics_px4_fmu_v2.x_0
Comments
Post a Comment