Skip to content

Commit 1500c19

Browse files
committed
fix hid_test.py preceeded with 0x00 as dummy reportID
update comment for how to install hidapi on windows
1 parent 4b84b22 commit 1500c19

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

examples/HID/hid_generic_inout/hid_generic_inout.ino

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,24 @@
1515
*
1616
* There are 2 ways to test the sketch
1717
* 1. Using nodejs
18-
* - Install nodejs and nmp to your PC
19-
* - Install execellent node-hid (https://github.com/node-hid/node-hid) by
20-
* $ npm install node-hid
21-
* - Run provided hid test script
22-
* $ node hid_test.js
23-
*
24-
* 2. Using python hidRun
25-
* - Python and `hid` package is required, for installation please follow https://pypi.org/project/hid/
26-
* - Run provided hid test script to send and receive data to this device.
27-
* $ python3 hid_test.py
18+
* - Install nodejs and npm to your PC
19+
*
20+
* - Install excellent node-hid (https://github.com/node-hid/node-hid) by
21+
* $ npm install node-hid
22+
*
23+
* - Run provided hid test script
24+
* $ node hid_test.js
25+
*
26+
* 2. Using python
27+
* - Install `hid` package (https://pypi.org/project/hid/) by
28+
* $ pip install hid
29+
*
30+
* - hid package replies on hidapi (https://github.com/libusb/hidapi) for backend,
31+
* which already available in Linux. However on windows, you may need to download its dlls from their release page and
32+
* copy it over to folder where python is installed.
33+
*
34+
* - Run provided hid test script to send and receive data to this device.
35+
* $ python3 hid_test.py
2836
*/
2937

3038
#include "Adafruit_TinyUSB.h"

examples/HID/hid_generic_inout/hid_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
if dev:
1313
while True:
1414
# Get input from console and encode to UTF8 for array of chars.
15-
str_out = input("Send text to HID Device : ").encode('utf-8')
15+
# hid generic inout is single report therefore by HIDAPI requirement
16+
# it must be preceeded with 0x00 as dummy reportID
17+
str_out = b'\x00'
18+
str_out += input("Send text to HID Device : ").encode('utf-8')
1619
dev.write(str_out)
1720
str_in = dev.read(64)
1821
print("Received from HID Device:", str_in, '\n')

0 commit comments

Comments
 (0)