File tree Expand file tree Collapse file tree 2 files changed +22
-11
lines changed
examples/HID/hid_generic_inout Expand file tree Collapse file tree 2 files changed +22
-11
lines changed Original file line number Diff line number Diff line change 15
15
*
16
16
* There are 2 ways to test the sketch
17
17
* 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
28
36
*/
29
37
30
38
#include " Adafruit_TinyUSB.h"
Original file line number Diff line number Diff line change 12
12
if dev :
13
13
while True :
14
14
# 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' )
16
19
dev .write (str_out )
17
20
str_in = dev .read (64 )
18
21
print ("Received from HID Device:" , str_in , '\n ' )
You can’t perform that action at this time.
0 commit comments