question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New Parser: lsusb

See original GitHub issue

Verbose I filtered this one to a single device. Without the filter the output is the same, but a block like this for each device.

$ lsusb -d 1915:521a -v

Bus 003 Device 090: ID 1915:521a Nordic Semiconductor ASA nRF52 USB CDC BLE Demo
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x1915 Nordic Semiconductor ASA
  idProduct          0x521a 
  bcdDevice            1.00
  iManufacturer           1 Nordic Semiconductor
  iProduct                2 nRF52 USB CDC BLE Demo
  iSerial                 3 F42DE60BE261
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x004b
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          4 
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass          2 Communications
      bFunctionSubClass       2 Abstract (modem)
      bFunctionProtocol       1 AT-commands (v.25ter)
      iFunction               0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      1 AT-commands (v.25ter)
      iInterface              0 
      CDC Header:
        bcdCDC               1.10
      CDC Call Management:
        bmCapabilities       0x03
          call management
          use DataInterface
        bDataInterface          1
      CDC ACM:
        bmCapabilities       0x02
          line coding and serial state
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              16
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      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               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0

Normal

$ lsusb -d 1915:521a
Bus 003 Device 090: ID 1915:521a Nordic Semiconductor ASA nRF52 USB CDC BLE Demo

Tree

$ lsusb -t
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 2: Dev 90, If 0, Class=Communications, Driver=cdc_acm, 12M
        |__ Port 2: Dev 90, If 1, Class=CDC Data, Driver=cdc_acm, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
        |__ Port 1: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 2: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 6: Dev 66, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 1: Dev 67, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
            |__ Port 1: Dev 67, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M

Verbose Tree

$ lsusb -tv
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        ID 0409:005a NEC Corp. HighSpeed Hub
        |__ Port 2: Dev 90, If 0, Class=Communications, Driver=cdc_acm, 12M
            ID 1915:521a Nordic Semiconductor ASA 
        |__ Port 2: Dev 90, If 1, Class=CDC Data, Driver=cdc_acm, 12M
            ID 1915:521a Nordic Semiconductor ASA 
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
        ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
        ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
        |__ Port 1: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
            ID 045e:00d1 Microsoft Corp. Optical Mouse with Tilt Wheel
        |__ Port 2: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
            ID 051d:0002 American Power Conversion Uninterruptible Power Supply
        |__ Port 6: Dev 66, If 0, Class=Hub, Driver=hub/4p, 480M
            ID 0424:2504 Microchip Technology, Inc. (formerly SMSC) 
            |__ Port 1: Dev 67, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
                ID 0518:0001 EzKEY Corp. USB to PS2 Adaptor v1.09
            |__ Port 1: Dev 67, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
                ID 0518:0001 EzKEY Corp. USB to PS2 Adaptor v1.09

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kellyjonbrazilcommented, Oct 30, 2021

added in v1.17.1

0reactions
kellyjonbrazilcommented, Oct 23, 2021

I have a working version of the lsusb parser in the dev branch. Could you copy/paste the code from the link below into a file called lsusb.py in your App data directory to test it?

https://github.com/kellyjonbrazil/jc/blob/dev/jc/parsers/lsusb.py

This is probably one of the most complex parsers I’ve written due to the many state changes required. Maybe there was a simpler way to do it, but I ended up at this this solution. I think match/case functionality in Python 3.10 may make something like this easier in the future.

p.s. I only implemented lsusb and lsusb -v.

Read more comments on GitHub >

github_iconTop Results From Across the Web

technique to know usb root hub by parsing lsusb -v command ...
I mounted usbfs file system,it began to show the devices file.from this file,root hubs can be easily detected But I want to parse...
Read more >
jc - JSON Convert lsusb command output parser - GitHub Pages
CLI tool and python library that converts the output of popular command-line tools, file-types, and common strings to JSON, YAML, or Dictionaries.
Read more >
parse-usb-devices.sh - GitHub Gist
Parse the output of the "usb-devices" bash script and filter. # only for Mass Storage devices (Class ... new device. bus=$(echo "${line}" |...
Read more >
How to get device filename from lsusb output or by device path
1. Browse the directories under /dev/disk/ , the by-label and by-id paths might be of use. – lornix · 1. Thanks, but /dev/disk...
Read more >
How to Use lsusb in Linux (With a Practical Example)
lsusb is a command-line tool in Linux, installed by default as part of your (modern) Linux Operating System, which can list and enumerate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found