summaryrefslogtreecommitdiff
path: root/examples/device
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2021-12-13 23:56:13 +0700
committerGitHub <[email protected]>2021-12-13 23:56:13 +0700
commitdd30f2c648b984949b858d7dcc914297985a20bb (patch)
tree89ca7fb06430ba2b47b9c95df5750151122d6ad2 /examples/device
parentbfb5e32e1fd5187ab7fb448066c63efda3aad50c (diff)
parentd097178ab06ce665972bc2f3222648784eba2f54 (diff)
Merge pull request #1243 from hathach/g4-nucleo
Add G4 support
Diffstat (limited to 'examples/device')
-rw-r--r--examples/device/hid_generic_inout/hid_test.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/examples/device/hid_generic_inout/hid_test.py b/examples/device/hid_generic_inout/hid_test.py
index a42930fb5..21fd3f421 100644
--- a/examples/device/hid_generic_inout/hid_test.py
+++ b/examples/device/hid_generic_inout/hid_test.py
@@ -1,20 +1,22 @@
# Install python3 HID package https://pypi.org/project/hid/
import hid
-USB_VID = 0xcafe
+# default is TinyUSB (0xcafe), Adafruit (0x239a), RaspberryPi (0x2e8a), Espressif (0x303a) VID
+USB_VID = (0xcafe, 0x239a, 0x2e8a, 0x303a)
-print("Openning HID device with VID = 0x%X" % USB_VID)
+print("VID list: " + ", ".join('%02x' % v for v in USB_VID))
-for dict in hid.enumerate(USB_VID):
- print(dict)
- dev = hid.Device(dict['vendor_id'], dict['product_id'])
- if dev:
- while True:
- # Get input from console and encode to UTF8 for array of chars.
- # 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')
+for vid in USB_VID:
+ for dict in hid.enumerate(vid):
+ print(dict)
+ dev = hid.Device(dict['vendor_id'], dict['product_id'])
+ if dev:
+ while True:
+ # Get input from console and encode to UTF8 for array of chars.
+ # 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')