0

I want to get usb device name like Kingston Technology DataTraveler.

Bus 004 Device 014: ID 0951:1666 Kingston Technology DataTraveler 100 G3/G4/SE9 G2

I am using libusb library for this but I was able to obtain idVendor number and idProduct number. How to get Kingston Technology part of the idVendor?

enter image description here

int hotplug_callback(struct libusb_context *ctx, struct libusb_device *dev,
                     libusb_hotplug_event event, void *user_data) {
  static libusb_device_handle *dev_handle = NULL;
  struct libusb_device_descriptor desc;
  (void)libusb_get_device_descriptor(dev, &desc);

    printf("Device Descriptor:\n"
           "  bLength             %5u\n"
           "  bDescriptorType     %5u\n"
           "  bcdUSB              %2x.%02x\n"
           "  bDeviceClass        %5u %s\n"
           "  bDeviceSubClass     %5u %s\n"
           "  bDeviceProtocol     %5u %s\n"
           "  bMaxPacketSize0     %5u\n"
           "  idVendor           0x%04x %s\n"
           "  idProduct          0x%04x %s\n"
           "  bcdDevice           %2x.%02x\n"
           "  iManufacturer       %5u %s\n"
           "  iProduct            %5u %s\n"
           "  iSerial             %5u %s\n"
           "  bNumConfigurations  %5u\n",
           desc.bLength, desc.bDescriptorType,
           desc.bcdUSB >> 8, desc.bcdUSB & 0xff,
           desc.bDeviceClass, cls,
           desc.bDeviceSubClass, subcls,
           desc.bDeviceProtocol, proto,
           desc.bMaxPacketSize0,
           desc.idVendor, vendor, desc.idProduct, product,
           desc.bcdDevice >> 8, desc.bcdDevice & 0xff,
           desc.iManufacturer, mfg,
           desc.iProduct, prod,
           desc.iSerialNumber, serial,
           desc.bNumConfigurations);
folibis
  • 12,048
  • 6
  • 54
  • 97

1 Answers1

0

I solved the problem. I added necessary functions of the lsusb library from github, the problem was solved.

https://github.com/gregkh/usbutils/blob/master/lsusb.c

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 16 '22 at 18:17