title: How to get device descriptor and configuration descriptor of usb device in Mac?
body: <p>I have minimum exposure to xcode and I/Okit framework. I have seen device descriptor and configuration descriptor of a usb device in USB prober.<img src="https://i.stack.imgur.com/OLYnX.png" alt="enter image description here"></p>
  
  <p>I have written an xcode program using I/O kit framework which gives the usb device name as output, when we give product id and vendor id of that device as input.</p>
  
  <pre><code>/*Take the vendor and product id from console*/
  
  printf("\nEnter the vendor id : ");
  scanf("%lx",&amp;usbVendor);
  
  printf("\nEnter the product id :");
  scanf("%lx",&amp;usbProduct);
  
  
  /* Set up a matching dictionary for the class */
  matchingDict = IOServiceMatching(kIOUSBDeviceClassName);
  if (matchingDict == NULL)
  {
      return -1; // fail
  }
  // Create a CFNumber for the idVendor and set the value in the dictionary
  numberRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &amp;usbVendor);
  CFDictionarySetValue(matchingDict, 
                       CFSTR(kUSBVendorID), 
                       numberRef);
  CFRelease(numberRef);
  
  // Create a CFNumber for the idProduct and set the value in the dictionary
  numberRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &amp;usbProduct);
  CFDictionarySetValue(matchingDict, 
                       CFSTR(kUSBProductID), 
                       numberRef);
  CFRelease(numberRef);
  numberRef = NULL;
  
  /*Get an iterator.*/
  kr = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &amp;iter);
  if (kr != KERN_SUCCESS)
  {
      return -1;// fail
  }
  
  /* iterate */
  while ((device = IOIteratorNext(iter)))
  {
      /*Display the device names */
  
      io_name_t       deviceName;
      kr = IORegistryEntryGetName(device, deviceName);
      if (KERN_SUCCESS != kr) {
          deviceName[0] = '\0';
      }
  
  
      printf("\ndeviceName:%s",deviceName);
  
      /*Free the reference taken before continuing to the next item */
      IOObjectRelease(device);
  }
  
  /*Release the iterator */
  IOObjectRelease(iter);
  return 0;
  </code></pre>
  
  <p>}</p>
  
  <p>I need to modify this, so that on giving vendor and product id of usb device, i will get the device descriptor and configuration descriptor( as shown in USB prober) as output.</p>
  
  <p>Here i just gave an example, code can change but the output must be the descriptor( atleast the device decriptor). </p>
  
  <p>Thanks in advance...</p>