usb/detect doesn't list all USB devices

Bug #1712435 reported by Jeff Lane on 2017-08-22
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Provider for Plainbox - Checkbox
Medium
Jeff Lane

Bug Description

The description for usb/detect is this:
plugin: shell
category_id: com.canonical.plainbox::usb
id: usb/detect
requires:
 cpuinfo.platform != 's390x'
estimated_duration: 1.0
command:
 set -o pipefail
 if [[ -v SNAP ]]; then
     lsusb.py -f $SNAP/var/lib/usbutils/usb.ids 2>/dev/null | sed 's/.*\(ID .*\)/\1/' | head -n 4 || echo "No USB devices were detected" >&2
 else
     lsusb 2>/dev/null | sed 's/.*\(ID .*\)/\1/' | head -n 4 || echo "No USB devices were detected" >&2
 fi
_summary: Display USB devices attached to SUT
_description: Detects and shows USB devices attached to this system.

I don't recall why, but the head usage means it is not returning all the attached USB devices. For example:

bladernr@galactica:~/development/git/plainbox-provider-checkbox$ lsusb 2>/dev/null | sed 's/.*\(ID .*\)/\1/' | head -n 4
ID 2109:0812 VIA Labs, Inc. VL812 Hub
ID 2109:0812 VIA Labs, Inc. VL812 Hub
ID 1d6b:0003 Linux Foundation 3.0 root hub
ID 1050:0010 Yubico.com Yubikey
bladernr@galactica:~/development/git/plainbox-provider-checkbox$ lsusb 2>/dev/null | sed 's/.*\(ID .*\)/\1/'
ID 2109:0812 VIA Labs, Inc. VL812 Hub
ID 2109:0812 VIA Labs, Inc. VL812 Hub
ID 1d6b:0003 Linux Foundation 3.0 root hub
ID 1050:0010 Yubico.com Yubikey
ID 2109:2812 VIA Labs, Inc. VL812 Hub
ID 2109:2812 VIA Labs, Inc. VL812 Hub
ID 1d6b:0002 Linux Foundation 2.0 root hub
ID 1d6b:0003 Linux Foundation 3.0 root hub
ID 17f6:0860 Unicomp, Inc
ID 046d:c52b Logitech, Inc. Unifying Receiver
ID 051d:0002 American Power Conversion Uninterruptible Power Supply
ID 1d6b:0002 Linux Foundation 2.0 root hub

One of the following options would be preferable:

Tree, only drawback is that it doesn't explicitly show the names of devices
bladernr@galactica:~/development/git/plainbox-provider-checkbox$ lsusb -t 2>/dev/null |sort
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/10p, 5000M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
    |__ Port 13: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 1: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 3, If 0, Class=Hub, Driver=hub/4p, 5000M
    |__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
    |__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M
        |__ Port 2: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
            |__ Port 2: Dev 5, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
    |__ Port 4: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 4: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 4: Dev 2, If 2, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 6: Dev 6, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 6: Dev 6, If 1, Class=Human Interface Device, Driver=usbhid, 12M

full output, sorted. Allows you to map which key is attached to which hub:
bladernr@galactica:~/development/git/plainbox-provider-checkbox$ lsusb 2>/dev/null |sort
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 005: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 006: ID 17f6:0860 Unicomp, Inc
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 2109:2812 VIA Labs, Inc. VL812 Hub
Bus 003 Device 003: ID 2109:2812 VIA Labs, Inc. VL812 Hub
Bus 003 Device 004: ID 1050:0010 Yubico.com Yubikey
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 004 Device 002: ID 2109:0812 VIA Labs, Inc. VL812 Hub
Bus 004 Device 003: ID 2109:0812 VIA Labs, Inc. VL812 Hub
Bus 004 Device 005: ID 125f:312b A-DATA Technology Co., Ltd. Superior S102 Pro

Jeff Lane (bladernr) on 2017-08-23
Changed in plainbox-provider-checkbox:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Jeff Lane (bladernr)
milestone: none → 0.40.0
Changed in plainbox-provider-checkbox:
status: In Progress → Fix Committed
Changed in plainbox-provider-checkbox:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers