summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-08-09 22:57:11 +0700
committerhathach <[email protected]>2021-08-09 22:57:11 +0700
commit312fd5f839059773982378177beacae0bc28385c (patch)
tree948834bb4470bf5a2c871ee077b80bc73f524828 /examples
parent88f5c04fe0cde1cf04779a3cca0cc0e40f68ae67 (diff)
fix hid_test.py for hid inout to correctly preceeded with dummy reportID
add note for install hidapi on windows
Diffstat (limited to 'examples')
-rw-r--r--examples/device/hid_generic_inout/hid_test.py5
-rw-r--r--examples/device/hid_generic_inout/src/main.c26
2 files changed, 21 insertions, 10 deletions
diff --git a/examples/device/hid_generic_inout/hid_test.py b/examples/device/hid_generic_inout/hid_test.py
index c89d89062..a42930fb5 100644
--- a/examples/device/hid_generic_inout/hid_test.py
+++ b/examples/device/hid_generic_inout/hid_test.py
@@ -11,7 +11,10 @@ for dict in hid.enumerate(USB_VID):
if dev:
while True:
# Get input from console and encode to UTF8 for array of chars.
- str_out = input("Send text to HID Device : ").encode('utf-8')
+ # hid generic inout is single report therefore by HIDAPI requirement
+ # it must be preceeded with 0x00 as dummy reportID
+ str_out = b'\x00'
+ str_out += input("Send text to HID Device : ").encode('utf-8')
dev.write(str_out)
str_in = dev.read(64)
print("Received from HID Device:", str_in, '\n')
diff --git a/examples/device/hid_generic_inout/src/main.c b/examples/device/hid_generic_inout/src/main.c
index 65874f483..32185560e 100644
--- a/examples/device/hid_generic_inout/src/main.c
+++ b/examples/device/hid_generic_inout/src/main.c
@@ -36,16 +36,24 @@
*
* There are 2 ways to test the sketch
* 1. Using nodejs
- * - Install nodejs and npm to your PC
- * - Install excellent node-hid (https://github.com/node-hid/node-hid) by
- * $ npm install node-hid
- * - Run provided hid test script
- * $ node hid_test.js
+ * - Install nodejs and npm to your PC
*
- * 2. Using python hidRun
- * - Python and `hid` package is required, for installation please follow https://pypi.org/project/hid/
- * - Run provided hid test script to send and receive data to this device.
- * $ python3 hid_test.py
+ * - Install excellent node-hid (https://github.com/node-hid/node-hid) by
+ * $ npm install node-hid
+ *
+ * - Run provided hid test script
+ * $ node hid_test.js
+ *
+ * 2. Using python
+ * - Install `hid` package (https://pypi.org/project/hid/) by
+ * $ pip install hid
+ *
+ * - hid package replies on hidapi (https://github.com/libusb/hidapi) for backend,
+ * which already available in Linux. However on windows, you may need to download its dlls from their release page and
+ * copy it over to folder where python is installed.
+ *
+ * - Run provided hid test script to send and receive data to this device.
+ * $ python3 hid_test.py
*/
//--------------------------------------------------------------------+