为什么我的报表描述符在lsusb中是“不可用的”?

时间:2018-11-22 10:49:06

标签: linux usb stm32 hidapi lsusb

我正在基于STM32 CubeMX鼠标示例对USB-HID设备进行编程。 我已经使用CustomHID类模板进行了一些修改(接口,端点,报告描述符等),目前正在测试枚举。

除了lsusb命令无法转储报告描述符之外,其他所有操作似乎都没问题:

$lsusb
Bus 001 Device 013: ID 0483:5740 STMicroelectronics STM32F407

$sudo lsusb -v -s 001:013

Bus 001 Device 013: ID 0483:5740 STMicroelectronics STM32F407
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.01
  bDeviceClass            2 Communications
  bDeviceSubClass         2 Abstract (modem)
  bDeviceProtocol         0 None
  bMaxPacketSize0        64
  idVendor           0x0483 STMicroelectronics
  idProduct          0x5740 STM32F407
  bcdDevice            2.00
  iManufacturer           1 TEST-ST
  iProduct                2 TEST MY HID
  iSerial                 3 00000000001A
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      36
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
Binary Object Store Descriptor:
  bLength                 5
  bDescriptorType        15
  wTotalLength           12
  bNumDeviceCaps          1
  USB 2.0 Extension Device Capability:
    bLength                 7
    bDescriptorType        16
    bDevCapabilityType      2
    bmAttributes   0x00000002
      Link Power Management (LPM) Supported
Device Status:     0x0001
  Self Powered

我在网上发现的唯一与我的问题有关的链接是this,但是它对此处的操作缺乏解释...

[编辑]

我也尝试使用HIDAPI进行调试:

由于某些原因,插入目标时,不发送报告描述符。 但是,当我通过 HIDAPI connect然后断开目标(无论我是否发送命令)时,然后在lsusb中填充报告描述符输出:

iInterface              0 
    HID Device Descriptor:
      bLength                 9
      bDescriptorType        33
      bcdHID               1.11
      bCountryCode            0 Not supported
      bNumDescriptors         1
      bDescriptorType        34 Report
      wDescriptorLength      34
      Report Descriptor: (length is 34)
        Item(Global): Usage Page, data= [ 0xd0 0xf1 ] 61904
                        (null)
        Item(Local ): Usage, data= [ 0x01 ] 1
                        (null)
        Item(Main  ): Collection, data= [ 0x01 ] 1
                        Application
        Item(Local ): Usage, data= [ 0x20 ] 32
                        (null)
        Item(Global): Logical Minimum, data= [ 0x00 ] 0
        Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
        Item(Global): Report Size, data= [ 0x08 ] 8
        Item(Global): Report Count, data= [ 0x40 ] 64
        Item(Main  ): Input, data= [ 0x02 ] 2
                        Data Variable Absolute No_Wrap Linear
                        Preferred_State No_Null_Position Non_Volatile Bitfield
        Item(Local ): Usage, data= [ 0x21 ] 33
                        (null)
        Item(Global): Logical Minimum, data= [ 0x00 ] 0
        Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
        Item(Global): Report Size, data= [ 0x08 ] 8
        Item(Global): Report Count, data= [ 0x40 ] 64
        Item(Main  ): Output, data= [ 0x02 ] 2
                        Data Variable Absolute No_Wrap Linear
                        Preferred_State No_Null_Position Non_Volatile Bitfield
        Item(Main  ): End Collection, data=none
  Endpoint Descriptor:

此外,当我用udevadm monitor进行监视时,输出如下:

KERNEL[25465.054769] add      /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2 (usb)
KERNEL[25465.055295] add      /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0 (usb)
KERNEL[25465.056409] add      /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D (hid)
KERNEL[25465.056864] add      /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/usbmisc/hiddev2 (usbmisc)
KERNEL[25465.056944] add      /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D/hidraw/hidraw3 (hidraw)
UDEV  [25465.097179] add      /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2 (usb)
UDEV  [25465.100961] add      /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0 (usb)
UDEV  [25465.104350] add      /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D (hid)
UDEV  [25465.106807] add      /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/usbmisc/hiddev2 (usbmisc)
UDEV  [25465.108620] add      /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D/hidraw/hidraw3 (hidraw)

当我使用 HIDAPI 连接到目标时:

KERNEL[25560.356084] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/usbmisc/hiddev2 (usbmisc)
KERNEL[25560.356187] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D/hidraw/hidraw3 (hidraw)
KERNEL[25560.356278] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D (hid)
UDEV  [25560.359579] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/usbmisc/hiddev2 (usbmisc)
UDEV  [25560.360677] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D/hidraw/hidraw3 (hidraw)
UDEV  [25560.362515] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D (hid)

断开连接后,没有其他活动了。但是,仅在为目标断开 HIDAPI 后,报告描述符才会出现在lsusb中。

我的猜测是,插头刚插入后,某些东西会阻塞/丢失。 与 HIDAPI 的连接触发了丢失信息的发送,但是我不确定为什么只有 HIDAPI 断开连接后该信息才可用...

0 个答案:

没有答案