usbhid-dump(8)

๐Ÿ“ฆ
version 020 ยท 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

โœจ usbhid-dump(8) โ€” NAME โœจ

usbhid-dump ๐Ÿฆ‹ is the tool that lets you dump USB HID device report descriptors and streams. Iconic, right?


๐Ÿ“‹ SYNOPSIS ๐Ÿ“‹

usbhid-dump [OPTION]...

๐Ÿ’– DESCRIPTION ๐Ÿ’–

okay so usbhid-dump uses libusb to dump report descriptors and streams from HID (human interface device) interfaces of USB devices. By default it dumps HID interfaces of all connected USB devices, but you can narrow it down to a subset of them, or to a single interface, using options. main character energy ๐Ÿ’…

๐Ÿšจ NOTE: usbhid-dump detaches kernel drivers from the interfaces it dumps and uses them exclusively, so no other program receives the input in the meantime. The report descriptor dumping is instantaneous, but the stream dumping keeps going until you terminate it with SIGINT (^C from the terminal) or a timeout expires.

bestie, listen ๐Ÿซถ if you accidentally start dumping a stream from the USB keyboard you're using to control the terminal, the system stops receiving your input and you can't terminate usbhid-dump. ๐Ÿ’€ Just stop typing and wait for the timeout to expire. The stream dumping will stop, the keyboard gets reattached to the kernel driver, and you'll regain control. phew ๐Ÿ˜ญ

The default stream dumping timeout is 60 seconds, and you can change it with the -t option. โฐ


๐ŸŽ€ OPTIONS ๐ŸŽ€

  • -h, --help โ€” Output a help message and exit. ๐ŸŒธ
  • -v, --version โ€” Output version information and exit. โœจ
  • -s, -a, --address=bus[:dev] โ€” Limit interfaces by bus number and device address. Both are 1-255, decimal. Zeroes match any bus or device. ๐Ÿงš
  • -d, -m, --model=vid[:pid] โ€” Limit interfaces by device vendor and product IDs. Both are 1-FFFF, hexadecimal. Zeroes match any vendor or product. ๐Ÿ’œ
  • -i, --interface=NUMBER โ€” Limit interfaces by number (0-254), decimal. 255 matches any interface. ๐Ÿฆ‹
  • -e, --entity=STRING โ€” The entity to dump: either "descriptor", "stream" or "all". You can shorten it down to one letter. The default is "descriptor". ๐Ÿ’…
  • -t, --stream-timeout=NUMBER โ€” Stream interrupt transfer timeout, in ms. Zero means infinity. The default is 60000 (60 seconds). โณ
  • -p, --stream-paused โ€” Start with the stream dump output paused. ๐Ÿ™ˆ
  • -f, --stream-feedback โ€” Enable stream dumping feedback: print a dot to stderr for every transfer dumped. ๐Ÿ“

๐ŸŒˆ SIGNALS ๐ŸŒˆ

  • USR1/USR2 โ€” Pause/resume stream dump output. ๐Ÿ”ฅ

๐Ÿงพ OUTPUT FORMAT ๐Ÿงพ

okay so usbhid-dump outputs dumps in chunks. Each chunk is separated by an empty line and starts with this header line:

BUS:DEVICE:INTERFACE:ENTITY TIMESTAMP

Here, BUS, DEVICE and INTERFACE are the bus, device and interface numbers respectively. ENTITY is either "DESCRIPTOR" or "STREAM". TIMESTAMP is the timestamp in seconds since epoch. โŒ›

After the header, the actual dump data follows as hex bytes. A descriptor chunk includes the whole report descriptor. Every stream chunk usually includes a whole report, but if a report is bigger than the endpoint's wMaxPacketSize, it will span several chunks. ๐Ÿงฉ


๐Ÿ“ EXAMPLES ๐Ÿ“

Dump the report descriptor for a device with address 3 on bus number 2: ๐Ÿ’ป

usbhid-dump -a 2:3

Dump the report stream for a device with vendor ID 0x5543 and product ID 0x0005: ๐ŸŽฎ

usbhid-dump -m 5543:0005 -es

Dump the report descriptor from interface 1 of a device with vendor ID 0x5543: ๐Ÿ”

usbhid-dump -m 5543 -i 1 -ed

Dump report streams from all HID interfaces of all USB devices (caution: you will lose control over the terminal if you use a USB keyboard): โš ๏ธ

usbhid-dump -es

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Nikolai Kondrashov <spbnick@gmail.com> ๐Ÿซถ


bestie, this was the usbutils package's usbhid-dump(8) page from the Linux USB Utilities set, last updated February 2012. Go slay your HID devices responsibly ๐Ÿ’…โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from