Code: Select all
import hid
from time import sleep
# List all connected HID devices
for device_dict in hid.enumerate():
keys = list(device_dict.keys())
keys.sort()
for key in keys:
print(f"{key}: {device_dict[key]}")
print()
vendor_id = 0x17a4
product_id = 0x0001
data = [0x91]
try:
with hid.Device(vendor_id, product_id) as h:
print(f'Device manufacturer: {h.manufacturer}')
print(f'Product: {h.product}')
print(f'Serial Number: {h.serial}')
h.write(bytes(data))
sleep(0.1)
data = h.read(64, timeout=1000)
if data:
print(data)
except Exception as e:
print(e)