Skip to main content

Thread: search /sys/bus/usb/devices


hello, have question searching through /sys/bus/usb/devices :
before prog open devices file in /proc/bus/usb ubuntu upgrade file no longer available.
need acomplish search inside /sys/bus/usb/devices folers/files idvendor , prodid (both have match hex value - ex:vendor =12a4 , prodid=5678 ), if found - happens, not found b happens.
suggested me iterate through subdirectories using opendir, readdir_r , closedir , try read idproduct , idvendor using readsinglelinefile ... not quite sure how proceed. can me issue? lot help.

i guess can accomplish in shell with
code:
lsusb -d12a4:5678 >/dev/null && echo device found || echo device not found
you can see source code of lsusb on github: https://github.com/gregkh/usbutils/

there's bash script /usr/bin/usb-devices may want have at. recursively iterates on /sys/bus/usb/devices/usb*:
code:
for device in /sys/bus/usb/devices/usb*         print_device $device 0 0 0 done
this script supposed drop-in replacement file usb/devices.

alternatively, if can mount debugfs program work practically unchanged evaluating contents of /sys/kernel/debug/usb/devices.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk search /sys/bus/usb/devices


Ubuntu

Comments

Popular posts from this blog

Some mp4 files not displaying correctly (CS6)

Thread: Samba is not authenticating with LDAP