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
you can see source code of lsusb on github: https://github.com/gregkh/usbutils/code:lsusb -d12a4:5678 >/dev/null && echo device found || echo device not found
there's bash script /usr/bin/usb-devices may want have at. recursively iterates on /sys/bus/usb/devices/usb*:
this script supposed drop-in replacement file usb/devices.code:for device in /sys/bus/usb/devices/usb* print_device $device 0 0 0 done
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
Post a Comment