title: How do I receive HID reports using libusb-1.0?
body: <p>I have a USB HID scale that I need to fetch the weighing reports from.  I am able to do this on Linux by reading 7 bytes at a time from <code>/dev/hidraw#</code>, but I would like to get the same information using libusb-1.0.</p>
  
  <p>Even when I do get some non-null bytes, I get error -9: <code>LIBUSB_ERROR_PIPE</code></p>
  
  <p>I am attempting to use a control transfer like so:</p>
  
  <pre><code>#define WEIGH_REPORT_SIZE 7
  
      /*
       * Open a handle to the found scale
       */
      libusb_open(dev, &amp;handle);
  #ifdef __linux__
      libusb_detach_kernel_driver(handle, 0);
  #endif
      libusb_claim_interface(handle, 0);
  
      /*
       * Try to transfer data about status
       *
       */
      unsigned char data[WEIGH_REPORT_SIZE];
      unsigned int len = libusb_control_transfer(
          handle,
          LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS |
              LIBUSB_RECIPIENT_INTERFACE,
          HID_REPORT_GET,
          //wValue =&gt; hid report, no report ID
          0x0100,
          0x00,   //windex =&gt; interface 0
          data,
          WEIGH_REPORT_SIZE,    //wLength
          10000 //timeout =&gt; 10 sec
          );
      int i;
      printf("Got %d bytes from control transfer:\n", len);
      for(i = 0; i &lt; WEIGH_REPORT_SIZE; i++) {
          printf("%x\n", data[i]);
      }
  </code></pre>