Giter Site home page Giter Site logo

hidapitester's Introduction

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-usages               List HID devices w/ usages (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
  --get-report-descriptor     Get the report descriptor
  --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                Read Input reports
  --read-input-forever        Read Input reports in a loop forever
  --read-input-report <reportId>  Read Input report from specific reportId
  --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 commmand 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

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 <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, 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:

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

hidapitester's People

Contributors

alexanderdickson avatar andypiper avatar dentrax avatar katyo avatar poomaster avatar todbot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hidapitester's Issues

What's the expected result for Test-Hardware?

Hey,
so I'm trying hidapitester on Windows 10 with an Arduino Pro Micro and the supplied Test-Code for the Arduino Micro.
I am able to send and receive regular reports, but no feature reports (wrote -1 bytes).

> hidapitester.exe --vidpid 1b4f:9206 --open --get-report-descriptor 
Opening device, vid/pid: 0x1B4F/0x9206
Report Descriptor:
 06 C0 FF 0A 00 0C A1 01 09 01 15 00 26 FF 00 75 08 95 40 81 02 09 02 15 00 26 FF 00 75 08 95 40
 91 02 C0
Closing device

> hidapitester.exe --vidpid 1b4f:9206 --open -t 2000 --read-input
Opening device, vid/pid: 0x1B4F/0x9206
Reading 64-byte input report 0, 2000 msec timeout...read 64 bytes:
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
Closing device

> hidapitester.exe --vidpid 1b4f:9206 --open -l 2 --send-output 0,1 
Opening device, vid/pid: 0x1B4F/0x9206
Writing output report of 2-bytes...wrote 65 bytes:
 00 01
Closing device

> hidapitester.exe --vidpid 1b4f:9206 --open -l 2 --send-feature 0,1 
Opening device, vid/pid: 0x1B4F/0x9206
Writing 2-byte feature report...wrote -1 bytes:
 00 01
Closing device

Is this expected? Or should I be able to send feature reports?

Docs read

The sketch recives 64-byte Output or Feature reports, and prints them to Serial Monitor

So I guess not being able to send a feature report is an issue?

Getting the same result on 3 different Windows 10 PCs.

Different output after building on MacOS

Hi,

I have rebuilt hidapitester so that it uses latest version of hidapi, and I get different results, don't really undersatnd why.

Moreover, latest release on Monterey needs to be run with sudo to open a device in bluetooth (I was hoping that rebuilding with latest version would prevent that).

Any idea ? (I am trying to play with switching channel on logitech products, it works through unify, can't make it work in bluetooth however).

Results for latest hidapitester release:

imac-de-nico:hidapitester nico$ ./hidapitester --list
05AC/8294: Broadcom Corp. - Bluetooth USB Host Controller
046D/C52B: Logitech - USB Receiver
046D/C52B: Logitech - USB Receiver
046D/C52B: Logitech - USB Receiver
046D/C52B: Logitech - USB Receiver
046D/C52B: Logitech - USB Receiver
046D/C52B: Logitech - USB Receiver
0000/0000:  - Apple Mikey HID Driver
05AC/8294: Broadcom Corp. - Bluetooth USB Host Controller
05AC/8294: Broadcom Corp. - Bluetooth USB Host Controller
046D/C52B: Logitech - USB Receiver
046D/C52B: Logitech - USB Receiver
046D/C52B: Logitech - USB Receiver
imac-de-nico:hidapitester nico$ ./hidapitester -vidpid 046D/C52B --list-detail
hidapitester: invalid option -- i
hidapitester: invalid option -- d
hidapitester: invalid option -- p
hidapitester: invalid option -- i
hidapitester: invalid option -- d
05AC/8294: Broadcom Corp. - Bluetooth USB Host Controller
  vendorId:      0x05AC
  productId:     0x8294
  usagePage:     0x0001
  usage:         0x0002
  serial_number:  
  interface:     1 
  path: DevSrvsID:4294968342

05AC/8294: Broadcom Corp. - Bluetooth USB Host Controller
  vendorId:      0x05AC
  productId:     0x8294
  usagePage:     0x0001
  usage:         0x0001
  serial_number:  
  interface:     1 
  path: DevSrvsID:4294968342

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0x0001
  usage:         0x0006
  serial_number:  
  interface:     0 
  path: DevSrvsID:4294968380

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0x0001
  usage:         0x0002
  serial_number:  
  interface:     1 
  path: DevSrvsID:4294968387

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0x0001
  usage:         0x0001
  serial_number:  
  interface:     1 
  path: DevSrvsID:4294968387

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0x000C
  usage:         0x0001
  serial_number:  
  interface:     1 
  path: DevSrvsID:4294968387

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0x0001
  usage:         0x0080
  serial_number:  
  interface:     1 
  path: DevSrvsID:4294968387

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0xFFBC
  usage:         0x0088
  serial_number:  
  interface:     1 
  path: DevSrvsID:4294968387

0000/0000:  - Apple Mikey HID Driver
  vendorId:      0x0000
  productId:     0x0000
  usagePage:     0x000C
  usage:         0x0001
  serial_number:  
  interface:     -1 
  path: DevSrvsID:4294968463

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0xFF00
  usage:         0x0001
  serial_number:  
  interface:     2 
  path: DevSrvsID:4294968403

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0xFF00
  usage:         0x0002
  serial_number:  
  interface:     2 
  path: DevSrvsID:4294968403

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0xFF00
  usage:         0x0004
  serial_number:  
  interface:     2 
  path: DevSrvsID:4294968403

05AC/8294: Broadcom Corp. - Bluetooth USB Host Controller
  vendorId:      0x05AC
  productId:     0x8294
  usagePage:     0x0001
  usage:         0x0006
  serial_number:  
  interface:     0 
  path: DevSrvsID:4294968390

Results with rebuilded version :

mac-de-nico:logiSwitch nico$ ./hidapitester --list
046D/C52B: Logitech - USB Receiver
0000/0000:  - Apple Mikey HID Driver
05AC/8294: Broadcom Corp. - Bluetooth USB Host Controller
05AC/8294: Broadcom Corp. - Bluetooth USB Host Controller
046D/C52B: Logitech - USB Receiver
046D/C52B: Logitech - USB Receiver
imac-de-nico:logiSwitch nico$ ./hidapitester -vidpid 046D/C52B --list-detail
hidapitester: invalid option -- i
hidapitester: invalid option -- d
hidapitester: invalid option -- p
hidapitester: invalid option -- i
hidapitester: invalid option -- d
05AC/8294: Broadcom Corp. - Bluetooth USB Host Controller
  vendorId:      0x05AC
  productId:     0x8294
  usagePage:     0x0001
  usage:         0x0006
  serial_number:  
  interface:     0 
  path: IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC1@14/XHC1@14000000/HS06@14500000/Bluetooth USB Host Controller@14500000/IOUSBHostInterface@0/AppleUserUSBHostHIDDevice

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0x0001
  usage:         0x0006
  serial_number:  
  interface:     0 
  path: IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC1@14/XHC1@14000000/HS04@14300000/USB Receiver@14300000/IOUSBHostInterface@0/AppleUserUSBHostHIDDevice

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0x0001
  usage:         0x0002
  serial_number:  
  interface:     1 
  path: IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC1@14/XHC1@14000000/HS04@14300000/USB Receiver@14300000/IOUSBHostInterface@1/AppleUserUSBHostHIDDevice

0000/0000:  - Apple Mikey HID Driver
  vendorId:      0x0000
  productId:     0x0000
  usagePage:     0x000C
  usage:         0x0001
  serial_number:  
  interface:     -1 
  path: IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SBUS@1F,4/AppleSMBusPCI/BUS0@0/AppleSMBusControllerICH/MKY0/AppleMikeyDriver/AppleMikeyHIDDriver

05AC/8294: Broadcom Corp. - Bluetooth USB Host Controller
  vendorId:      0x05AC
  productId:     0x8294
  usagePage:     0x0001
  usage:         0x0002
  serial_number:  
  interface:     1 
  path: IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC1@14/XHC1@14000000/HS06@14500000/Bluetooth USB Host Controller@14500000/IOUSBHostInterface@1/AppleUserUSBHostHIDDevice

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0xFF00
  usage:         0x0001
  serial_number:  
  interface:     2 
  path: IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC1@14/XHC1@14000000/HS04@14300000/USB Receiver@14300000/IOUSBHostInterface@2/AppleUserUSBHostHIDDevice

How to read a different Input Report other than Input Report 0?

I have an HID device that implements Input Report ID 22 with 48 bytes. Is it possible to just request an input report read from this Input Report ID 22?

hidapitester --vidpid 0483:5751 --open -l 48 --read-input 22

This command seems to only read from Input Report 0. The [Report ID] seems to be ignored.

Filter by Serial Number

I have two USB devices connected that share identical VID, PID, usagePage, usage, and path. The only difference between them when I use --list-detail is the serial_number.

Would it be possible to filter by serial_number to send output to a device?

i can't open the keyboard device on macOS Sonoma

This is the information on the keyboard

# hidapitester --list-detail

046D/B367: Logitech - MX MCHNCL M
  vendorId:      0x046D
  productId:     0xB367
  usagePage:     0x0001
  usage:         0x0006


046D/B367: Logitech - MX MCHNCL M
  vendorId:      0x046D
  productId:     0xB367
  usagePage:     0x000C
  usage:         0x0001


046D/B367: Logitech - MX MCHNCL M
  vendorId:      0x046D
  productId:     0xB367
  usagePage:     0xFF43
  usage:         0x0202

but the error appears that the device cannot be opened

# hidapitester --vidpid 046D:B367 --usage 0x0202 --usagePage 0xFF43 --timeout 2000 --open --read-input-forever --length 11 --read-feature 1

Opening device, vid/pid:0x046D/0xB367, usagePage/usage: FF43/202
Error: could not open device
Error on read: no device opened.
Error on read: no device opened.

it works fine on Windows

Rawhid test device ProMicroRawHID Feature Report Problem

I have issues with the other example ProMicroRawHID in terms of Feature report.
https://github.com/todbot/hidapitester/tree/master/test_hardware/ProMicroRawHID

Reading input seems to be okay (I did the minor change to send 0x08 to 0x47. But the comments about 2s does not seem to be right. It seems to be once per second. Basically the code has been changed to 1s but the comment has not been updated.

Sending the output report seems to be okay as well since I can see the echo from Arduino terminal Window.

It does not seem to work when sending the feature report.

PS C:\work\hid\hidapitester> .\hidapitester --vidpid 2341:8037 --open --read-input-forever
Opening device, vid/pid: 0x2341/0x8037
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27
 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27
 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27
 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27
 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...

PS C:\work\hid\hidapitester> .\hidapitester --vidpid 2341:8037 --open --send-output 0x00,0x30,0x31
Opening device, vid/pid: 0x2341/0x8037
Writing output report of 64-bytes...wrote 65 bytes:
 00 30 31 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 00
Closing device

Arduino Serial Termainal echo
112115: sending packet
113116: sending packet
48
49
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
114117: sending packet
115118: sending packet
116119: sending packet
117120: sending packet

PS C:\work\hid\hidapitester> .\hidapitester --vidpid 2341:8037 --open --send-feature 0x00,0x30,0x31
Opening device, vid/pid: 0x2341/0x8037
Writing 64-byte feature report...wrote -1 bytes:
 00 30 31 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 00
Closing device

How to open the console command , hidapitester command not found

Hi

i'm on linux Ubuntu 16.04 and i'm trying to run the hidApiTester in my Terminal

i followed all step

1--
chakib@chakib-temal:/HIDTESTER$ git clone https://github.com/libusb/hidapi
Cloning into 'hidapi'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 2022 (delta 1), reused 1 (delta 0), pack-reused 2015
Receiving objects: 100% (2022/2022), 2.63 MiB | 1.60 MiB/s, done.
Resolving deltas: 100% (1311/1311), done.
Checking connectivity... done.
2--
chakib@chakib-temal:
/HIDTESTER$ git clone https://github.com/todbot/hidapitester
Cloning into 'hidapitester'...
remote: Enumerating objects: 101, done.
remote: Counting objects: 100% (101/101), done.
remote: Compressing objects: 100% (74/74), done.
remote: Total 101 (delta 53), reused 67 (delta 24), pack-reused 0
Receiving objects: 100% (101/101), 682.88 KiB | 0 bytes/s, done.
Resolving deltas: 100% (53/53), done.
Checking connectivity... done.
3--
chakib@chakib-temal:/HIDTESTER$ cd hidapitester
4--
chakib@chakib-temal:
/HIDTESTER/hidapitester$ ls
docs hidapitester.c hid_generic_trinketm0 LICENSE Makefile ProMicroRawHID README.md TeensyRawHid
5--
chakib@chakib-temal:~/HIDTESTER/hidapitester$ sudo make
gcc -I ../hidapi/hidapi -c ../hidapi/linux/hid.c -o ../hidapi/linux/hid.o
gcc -I ../hidapi/hidapi -c hidapitester.c -o hidapitester.o
gcc -I ../hidapi/hidapi ../hidapi/linux/hid.o hidapitester.o -o hidapitester pkg-config libudev --libs

there is any problem with my command make ? i don't have any specific terminal opened after this command
there is a command to open the terminal command hidApitester ?

Thank's

Add a Linux aarch64 build?

This would cover ARM64 devices like Apple Silicon running Asahi Linux as well as the dozens of Android and ChromeOS devices that run ARM64 chips that can run Linux via PRoot/Crostini/etc or natively via postmarketOS/Alpine/Debian/Fedora support of aarch64.

Report Error Output

When hidapitester fails to write, read, etc. (-1 returned), it would be good for it to output the error message obtained from hid_error(). even with the -v flag, I just get e.g. "wrote -1 bytes" - and the situations when I have encountered this in my own application using libusb have had different reasons for this failure, so the tool would be much more helpful if it can help quickly try different things and diagnose errors.

To support Apple Silicon M1

The Makefile may need to be updated to support Apple Silicon Macs.

mcuee@mcuees-Mac-mini hidapitester % make
gcc -I ../hidapi/hidapi -c ../hidapi/mac/hid.c -o ../hidapi/mac/hid.o
gcc -I ../hidapi/hidapi -c hidapitester.c -o hidapitester.o
gcc -I ../hidapi/hidapi ../hidapi/mac/hid.o hidapitester.o -o hidapitester -framework IOKit -framework CoreFoundation
Undefined symbols for architecture arm64:
  "_NSAppKitVersionNumber", referenced from:
      _hid_init in hid.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [hidapitester] Error 1

Are there any limitations for keyboards in Windows?

Hi,
I'm trying to work with my keyboard and this tool can read all properties, but seems it can't read/write data. Doesn't matter what I'm trying, I'm getting only zeroes for reading and -1 for writing. All other HID-related examples I found on github throws out -1 as well, so not sure if I'm doing something wrong or it just impossible.

Is it even possible to read/write data from/to active keyboard in Windows? My goal is to control RGB leds there, relying on this example.

Filter by Serial Number

I have two USB devices connected that share identical VID, PID, usagePage, usage, and path. The only difference between them when I use --list-detail is the serial_number.

Would it be possible to filter by serial_number to send output to a device?

Requires sudo to write

On the latest macOS iMac 2020 (intel).

Executing this command without sudo to switch Logi MX Master 3 to the first channel:
/usr/local/bin/hidapitester -v --vidpid 046D:B023 --usagePage 0x0001 --usage 0x0006 --open --length 20 --send-output "0x11,0x00,0x0A,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00"

Which results in:

Looking for vid/pid 0x046D / 0xB023 (1133 / 45091)
Set usagePage to 0x0001 (1)
Set usage to 0x0006 (6)
Opening device, vid/pid:0x046D/0xB023, usagePage/usage: 1/6
Error: could not open device
Set buflen to 20
Error on send: no device opened.

Executing the same command with sudo:
sudo /usr/local/bin/hidapitester -v --vidpid 046D:B023 --usagePage 0x0001 --usage 0x0006 --open --length 20 --send-output "0x11,0x00,0x0A,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00"

Works as expected:

Looking for vid/pid 0x046D / 0xB023 (1133 / 45091)
Set usagePage to 0x0001 (1)
Set usage to 0x0006 (6)
Opening device, vid/pid:0x046D/0xB023, usagePage/usage: 1/6
Device opened
Set buflen to 20
Writing output report of 20-bytes...wrote 20 bytes:
11 00 0A 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Closing device

I'm not sure how to make hidapitester work without sudo. Having to do sudo makes it not possible to use Shortcuts application.

Adding a new cmd CMD_READ_INPUT_ALT

From libusb/hidapi#229
This new CMD is to test hid_get_input_report.

diff --git a/hidapitester.c b/hidapitester.c
index b4ae3d9..8dcdbb5 100644
--- a/hidapitester.c
+++ b/hidapitester.c
@@ -84,6 +84,7 @@ enum {
     CMD_SEND_OUTPUT,
     CMD_SEND_FEATURE,
     CMD_READ_INPUT,
+       CMD_READ_INPUT_ALT,
     CMD_READ_FEATURE,
     CMD_READ_INPUT_FOREVER,
 };
@@ -204,6 +205,7 @@ int main(int argc, char* argv[])
          {"send-out",     required_argument, &cmd,   CMD_SEND_OUTPUT},
          {"send-feature", required_argument, &cmd,   CMD_SEND_FEATURE},
          {"read-input",   optional_argument, &cmd,   CMD_READ_INPUT},
+        {"read-input-alt",   optional_argument, &cmd,   CMD_READ_INPUT_ALT},
          {"read-in",      optional_argument, &cmd,   CMD_READ_INPUT},
          {"read-feature", required_argument, &cmd,   CMD_READ_FEATURE},
          {"read-input-forever",  optional_argument, &cmd,   CMD_READ_INPUT_FOREVER},
@@ -387,6 +389,22 @@ int main(int argc, char* argv[])
                         break;
                     }
                 } while( cmd == CMD_READ_INPUT_FOREVER );
+            }
+                       else if( cmd == CMD_READ_INPUT_ALT ) {
+
+                if( !dev ) {
+                    msg("Error on read: no device opened.\n"); break;
+                }
+                if( !buflen) {
+                    msg("Error on read: buffer length is 0. Use --len to specify.\n");
+                    break;
+                }
+                uint8_t report_id = (optarg) ? strtol(optarg,NULL,10) : 0;
+                buf[0] = report_id;
+                msg("Reading %d-byte input report using hid_get_input_report, report_id %d...",buflen, report_id);
+                res = hid_get_input_report(dev, buf, buflen);
+                msg("read %d bytes:\n",res);
+                printbuf(buf, buflen, print_base, print_width);
             }
             else if( cmd == CMD_READ_FEATURE ) {

Hardware Test reading ok, but writing?

Hello,
I hope I can ask something for the incredible testtool. It is not a direct error.
Maybe you can give me an example here.

I have a 4 channel relay module which is connected to Windows via USB as an HID device. NO Com Port but with VID and PID. My device is recognised as VID 5131 and PID 2007.

Micro USB 1_2_4 Kanal HID Relais Modul

I have found out with your tool how to read something.

Output

But writing may not work.

I would like to switch relay 1-4 on and off via command line.
I need a command line solution for windows. I will switch it on and oder a .bat File or script.
I can switch a relay with the original windows tool.

OrigTestTool

That's why I was able to find out how your tool reads it.
I have created an excel for this (see screenshot).

Excel

with hidapitester --vidpid 5131 --open --read-input-forever
this worked very well.

How could I now switch the first or second relay on or off?
Perhaps you have a tip for me.

A very big thank you
I'm not a programmer, so I stumbled across your great tool after a lot of searching.

ascii output mode

Could you please add an output mode that would interpret the 7-bit values as ASCII characters and discard the rest? That means instead of:

Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 04 00 00 48 65 6C 6C 6F 20 77 6F 72 6C 64 21 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

one would see

Hello world!

I know one could pipe the output to perl or awk to achieve this but having it integrated with the program would be really handy.

Adding FreeBSD support

I am able to get hidapitester working under FreeBSD but I am not good at modifying the Makefile.

uname --> FreeBSD
CC --> cc (FreeBSD clang)
LIBS --> -lusb -lpthread (FreeBSD libusb-1.0 needs to link with -lusb)

Packages to install in order to build (libusb-1.0 is part of FreeBSD base OS, so no need to install)

  1. cmake
  2. MAKE --> gmake
  3. pkg-config --> part of pkgconf package

I can use the following command line to build under FreeBSD.

cc -o hidapitester -I ../hidapi/hidapi ../hidapi/libusb/hid.c hidapitester.c -lusb -lpthread

how to change command and host packet.

I want to change my logitech mouse bluetooth host.

스크린샷 2023-02-23 오전 1 40 48
This is a request when change host from logitech flow

./hidapitester --vidpid 046D:B01B --usage 0x0001 --usagePage 0x0001 --open --length 4 --send-feature 40 --send-output 0x11,0x09,0x1e,0x01

This is my request.

스크린샷 2023-02-23 오전 2 10 53
But the packets are a little different.

스크린샷 2023-02-23 오전 2 10 09
I found that the difference is command and handle.
how can i change? pls T ^ T help me

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.