title: LIBUSB Bulk Transfer, First URB failed, easy peasy
body: <p>I'm trying to update a program from USB 0.1.4 to LIBUSB, So far everything seems to be working except:</p>
  
  <pre><code>  //endp = 0x01 or 0x81 both return the same error
    //static unsigned char samples[8*400];
    //size=(samplelength*numberofDevices)&lt;&lt;1;
    return(usb_bulk_read(devh,endp,samples,size,timeout));
  </code></pre>
  
  <p>Currently I've tried</p>
  
  <pre><code>    int nread;
      struct libusb_transfer *xfr;
      xfr = libusb_alloc_transfer(0);
  
      libusb_fill_bulk_transfer(xfr, devh, endp, samples,size, callbackUSB, &amp;nread, timeout);
  
      if(libusb_submit_transfer(xfr) &lt; 0){
        libusb_free_transfer(xfr);
      }
  
      return sizeof(samples)*8;
  </code></pre>
  
  <p>And</p>
  
  <pre><code>    int nread;
      int r = 0;
      r = libusb_bulk_transfer(devh, endp, samples,size, &amp;nread, timeout);
      if(r &lt;0){
        printf("libusb_bulk_transfer\n");
        printf("%s\n", libusb_error_name(r));
        exit(1);
      }
  
      return sizeof(samples)*8;
  </code></pre>
  
  <p>I'm getting this error before program crashes:</p>
  
  <pre><code>libusb: debug [libusb_submit_transfer] transfer 0x12fba50
  libusb: debug [add_to_flying_list] arm timerfd for timeout in 100ms (first in line)
  libusb: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 1568
  libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=2
  libusb: debug [submit_bulk_transfer] first URB failed, easy peasy
  libusb: debug [disarm_timerfd]
  libusb: debug [libusb_free_transfer] transfer 0x12fba50
  
  </code></pre>
  
  <p>Device in question:</p>
  
  <pre><code>Bus 001 Device 012: ID ffff:ffff
  Device Descriptor:
    bLength                18
    bDescriptorType         1
    bcdUSB               1.10
    bDeviceClass          255 Vendor Specific Class
    bDeviceSubClass       255 Vendor Specific Subclass
    bDeviceProtocol       255 Vendor Specific Protocol
    bMaxPacketSize0        64
    idVendor           0xffff
    idProduct          0xffff
    bcdDevice            1.00
    iManufacturer           0
    iProduct                0
    iSerial                 0
    bNumConfigurations      1
    Configuration Descriptor:
      bLength                 9
      bDescriptorType         2
      wTotalLength           25
      bNumInterfaces          1
      bConfigurationValue     1
      iConfiguration          0
      bmAttributes         0xc0
        Self Powered
      MaxPower              100mA
      Interface Descriptor:
        bLength                 9
        bDescriptorType         4
        bInterfaceNumber        0
        bAlternateSetting       0
        bNumEndpoints           1
        bInterfaceClass       255 Vendor Specific Class
        bInterfaceSubClass    255 Vendor Specific Subclass
        bInterfaceProtocol    255 Vendor Specific Protocol
        iInterface              0
        Endpoint Descriptor:
          bLength                 7
          bDescriptorType         5
          bEndpointAddress     0x81  EP 1 IN
          bmAttributes            2
            Transfer Type            Bulk
            Synch Type               None
            Usage Type               Data
          wMaxPacketSize     0x0040  1x 64 bytes
          bInterval               1
  Device Status:     0x0001
    Self Powered
  </code></pre>
  
  <p>Awaiting legal department to change the VID/PID, but it has been working for the last 22 years as ffff:ffff</p>
  
  <p>Same error on RHEL 7.3, 7.6, Ubuntu 18.</p>
  
  <p>Any Suggestions on how to account for an easy peasy URB error?</p>