aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/ClassDriver/GenericHID/HostTestApp/test_generic_hid_libusb.py
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2018-01-07 18:38:01 +1100
committerDean Camera <dean@fourwalledcubicle.com>2018-01-07 18:38:01 +1100
commitbf630b3add2ed197ec4c9f94f06d4dec4281d09d (patch)
treeb26d041e87bdbd86bb4cca1744e8e9d6c3ebd6b9 /Demos/Device/ClassDriver/GenericHID/HostTestApp/test_generic_hid_libusb.py
parent021bad3105a1ae07fff8289f2f5bfe57b7e6c684 (diff)
downloadlufa-bf630b3add2ed197ec4c9f94f06d4dec4281d09d.tar.gz
lufa-bf630b3add2ed197ec4c9f94f06d4dec4281d09d.tar.bz2
lufa-bf630b3add2ed197ec4c9f94f06d4dec4281d09d.zip
Update other PyWinUSB Python host scripts to use the hidapi library.
Diffstat (limited to 'Demos/Device/ClassDriver/GenericHID/HostTestApp/test_generic_hid_libusb.py')
-rwxr-xr-xDemos/Device/ClassDriver/GenericHID/HostTestApp/test_generic_hid_libusb.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/Demos/Device/ClassDriver/GenericHID/HostTestApp/test_generic_hid_libusb.py b/Demos/Device/ClassDriver/GenericHID/HostTestApp/test_generic_hid_libusb.py
index a540a2c67..8da8ad767 100755
--- a/Demos/Device/ClassDriver/GenericHID/HostTestApp/test_generic_hid_libusb.py
+++ b/Demos/Device/ClassDriver/GenericHID/HostTestApp/test_generic_hid_libusb.py
@@ -22,13 +22,9 @@ from time import sleep
import usb.core
import usb.util
-# Generic HID device VID, PID and report payload length (length is increased
-# by one to account for the Report ID byte that must be pre-pended)
-device_vid = 0x03EB
-device_pid = 0x204F
def get_and_init_hid_device():
- device = usb.core.find(idVendor=device_vid, idProduct=device_pid)
+ device = usb.core.find(idVendor=0x03EB, idProduct=0x204F)
if device is None:
sys.exit("Could not find USB device.")
@@ -46,6 +42,7 @@ def get_and_init_hid_device():
return device
+
def send_led_pattern(device, led1, led2, led3, led4):
# Report data for the demo is LED on/off data
report_data = [led1, led2, led3, led4]
@@ -62,11 +59,13 @@ def send_led_pattern(device, led1, led2, led3, led4):
print("Sent LED Pattern: {0}".format(report_data))
+
def receive_led_pattern(hid_device):
endpoint = hid_device[0][(0,0)][0]
report_data = hid_device.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize)
return list(report_data)
+
def main():
hid_device = get_and_init_hid_device()