чтение 9DoF с помощью libusb на Debian - PullRequest
0 голосов
/ 19 декабря 2018

Использование libusb с этим кодом c ++ уже работает для меня с другими USB-устройствами, но я не могу прочитать его из IMU SparkFun 9DoF Rozor.ИДУ как отправлено;никаких изменений не сделано.Я даже могу прочитать данные с устройства с помощью «кота».Запуск моего кода заканчивается ошибкой libusb.И мне кажется, что он читает один набор данных нормально, но никогда не обновляет данные [64], как вы видите это в отладке (GTUsbDataIn :: readUsbdata).

libusb: error [submit_bulk_transfer]ошибка submiturb -1 ошибка errno = 2

Я застрял здесь.Кто-нибудь может помочь?

Вот подробности:

uname -a: Linux pcname 4.14.0-3-amd64 # 1 SMP Debian 4.14.17-1 (2018-02-14)x86_64 GNU / Linux

cpuinfo: 8x процессор Intel® Core ™ TM i7-4770R @ 3,20 ГГц

политика apt-cach: libusb-1.0-0: Installiert: 2: 1,0.22-2 Установки kandidat: 2: 1.0.22-2 libusb-1.0-0-dev: Installiert: 2: 1.0.22-2 Установкиkandidat: 2: 1.0.22-2

код: (..только важные фрагменты ...)

//setting loglevel
libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, 4);

//opening the device
dev_handle = libusb_open_device_with_vid_pid(ctx, vendorID, pID); //vendorID=1b4f(->6991), pID9d0f(->40207)

//claiming interface
if(libusb_kernel_driver_active(dev_handle, 1) == 1)
if(libusb_detach_kernel_driver(dev_handle, 1) == 0)

//reading

while(1){
    unsigned char data[64];
    int r = libusb_bulk_transfer(dev_handle, (2 | LIBUSB_ENDPOINT_IN), data, 64, &actual_length, 0);
}

и debuginfo:

[timestamp] [threadID] facility level [function call] <message><br>
--------------------------------------------------------------------------------<br>
[ 0.004496] [000048c8] libusb: debug [libusb_get_device_list]<br>
[ 0.004513] [000048c8] libusb: debug [discovered_devs_append] need to increase capacity<br>
[ 0.004519] [000048c8] libusb: debug [libusb_get_device_list]<br>
[ 0.004522] [000048c8] libusb: debug [discovered_devs_append] need to increase capacity<br>
[ 0.004526] [000048c8] libusb: debug [libusb_get_device_descriptor]<br>
[ 0.004528] [000048c8] libusb: debug [libusb_get_device_descriptor]<br>
[ 0.004530] [000048c8] libusb: debug [libusb_get_device_descriptor]<br>
[ 0.004532] [000048c8] libusb: debug [libusb_get_device_descriptor]<br>
[ 0.004533] [000048c8] libusb: debug [libusb_get_device_descriptor]<br>
[ 0.004535] [000048c8] libusb: debug [libusb_get_device_descriptor]<br>
[ 0.004537] [000048c8] libusb: debug [libusb_get_device_descriptor]<br>
[ 0.004539] [000048c8] libusb: debug [libusb_open] open 3.96<br>
[ 0.004557] [000048c8] libusb: debug [usbi_add_pollfd] add fd 17 events 4<br>
[ 0.004562] [000048c8] libusb: debug [libusb_kernel_driver_active] interface 1<br>
[ 0.004567] [000048c8] libusb: debug [libusb_claim_interface] interface 1<br>
"2018-12-19 07:48:44,433" GTUsbDataIn::startUsbDataIn: Claimed Interface<br>
[ 0.004642] [000048c8] libusb: debug [libusb_alloc_transfer] transfer 0x7f5f3001f2b0<br>
[ 0.004646] [000048c8] libusb: debug [libusb_submit_transfer] transfer 0x7f5f3001f2b0<br>
[ 0.004648] [000048c8] libusb: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 64<br>
[ 0.004653] [000048c8] libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=2<br>
[ 0.004655] [000048c8] libusb: debug [submit_bulk_transfer] first URB failed, easy peasy<br>
[ 0.004657] [000048c8] libusb: debug [libusb_free_transfer] transfer 0x7f5f3001f2b0<br>
"2018-12-19 07:48:44,433" GTUsbDataIn::readUsbdata: 8 0 0 0 0 0 0 0 0 250 66 151 19 186 226 190<br>
"2018-12-19 07:48:44,433" GTUsbDataIn::readUsbdata: 0 0 0 0 0 0 0 0 192 104 1 48 95 127 0 0<br>
"2018-12-19 07:48:44,433" GTUsbDataIn::readUsbdata: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<br>
"2018-12-19 07:48:44,433" GTUsbDataIn::readUsbdata: 10 152 56 154 159 85 0 0 5 0 0 0 0 0 0 0<br>
[ 0.004723] [000048c8] libusb: debug [libusb_alloc_transfer] transfer 0x7f5f30020f80<br>
[ 0.004726] [000048c8] libusb: debug [libusb_submit_transfer] transfer 0x7f5f30020f80<br>
[ 0.004728] [000048c8] libusb: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 64<br>
[ 0.004731] [000048c8] libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=2<br>
[ 0.004733] [000048c8] libusb: debug [submit_bulk_transfer] first URB failed, easy peasy<br>
[ 0.004735] [000048c8] libusb: debug [libusb_free_transfer] transfer 0x7f5f30020f80<br>
"2018-12-19 07:48:44,433" GTUsbDataIn::readUsbdata: 8 0 0 0 0 0 0 0 0 250 66 151 19 186 226 190<br>
"2018-12-19 07:48:44,433" GTUsbDataIn::readUsbdata: 0 0 0 0 0 0 0 0 192 104 1 48 95 127 0 0<br>
"2018-12-19 07:48:44,433" GTUsbDataIn::readUsbdata: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<br>
"2018-12-19 07:48:44,433" GTUsbDataIn::readUsbdata: 10 152 56 154 159 85 0 0 5 0 0 0 0 0 0 0<br>

