0

I'm trying to update a program from USB 0.1.4 to LIBUSB, So far everything seems to be working except:

  //endp = 0x01 or 0x81 both return the same error
  //static unsigned char samples[8*400];
  //size=(samplelength*numberofDevices)<<1;
  return(usb_bulk_read(devh,endp,samples,size,timeout));

Currently I've tried

    int nread;
    struct libusb_transfer *xfr;
    xfr = libusb_alloc_transfer(0);

    libusb_fill_bulk_transfer(xfr, devh, endp, samples,size, callbackUSB, &nread, timeout);

    if(libusb_submit_transfer(xfr) < 0){
      libusb_free_transfer(xfr);
    }

    return sizeof(samples)*8;

And

    int nread;
    int r = 0;
    r = libusb_bulk_transfer(devh, endp, samples,size, &nread, timeout);
    if(r <0){
      printf("libusb_bulk_transfer\n");
      printf("%s\n", libusb_error_name(r));
      exit(1);
    }

    return sizeof(samples)*8;

I'm getting this error before program crashes:

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

Device in question:

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

Awaiting legal department to change the VID/PID, but it has been working for the last 22 years as ffff:ffff

Same error on RHEL 7.3, 7.6, Ubuntu 18.

Any Suggestions on how to account for an easy peasy URB error?

0andriy
  • 4,183
  • 1
  • 24
  • 37

1 Answers1

1

bMaxPacketSize0 64 I Believe was the issue. It seems I was trying to Jam 1024x4 into the transfer. Once I adjusted that and used endpoint 0x81 It seems to work fine.

On to the next bug...