To help diagnose USB HID communication and to test out updates to hidapi, I wrote hidapitester. It is a command-line program that allows you to exercise just about every aspect of hidapi. Pre-built binaries for MacOS, Windows, and Linux Ubuntu x64.
I’ve found it very useful. You can use it to:
- Scan for connected HID devices, optionally by VID, PID, usagePage, usage
- Send OUTPUT reports, with or without Report IDs
- Receive INPUT reports, with or without Report IDs
- Send FEATURE reports, with or without Report IDs
- Receive FEATURE reports, with or without Report IDs
Commands are specified in-order on the command-line, so you can do all of these, repeated reads, close-and-open, etc. all in a single command. More details can be found on the hidapitester github README page.
It is written in really vanilla C to maximize compatibility and ease-of-compilation.
Here’s the help page:
Usage:
hidapitester <cmd> [options]
where <cmd> is one of:
--vidpid <vid/pid> Filter by vendorId/productId (comma/slash delim)
--usagePage <number> Filter by usagePage
--usage <number> Filter by usage
--list List HID devices (by filters)
--list-detail List HID devices w/ details (by filters)
--open Open device with previously selected filters
--open-path <pathstr> Open device by path (as in --list-detail)
--close Close currently open device
--send-feature <datalist> Send Feature report (1st byte reportId, if used)
--read-feature <reportId> Read Feature report (w/ reportId, 0 if unused)
--send-output <datalist> Send Ouput report to device
--read-input [reportId] Read Input report (w/ opt. reportId, if unused)
--read-input-forever [rId] Read Input reports in a loop forever
--length <len>, -l <len> Set buffer length in bytes of report to send/read
--timeout <msecs> Timeout in millisecs to wait for input reads
--base <base>, -b <base> Set decimal or hex buffer print mode
--quiet, -q Print out nothing except when reading data
--verbose, -v