Find the Information of USB Devices In C/C++/Java -
I need to use the existing USB Hub and Connected Devices to our C ++ program.
I can print devices connected to the terminal from the USB hub and the terminal using the command
lsusb lsusb -v
I want to use that feature in my C ++ program
How can I do this program? Are there any C ++ classes available for use in my CT application or C or Java? This is a help
#include & lt; Stdio.h & gt; # Include & lt; Usb.h & gt; Main () {struct usb_bus * bus; Struct usb_device * dev; Usb_init (); usb_find_busses (); usb_find_devices (); (Dev = bus-> devices; dev; dev = dev- & gt; next) {printf (trying to "device% s /% s \ n") (just = usb_busses; bus; bus = bus - & gt; Next), Bus-> Dynamite, Dev- & gt; Filename); Printf ("\ tID_VENDOR = 0x% 04x \ n", dev-> Descriptor.Idvendor); Printf ("\ tID_PRODUCT = 0x% 04x \ n", dev-> Descriptor.Idproduct); }
} Does anyone know how this compilation ??? The problem is facing
You must install libusb-dev and libusb
sudo apt-get update sudo apt-get install libusb sudo apt-get install libusb-dev
Then compile your code with -lusb
GCC Usbtest.c -o usbtest -lusb
Comments
Post a Comment