Bus 003 Device 096: ID 1b4f:9d0f<br>
Device Descriptor:<br>
  bLength                18<br>
  bDescriptorType         1<br>
  bcdUSB               2.00<br>
  bDeviceClass          239 Miscellaneous Device<br>
  bDeviceSubClass         2 ?<br>
  bDeviceProtocol         1 Interface Association<br>
  bMaxPacketSize0        64<br>
  idVendor           0x1b4f <br>
  idProduct          0x9d0f <br>
  bcdDevice            1.00<br>
  iManufacturer           1 SparkFun<br>
  iProduct                2 SFE 9DOF-D21<br>
  iSerial                 3 <br>
  bNumConfigurations      1<br>
  Configuration Descriptor:<br>
    bLength                 9<br>
    bDescriptorType         2<br>
    wTotalLength           75<br>
    bNumInterfaces          2<br>
    bConfigurationValue     1<br>
    iConfiguration          0 <br>
    bmAttributes         0x80<br>
      (Bus Powered)<br>
    MaxPower              500mA<br>
    Interface Association:<br>
      bLength                 8<br>
      bDescriptorType        11<br>
      bFirstInterface         0<br>
      bInterfaceCount         2<br>
      bFunctionClass          2 Communications<br>
      bFunctionSubClass       2 Abstract (modem)<br>
      bFunctionProtocol       0 None<br>
      iFunction               0 <br>
    Interface Descriptor:<br>
      bLength                 9<br>
      bDescriptorType         4<br>
      bInterfaceNumber        0<br>
      bAlternateSetting       0<br>
      bNumEndpoints           1<br>
      bInterfaceClass         2 Communications<br>
      bInterfaceSubClass      2 Abstract (modem)<br>
      bInterfaceProtocol      0 None<br>
      iInterface              0 <br>
      CDC Header:<br>
        bcdCDC               1.10<br>
      CDC ACM:<br>
        bmCapabilities       0x06<br>
          sends break<br>
          line coding and serial state<br>
      CDC Union:<br>
        bMasterInterface        0<br>
        bSlaveInterface         1 <br>
      CDC Call Management:<br>
        bmCapabilities       0x01<br>
          call management<br>
        bDataInterface          1<br>
      Endpoint Descriptor:<br>
        bLength                 7<br>
        bDescriptorType         5<br>
        bEndpointAddress     0x81  EP 1 IN<br>
        bmAttributes            3<br>
          Transfer Type            Interrupt<br>
          Synch Type               None<br>
          Usage Type               Data<br>
        wMaxPacketSize     0x0010  1x 16 bytes<br>
        bInterval              16<br>
    Interface Descriptor:<br>
      bLength                 9<br>
      bDescriptorType         4<br>
      bInterfaceNumber        1<br>
      bAlternateSetting       0<br>
      bNumEndpoints           2<br>
      bInterfaceClass        10 CDC Data<br>
      bInterfaceSubClass      0 Unused<br>
      bInterfaceProtocol      0 <br>
      iInterface              0 <br>
      Endpoint Descriptor:<br>
        bLength                 7<br>
        bDescriptorType         5<br>
        bEndpointAddress     0x02  EP 2 OUT<br>
        bmAttributes            2<br>
          Transfer Type            Bulk<br>
          Synch Type               None<br>
          Usage Type               Data<br>
        wMaxPacketSize     0x0040  1x 64 bytes<br>
        bInterval               0<br>
      Endpoint Descriptor:<br>
        bLength                 7<br>
        bDescriptorType         5<br>
        bEndpointAddress     0x83  EP 3 IN<br>
        bmAttributes            2<br>
          Transfer Type            Bulk<br>
          Synch Type               None<br>
          Usage Type               Data<br>
        wMaxPacketSize     0x0040  1x 64 bytes<br>
        bInterval               0<br>
Device Status:     0x0000<br>
  (Bus Powered)<br>
...