I need to list existing USB hub and the devices connected in the hub using my C++ program.
I can able to print the USB Hub and devices connected in hub from terminal using the commands
lsusb lsusb -v
I want to use that feature in my C++ program.
How I can do this programmatically. Is there any C++ classes available to use in my Qt application or in c or java.this is one help taken from https://unix.stackexchange.com/questions/61484/find-the-information-of-usb-devices-in-c
#include <stdio.h>
#include <usb.h>
main(){
struct usb_bus *bus;
struct usb_device *dev;
usb_init();
usb_find_busses();
usb_find_devices();
for (bus = usb_busses; bus; bus = bus->next)
for (dev = bus->devices; dev; dev = dev->next){
printf("Trying device %s/%s\n", bus->dirname, dev->filename);
printf("\tID_VENDOR = 0x%04x\n", dev->descriptor.idVendor);
printf("\tID_PRODUCT = 0x%04x\n", dev->descriptor.idProduct);
}
} does anyone know how to compile this??? i m facing problem