百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
H

hidapitester

> 编程语言
开源

用于测试 HIDAPI 的简单命令行程序

366 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于测试 HIDAPI 的简单命令行程序

hidapitester

Simple command-line program to exercise HIDAPI The goal of the hidapitester program is to provide a simple, low-dependency command-line tool to test out every API call in hidapi. Default builds are fully-static with no requirements on a system-installed hidapi.

Table of Contents

  • Prebuilt binaries
  • Usage
    • Listing Devices
    • Opening Devices
    • Reading and Writing Reports
  • Examples
    • Test Hardware
  • Compiling
    • Platform-specific requirements
      • Mac
      • Windows
      • Linux

Prebuilt binaries

See the hidapitester releases page for builds for:

  • Mac OS X (Intel and M1)
  • Linux (Ubuntu x64 and Raspberry Pi)
  • Windows 64-bit

Usage

hidapitester works by parsing a list of arguments as commands it executes in order. Those commands are:

…

Listing Devices

  • --list shows devices similar to lsusb

  • --list-usages includes usagePage and usage attributes

  • --list-detail shows all available information, including usagePage, usage, path, and more

  • Use --vidpid, --usagePage, or --usage to filter the output

  • The --vidpid commmand allows full or partial specification of the Vendor Id and Product Id in hexadecimal.

These are all valid:

  --vidpid 16C0:FFAB  # specify both vid 0x16C0 and pid 0xFFAB
  --vidpid 16C0       # just specify the vid
  --vidpid 0:FFAB     # just specify the pid
  --vidpid 16C0:FFAB  # use colon instead of slash
  --vidpid 0x16C0:0xFFAB  # as explicitly hexadecimal

Opening Devices

You must --open before you can --read-input. You can also --read-input multiple times, or --open one device, --close it, and --open another.

The --open command will take whichever of VID, PID, usagePage, and usage are specified. So these are valid:

hidapitester --vidpid 16C0 --usagePage FFAB --open      # specify vid and usagePage
hidapitester --usage FFAB --open                        # specify only usagePage
hidapitester --0/0486  --open                           # specify only pid
hidapitester --vidpid 16C0/486 --usagePage FFAB --open  # specify vid,pid,usagePage

Reading and Writing Reports

Get the report descriptor with --get-report-descriptor.

Send Output reports to devices with --send-output. The argument to the command is the data to send: --send-output 1,2,0xff,30,40,0x50. If using reportIds, the first byte is the reportId. If not using reportIds, the first byte should be 0. The length of the actual report is set by --length .

Thus to send a 16-byte report on reportId 3 with only the 1st byte set to "42":

hidapitester [...] --length 16 --send-output 3,42

Send Feature reports the same way with --send-feature.

Read Input reports from device with --read-input. If using reportIds, use --read-input-report n where the n argument is the reportId number: e.g. --read-input 1. The length to read is specified by the --length argument. If using reportIds, this length should be one more than the buffer to read (e.g. if the report is 16-bytes, length is 17).

So to read a 16-byte report on reportId 3:

hidapitester [...] --length 17 --read-input-report 3

Examples

Get version info from a blink(1):

hidapitester --vidpid 0x27b8/0x1ed --open --length 9 --send-feature 1,99,0,255,0  --read-feature 1 --close
Opening device at vid/pid 27b8/1ed
Set buflen to 9
Writing 9-byte feature report...wrote 9 bytes
Reading 9-byte feature report, report_id 1...read 8 bytes
Report:
0x0, 0x63, 0x0, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0,
Closing device

Send data to/from "TeensyRawHid" sketch:

…

Test Hardware

  • "hidtest_tinyusb" is an Arduino sketch that's cross-platform for any device that Adafruit_TinyUSB_Arduino supports. Currently it primarily targets RP2040 (Raspberry Pi Pico), with ESP32-S2/S3 and SAMD51/21 also known to work.

  • "TeensyRawHid" is an Arduino sketch for Teensy microcontrollers. The sketch sends 64-byte Input reports every second, with no reportId. The sketch receives 64-byte Output reports, and prints them to Serial Monitor.

  • ProMicroRawHID is an Arduino sketch for any board supported by NicoHood's HID Project This sketch sends a 64-byte Input report every 2 seconds, with no reportId. The sketch recives 64-byte Output or Feature reports, and prints them to Serial Monitor

Compiling

Building hidapitester is done via a simple Makefile.

There is also a CMakeLists.txt if you prefer CMake. (see below)

Build with Makefile:

git clone https://github.com/libusb/hidapi
git clone https://github.com/todbot/hidapitester
cd hidapitester
make

hidapitester will use a copy of hidapi located next to it in the directory hierarchy. If you install hidapi in a different directory, you can set the Makefile variable HIDAPI_DIR before invoking make:

# hidapi is in dir 'hidapi-libusb-test'
cd hidapitester
HIDAPI_DIR=../hidapi-libusb-test make clean
HIDAPI_DIR=../hidapi-libusb-test make
./hidapitester --list

Build with CMake:

(The cmake build process will fetch hidapi main branch from github)

mkdir build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

Platform-specific requirements

Mac

  • Install XCode
  • Specifically, Command-line Tools
sudo xcode-select --install

Windows

  • Install MSYS2
  • Build in a MinGW / MSYS2 window

Linux

  • Install udev, pkg-config
sudo apt install libudev1 libudev-dev pkg-config

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Chidhidapiusb

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言