モダンなlsusbのようなcymeを少し試す

rust製のモダンなlsusb的なcymeというものを見かけたので少し試してみました．
cymeはlsusbとも互換性が有り，Linux/Windows/macOSで動作するようです．

tuna-f1sh/cyme: List system USB buses and devices; a lib and modern lsusb that attempts to maintain compatibility with, but also add new features

install

$ sudo apt install cargo libudev-dev
$ cargo install cyme
$ export PATH=/home/matoken/.cargo/bin:$PATH

help

$ cyme -h
List system USB buses and devices; a modern and compatible `lsusb`

Usage: cyme [OPTIONS]

Options:
-l, --lsusb
Attempt to maintain compatibility with lsusb output
-t, --tree
Dump USB device hierarchy as a tree
-d, --vidpid <VIDPID>
Show only devices with the specified vendor and product ID numbers (in hexadecimal) in format VID:[PID]
-s, --show <SHOW>
Show only devices with specified device and/or bus numbers (in decimal) in format [[bus]:][devnum]
-D, --device <DEVICE>
Selects which device lsusb will examine - supplied as Linux /dev/bus/usb/BBB/DDD style path
--filter-name <FILTER_NAME>
Filter on string contained in name
--filter-serial <FILTER_SERIAL>
Filter on string contained in serial
--filter-class <FILTER_CLASS>
Filter on USB class code [possible values: use-interface-descriptor, audio, cdc-communications, hid, physical, image, printer, mass-storage, hub, cdc-data, smart-cart, content-security, video, personal-healthcare, audio-video, billboard, usb-type-c-bridge, i3c-device, diagnostic, wireless-controller, miscellaneous, application-specific-interface, vendor-specific-class]
-v, --verbose...
Verbosity level: 1 prints device configurations; 2 prints interfaces; 3 prints interface endpoints; 4 prints everything and all blocks
-b, --blocks <BLOCKS>
Specify the blocks which will be displayed for each device and in what order [possible values: bus-number, device-number, branch-position, port-path, sys-path, driver, icon, vendor-id, product-id, name, manufacturer, product-name, vendor-name, serial, speed, tree-positions, bus-power, bus-power-used, extra-current-used, bcd-device, bcd-usb, class-code, sub-class, protocol]
--bus-blocks <BUS_BLOCKS>
Specify the blocks which will be displayed for each bus and in what order [possible values: bus-number, icon, name, host-controller, pci-vendor, pci-device, pci-revision, port-path]
--config-blocks <CONFIG_BLOCKS>
Specify the blocks which will be displayed for each configuration and in what order [possible values: name, number, num-interfaces, attributes, icon-attributes, max-power]
--interface-blocks <INTERFACE_BLOCKS>
Specify the blocks which will be displayed for each interface and in what order [possible values: name, number, port-path, class-code, sub-class, protocol, alt-setting, driver, sys-path, num-endpoints, icon]
--endpoint-blocks <ENDPOINT_BLOCKS>
Specify the blocks which will be displayed for each endpoint and in what order [possible values: number, direction, transfer-type, sync-type, usage-type, max-packet-size, interval]
-m, --more
Print more blocks by default at each verbosity
--sort-devices <SORT_DEVICES>
Sort devices by value [possible values: branch-position, device-number, no-sort]
--sort-buses
Sort devices by bus number
--group-devices <GROUP_DEVICES>
Group devices by value when listing [default: no-group] [possible values: no-group, bus]
--hide-buses
Hide empty buses when printing tree; those with no devices. When listing will hide Linux root_hubs
--hide-hubs
Hide empty hubs when printing tree; those with no devices. When listing will hide hubs regardless of whether empty of not
--decimal
Show base16 values as base10 decimal instead
--no-padding
Disable padding to align blocks
--no-colour
Disable coloured output, can also use NO_COLOR environment variable
--ascii
Disables icons and utf-8 charactors
--headings
Show block headings
--json
Output as json format after sorting, filters and tree settings are applied; without -tree will be flattened dump of devices
--from-json <FROM_JSON>
Read from json output rather than profiling system - must use --tree json dump
-F, --force-libusb
Force libusb profiler on macOS rather than using/combining system_profiler output
-c, --config <CONFIG>
Path to user config file to use for custom icons, colours and default settings
-z, --debug...
Turn debugging information on. Alternatively can use RUST_LOG env: INFO, DEBUG, TRACE
--mask-serials <MASK_SERIALS>
Mask serial numbers with '*' or random chars [possible values: hide, scramble, replace]
-h, --help
Print help information (use `--help` for more detail)
-V, --version
Print version information

実行

$ cyme
Failed to open Bus 002 Device 001: ID 1d6b:0003, will be unable to obtain all data: Access denied (insufficient permissions)
Failed to open Bus 001 Device 003: ID 8087:0a2b, will be unable to obtain all data: Access denied (insufficient permissions)
Failed to open Bus 001 Device 002: ID 5986:054c, will be unable to obtain all data: Access denied (insufficient permissions)
Failed to open Bus 001 Device 004: ID 17ef:6047, will be unable to obtain all data: Access denied (insufficient permissions)
Failed to open Bus 001 Device 001: ID 1d6b:0002, will be unable to obtain all data: Access denied (insufficient permissions)
1 3  0x8087 0x0a2b Bluetooth wireless interface 12.0 Mb/s
1 2  0x5986 0x054c 480.0 Mb/s
1 4  0x17ef 0x6047 ThinkPad Compact Keyboard with TrackPoint 12.0 Mb/s
1 1  0x1d6b 0x0002 2.0 root hub 480.0 Mb/s
2 1  0x1d6b 0x0003 3.0 root hub 5.0 Gb/s

