系统命令并搜索特定并显示

系统命令并搜索特定并显示

lsusb -v 提供 USB 设备的详细响应。

例子:

Bus 003 Device 003: ID 413c:2003 Dell Computer Corp. Keyboard
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x413c Dell Computer Corp.
  idProduct          0x2003 Keyboard
  bcdDevice            3.06
  iManufacturer           1 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower               70mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      1 Keyboard
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      65
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              24

现在我只想查看设备部分bInterfaceProtocol,或者我想列出所有 USB 设备的内容。有人能告诉我这个的具体格式吗?Interface DescriptorBus 003 Device 003bInterfaceProtocol

答案1

您无法仅使用以下方法完成此操作lsusb。您可以:

  1. 使用-s-d选项来制作lsusb仅显示特定设备的输出:

    -s [[bus]:][devnum]
          Show only devices in specified bus and/or devnum.  Both ID's are
          given in decimal and may be omitted.
    
    -d [vendor]:[product]
          Show  only  devices  with  the  specified vendor and product ID.
          Both ID's are given in hexadecimal.
    
  2. 并用来grep过滤掉字段。

例如:

$ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 004: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 003 Device 002: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
$ lsusb -s 003:003
Bus 003 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
$ lsusb -s 003:003 -v | grep bInterfaceProtocol
  bInterfaceProtocol      0 Full speed (or root) hub
# lsusb -v | grep -e bInterfaceProtocol -e Bus
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
      bInterfaceProtocol      0 Full speed (or root) hub
Bus 003 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
      bInterfaceProtocol      0 Full speed (or root) hub
Bus 003 Device 004: ID 0e0f:0003 VMware, Inc. Virtual Mouse
      bInterfaceProtocol      2 Mouse
Bus 003 Device 002: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
      bInterfaceProtocol      0 Full speed (or root) hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
      bInterfaceProtocol      0 Full speed (or root) hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
      bInterfaceProtocol      0 Full speed (or root) hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
      bInterfaceProtocol      0 Full speed (or root) hub

相关内容