• Stars
    star
    203
  • Rank 192,890 (Top 4 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created over 5 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple command-line program to test HIDAPI

hidapitester

Simple command-line program to exercise HIDAPI

Build Status linux Build Status macos Build Status windows

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

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:

  --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               Print out extra information

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 commmands allows full or partial specification of the Vendor Id and Product Id. 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
    

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

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 <num>.

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, the argument should be the reportId number: --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 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:

hidapitester --vidpid 16C0 --usagePage 0xFFAB --open --send-output 0x4f,33,22,0xff  --read-input
Opening device, vid/pid:0x16C0/0x0000, usagePage/usage: FFAB/0
Device opened
Writing output report of 64-bytes...wrote 64 bytes:
 4F 21 16 FF 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Reading 64-byte input report, 250 msec timeout...read 64 bytes:
 AB CD 01 67 01 6F 01 93 01 94 01 A6 01 AA 01 67
 01 82 01 7D 01 79 01 18 01 0B 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 91
Closing device

Test Hardware

  • The "TeensyRawHid" directory contains 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.

  • The "ProMicroRawHID" directory contains an Arduino sketch for any microcontroller 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 very simple 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

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
    

More Repositories

1

blink1

Official software for blink(1) USB RGB LED by ThingM
C#
944
star
2

circuitpython-tricks

Some CircuitPython tricks, mostly reminders to myself
Python
534
star
3

arduino-serial

Example C and Java host code to talking to an arduino or other "serial" device
C
232
star
4

picostepseq

MIDI sequencer using Raspberry Pi Pico in Arduino & CircuitPython
C
191
star
5

Blink1Control2

Blink1Control GUI to control blink(1) USB RGB LED devices.
JavaScript
151
star
6

usbSearch

Search for USB devices by VID/PID, gets device serial numbers
C
102
star
7

blink1-tool

Command-line tools and C library for blink(1) USB RGB LED
C
80
star
8

mozzi_experiments

Experiments with Mozzi, mostly on SAMD21 & RP2040 chips
C++
79
star
9

wiichuck_adapter

Very simple adpater for hooking a Wii Nunchuck to your Arduino or other microcontroller
Objective-C
72
star
10

SoftI2CMaster

Software I2C / TWI library for Arduino allows any two pins to be SDA & SCL
C++
71
star
11

qtpy-knob

QT Py Media Knob using rotary encoder & neopixel ring
Python
70
star
12

ServoEaser

Arduino library for servo easing
C++
67
star
13

picotouch

Tiny capsense touch MIDI keyboard controller from a Raspberry Pi Pico
Python
67
star
14

hidpytoy

A GUI app for playing with HID devices, written in Python
Python
64
star
15

arduino-i2c-scanner

Simple Arduino I2C scanner as described at http://todbot.com/blog/2009/11/29/i2cscanner-pde-arduino-as-i2c-bus-scanner/
Arduino
64
star
16

CircuitPython_GC9A01_demos

Demos showing how to use CircuitPython displayio driver for GC9A01 round LCDs
Python
50
star
17

qtpy-tricks

Some tips and tricks for CircuitPython, using a QT Py board
41
star
18

win-hid-dump

Sort of a Windows version of `usbhid-dump` to show HID Report Descriptors
C#
40
star
19

mac-hid-dump

Sort of a MacOS version of `usbhid-dump` to show HID Report Descriptors
C
40
star
20

circuitpython-synthio-tricks

tips, tricks, and examples of using CircuitPython synthio
37
star
21

blink1-python

Official Python library for blink(1) USB RGB LED notification device
Python
35
star
22

pico8enc

Lotsa Rotary Encoders on a Raspberry Pi Pico
Python
33
star
23

PicoDVI_experiments

Experiments using PicoDVI (mostly on Adafruit DVI RP2040 Feather)
C++
31
star
24

NeoJoints

Neopixel Joints, millable on the Othermill
Eagle
27
star
25

macropadsynthplug

Abuse StemmaQT port by turning it into Audio Out + MIDI In
Python
25
star
26

picotouch_synth

Thin captouch-based synth platform for Raspberry Pi Pico
Python
24
star
27

MIDIPedalBox

USB MIDI Pedal, powered by CircuitPython + Trinket M0
Python
24
star
28

samd21-programming-notes

SAMD21 programming notes
23
star
29

electron-hid-toy

Simple example of using node-hid in Electron (w/ React)
JavaScript
19
star
30

crashspace-bigbutton

Eagle
18
star
31

MozziScout

Arduino sketches for Oskitone Scout using Mozzi synthesis library
C
17
star
32

plinkykeeb

Simple MIDI controller using KB2040 and computer key switches
Python
16
star
33

circuitpython_staroids

Something like Asteroids but not really, done in CircuitPython
Python
15
star
34

circuitpython_led_effects

Some fun with Neopixel / WS2812 LEDs in CircuitPython
Python
15
star
35

qtpy_synth

Hardware & software for a tiny QTPy-driven synth
Python
13
star
36

LinkM

BlinkM controller / programmer and general USB-to-I2C adapter
C
12
star
37

node-blink1-server

HTTP API server in Node for blink(1) devices
JavaScript
12
star
38

BlinkM-Examples

BlinkM example code for Arduino, Processing, et al
C
11
star
39

hidraw-dump

Use Linux HIDRAW to print info about HID devices (USB & Bluetooth/BLE)
C
9
star
40

blink1mk3

Official hardware design files for blink(1) mk3 USB RGB LED by ThingM
C
8
star
41

circuitpython_screensaver

Do you need a screensaver for CircuitPython? Of course you do
Python
8
star
42

Mill-a-Week

weekly experiments with othermachine Othermill
Eagle
8
star
43

eurorack_hagiwo_stuff

C++
8
star
44

blink1-android

Android library for blink(1) USB RGB LED
Java
7
star
45

ArduinoOnBeagleBone

Arduino and AVR compilation tools for BeagleBone (currently command-line only)
7
star
46

CircuitPython_PS2Controller

CircuitPython library to read Sony PS2 and PS1 ("PSX") game controllers
Python
7
star
47

blink1-java

blink(1) Java / Processing library
Processing
6
star
48

magtag_dayofweek

Use MagTag to display day of week on your fridge
Python
6
star
49

picostepsynth

Python
6
star
50

NeopixelTester

some testing hardware for Neopixels (WS2812, SK6812)
C++
6
star
51

CircuitPython_MicroOSC

Minimal OSC parser, server, and client for CircuitPython and CPython
Python
5
star
52

node-hid-ds4-test

Testing Playstation DualShock4 controller with node-hid
JavaScript
5
star
53

tal_experiments

Experiments with the Teensy Audio Library
C++
5
star
54

tomu-hardware-eagle

Eagle translation of im-tomu/tomu-hardware
5
star
55

ArduinoCore-EFM32

Arduino core for EFM32HG and Tomu boards (very much work in progress)
C
5
star
56

HackadayVectorscopeHacks

Hacks (hopefully) for the Hackaday Superconference 2023 badge
Python
5
star
57

touchwheels

some touchwheels
Python
5
star
58

CircuitPython_Noise

Simplex noise (like Perlin) for CircuitPython
Python
4
star
59

blink1-webhid

JavaScript
4
star
60

blink1-python-old

Python libraries for blink(1) USB LED
Python
4
star
61

node-ifttt-demoserver

Example of how to implement an IFTTT Channel w/ OAuth2
JavaScript
4
star
62

blinkm2

C++
3
star
63

NoiseShield

A simple audio output shield for Arduino
C
3
star
64

electron-hid-test

extremely simple demo of node-hid with electron
JavaScript
3
star
65

StripGrid

Grid controller for LED strips
C
3
star
66

circuitpython_ledtools

hacks
Python
3
star
67

electron-hid-test-erb

electron-hid-test using electron-react-boilerplate
TypeScript
3
star
68

qtpy-keys

Tiny USB keyboard using QTPy and CircuitPython
Python
3
star
69

MIDIHost2Host

Connect two USB-MIDI host devices together, using two Trinket M0s
C++
3
star
70

GPSWiiRecorder

The full set of source for the Make magazine Wii nunchuck roller coaster data logger
C++
3
star
71

node-arduino-serial

NodeJs version of arduino-serial commandline tool
JavaScript
2
star
72

circuitpython_invaders

Python
2
star
73

CloudFridge

C++
2
star
74

TeamPneumo

Development for CashMachine
C++
2
star
75

eagle-tricks

Various bits n bobs to do with Eagle Schematic & PCB software
2
star
76

samd11toy

playing with SAMD11
Eagle
2
star
77

SDLbeerlight

an overly complicated light announcing a certain time of day or state of mind
Eagle
2
star
78

ILOVELAMP

Sketches and Ideas for I LOVE LAMP project
Eagle
2
star
79

seeknobs

knob board for seesaw, and also a drone synth
C++
2
star
80

TrinketTrigger

The simplest Eurorack module?
Python
2
star
81

QTPyNoisyBoi

Python
2
star
82

cirpycp

Copy files from CircuitPython Bundle to your device, based on a list of requirements
Shell
2
star
83

pico_test_synth

Simple board to help make synths with Raspberry Pi Pico and PCM5102 I2S DAC
Python
2
star
84

WS2812_Arduino_Lib_Compare

Comparison of different Arduino libraries for WS2812 / NeoPixel LEDs
Arduino
1
star
85

ReflashBlinkM

Update or replace firmware in a BlinkM
Processing
1
star
86

WingShield

WingShield Industries makes Arduino shield kits, like the ScrewShield
1
star
87

node-tinynative

Smallest possible Node.js native module
C++
1
star
88

Blink1DotNet

C# library blink(1) .NET library for blink(1) devices connected to computer
C#
1
star
89

qtpy_midibff

QTPy MIDI BFF
1
star
90

qt-fun

qt-fun
C++
1
star
91

TrinketTouringMachine

Eurorack modules based around Trinket M0
C++
1
star
92

PWM-Tests

1
star
93

BlinkMNet

A network of Arduino-connected BlinkMs
C++
1
star
94

electron-tray-test

Testing out Tray API in Electron, showing how click event does not work on MacOSX
JavaScript
1
star
95

mp3thing

mp3 player controller for cheap commercial screenless mp3 players
Arduino
1
star
96

CrashSpaceStatus

The "AtCrashSpace" app written using Apache Cordova
JavaScript
1
star
97

todbot.github.com

1
star
98

BlinkM-Arduino

Official BlinkM Arduino library and examples by ThingM
C++
1
star
99

CircuitPython_TouchPIO

Capacitive touch sensing using Pico / RP2040 PIO, using touchio API
Python
1
star