Issues with Pywinusb.hid in Python: Unable to Send Feature Reports

89 views Asked by At

I'm working on a Python script using pywinusb.hid to interact with an HID device. I'm attempting to send feature reports to control the device, but I seem to be encountering issues. Here's a snippet of my code:

import pywinusb.hid as hid

devices = hid.HidDeviceFilter(vendor_id=0x54C, product_id=0x5C4).get_devices()
device = devices[0]
device.open()
device.send_feature_report([0x08, 0x40, 0x00, 0x00])  # Disconnect command
device.send_feature_report([0x04, 0xFF, 0x00, 0x00])  # Red color
device.send_feature_report([0x01, 0x03, 0xFF, 0xFF])  # Enable vibration
input()
device.close()

I'm encountering issues with the feature reports, and I'm not sure why. The code runs without errors, but the device doesn't seem to respond as expected. Any insights or suggestions on how to troubleshoot and resolve this issue would be greatly appreciated.

1

There are 1 answers

0
Can Perçin On

I guess your problem might be related with async processing. Your code worked but response wasn't immediate. You can check pywinusb.hid.ReadInputReport. You can use ReadInputReport to obtain input reports from the device if it sends them after processing feature reports. This feature halt your script until a report is received, which would essentially synchronize communication to some degree.