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.

Error parsing data from "lsusb -v"

See original GitHub issue

While parsing plain lsusb output is fine, the output from lsusb -v gives an error:

# lsusb -s 002:002 -v | jc --lsusb -d
Traceback (most recent call last):
  File "/usr/bin/jc", line 33, in <module>
    sys.exit(load_entry_point('jc==1.20.2', 'console_scripts', 'jc')())
  File "/usr/lib/python3.10/site-packages/jc/cli.py", line 619, in main
    result = parser.parse(data,
  File "/usr/lib/python3.10/site-packages/jc/parsers/lsusb.py", line 835, in parse
    if lsusb._populate_lists(line):
  File "/usr/lib/python3.10/site-packages/jc/parsers/lsusb.py", line 521, in _populate_lists
    self.hub_port_status_list.append(self._add_hub_port_status_attributes(line))
  File "/usr/lib/python3.10/site-packages/jc/parsers/lsusb.py", line 395, in _add_hub_port_status_attributes
    second_split = first_split[1].split(maxsplit=1)
IndexError: list index out of range

The lsusb output looks like this:

# lsusb -s 002:002 -v

Bus 002 Device 002: ID 8087:8000 Intel Corp. Integrated Rate Matching Hub
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0 
  bDeviceProtocol         1 Single TT
  bMaxPacketSize0        64
  idVendor           0x8087 Intel Corp.
  idProduct          0x8000 Integrated Rate Matching Hub
  bcdDevice            0.04
  iManufacturer           0 
  iProduct                0 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0019
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 Full speed (or root) hub
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0002  1x 2 bytes
        bInterval              12
Hub Descriptor:
  bLength              11
  bDescriptorType      41
  nNbrPorts             8
  wHubCharacteristic 0x0009
    Per-port power switching
    Per-port overcurrent protection
    TT think time 8 FS bits
  bPwrOn2PwrGood        0 * 2 milli seconds
  bHubContrCurrent      0 milli Ampere
  DeviceRemovable    0x00 0x00
  PortPwrCtrlMask    0xff 0xff
 Hub Port Status:
   Port 1: 0000.0100 power
   Port 2: 0000.0100 power
   Port 3: 0000.0100 power
   Port 4: 0000.0100 power
   Port 5: 0000.0100 power
   Port 6: 0000.0100 power
   Port 7: 0000.0100 power
   Port 8: 0000.0100 power
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0 
  bDeviceProtocol         0 Full speed (or root) hub
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0001
  Self Powered

This is on Fedora Linux 36 with LANG=en_US.utf8 and usbutils-014-2.fc36.x86_64. jc used was still version 1.20.2, but it doesn’t look like the lsusb parser has been modified recently.

Similar errors occur whith the other usb devices. I just posted the data from one device for brevity, but could post full output or more information if helpful.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
g-v-egidycommented, Jul 30, 2022

With your newest patch parsing lsusb -v passes on all my systems.

Thank you very much for fixing this so fast.

0reactions
kellyjonbrazilcommented, Jul 30, 2022

It looks like the issue with these files was an additional Binary Object Store Descriptor section. I put in a handler to just ignore this section for now, which fixes the issue on all of the sample files. Could you let me know if that works for you? Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Config descriptor read ok by libusb 0.1, but fails with short ...
Hi all, I am trying to communicate with a device from Linux, and I'm experiencing a specific problem - with usblib-1.0 unable to...
Read more >
[regression 1.0.24] can't communicate with iPhone/iPad on ...
Hi, I'm seeing the same thing with an Eaton UPS. I can confirm that e2be556 is the first bad commit. Output from LIBUSB_DEBUG=99...
Read more >
benchmark demo error - lsusb - UP Community
Hello, we have an AI core module https://up-board.org/ai-edge/ai-core/ connected through PCIe to main Xeon Processor running Linux Centos.
Read more >
Bug #1534856 “lsusb hangs” : Bugs : linux package : Ubuntu
If I plug the sound card into a USB2 port, lsusb does not hang but the device is not ... as it doesn't...
Read more >
Determine if a usb is mounted using lsusb data [closed]
At the moment I use the lsusb -v command and parse it to obtain the Bus, Device and ID of the USB device...
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