permission不足をsudoで解決

$ sudo ~/.cargo/bin/cyme
1 3  0x8087 0x0a2b Bluetooth wireless interface 12.0 Mb/s
1 2  0x5986 0x054c USB HD Webcam 200901010001 480.0 Mb/s
1 4  0x17ef 0x6047 ThinkPad Compact USB Keyboard with TrackPoint 12.0 Mb/s
1 1  0x1d6b 0x0002 xHCI Host Controller 0000:00:14.0 480.0 Mb/s
2 1  0x1d6b 0x0003 xHCI Host Controller 0000:00:14.0 5.0 Gb/s

lsusb形式

$ cyme --lsusb
Failed to open Bus 002 Device 001: ID 1d6b:0003, will be unable to obtain all data: Access denied (insufficient permissions)
Failed to open Bus 001 Device 003: ID 8087:0a2b, will be unable to obtain all data: Access denied (insufficient permissions)
Failed to open Bus 001 Device 002: ID 5986:054c, will be unable to obtain all data: Access denied (insufficient permissions)
Failed to open Bus 001 Device 004: ID 17ef:6047, will be unable to obtain all data: Access denied (insufficient permissions)
Failed to open Bus 001 Device 001: ID 1d6b:0002, will be unable to obtain all data: Access denied (insufficient permissions)
Bus 001 Device 003: ID 8087:0a2b Intel Corp. Bluetooth wireless interface
Bus 001 Device 002: ID 5986:054c Acer, Inc
Bus 001 Device 004: ID 17ef:6047 Lenovo ThinkPad Compact Keyboard with TrackPoint
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

文字化けが気になるので --ascii オプションを

$ sudo ~/.cargo/bin/cyme --tree --ascii
/: xHCI Host Controller Linux 6.0.0-6-amd64 xhci-hcd
|__O 4 0x17ef 0x6047 ThinkPad Compact USB Keyboard with TrackPoint
|__O 2 0x5986 0x054c USB HD Webcam 200901010001
|__O 3 0x8087 0x0a2b Bluetooth wireless interface

/: xHCI Host Controller Linux 6.0.0-6-amd64 xhci-hcd

--verbose は4つまで効くよう

$ sudo ~/.cargo/bin/cyme --ascii --vidpid 0x17ef:0x6047 --verbose --verbose --verbose | wc
6 39 271
$ sudo ~/.cargo/bin/cyme --ascii --vidpid 0x17ef:0x6047 --verbose --verbose --verbose --verbose | wc
6 56 389
$ sudo ~/.cargo/bin/cyme --ascii --vidpid 0x17ef:0x6047 --verbose --verbose --verbose --verbose --verbose | wc
6 56 389

filter

$ sudo ~/.cargo/bin/cyme --ascii --filter-name cam (1)
1 2 0x5986 0x054c USB HD Webcam 200901010001 480.0 Mb/s
$ sudo ~/.cargo/bin/cyme --ascii --filter-class hid (2)
$ sudo ~/.cargo/bin/cyme --ascii --filter-serial 14 (3)
1 1 0x1d6b 0x0002 xHCI Host Controller 0000:00:14.0 480.0 Mb/s
2 1 0x1d6b 0x0003 xHCI Host Controller 0000:00:14.0 5.0 Gb/s
$ sudo ~/.cargo/bin/cyme --ascii --vidpid 0x17ef:0x6047 (4)
1 4 0x17ef 0x6047 ThinkPad Compact USB Keyboard with TrackPoint 12.0 Mb/s

文字列でフィルタ

hid class でフィルタ……うまくいかない?

serialの一部でフィルタ

vid/pidでフィルタ

よく使う sudo lsusb -d 17ef:6047 -vvv の代わり?

$ sudo ~/.cargo/bin/cyme --ascii --vidpid 0x17ef:0x6047 --verbose --verbose --verbose --verbose --lsusb | head

Bus 001 Device 004: ID 17ef:6047 Lenovo ThinkPad Compact Keyboard with TrackPoint
Device Descriptor:
bcdUSB 2.00
bDeviceClass 0 UseInterfaceDescriptor
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x17ef Lenovo
idProduct 0x6047 ThinkPad Compact Keyboard with TrackPoint

uninstall

$ cargo uninstall cyme
Removing /home/matoken/.cargo/bin/cyme

lsusbでそう困っていませんが，cymeはlsusbと互換性があるし見た目も今どきな感じなので良さそうです．ただ自分で入れてまで使うかというと微妙．ディストリビューションパッケージに入ったら使うかもという感じでしょうか．

環境

$ cyme --version
cyme 1.2.1
$ dpkg-query -W cargo libudev-dev
cargo 0.63.1-3
libudev-dev:amd64 252.4-1
$ lsb_release -a
Distributor ID: Debian
Description: Debian GNU/Linux bookworm/sid
Release: n/a
Codename: bookworm
$ arch
x86_64