Open Hal9000Space opened 3 years ago
Well I just answered by own question! I looked through the public methods in this repository and I saw the send_feature_report() method and tried it out. This is doing what I want. Some times we just need to summarize our question in writing and then we can answer our own question. Still curious what was wrong with my set_raw_data() example, but I'm not stuck on this anymore.
Set your buffer to be one bytes more (for the report ID).
https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/hidsdi/nf-hidsdi-hidd_setfeature
BOOLEAN HidD_SetFeature(
HANDLE HidDeviceObject,
PVOID ReportBuffer,
ULONG ReportBufferLength
);
ReportBufferLength
[in] Specifies the size, in bytes, of the report buffer. The report buffer must be large
enough to hold the feature report -- excluding its report ID, if report IDs are used
-- plus one additional byte that specifies a nonzero report ID or zero.
This is a current design limitation, currently, the HID class doesn't keep an internal feature type so find_feature_reports
just returns a generic report, hence, send
assumes the default output
report.
I think your example code makes sense, it should be supported.
This is a current design limitation, currently, the HID class doesn't keep an internal feature type so
find_feature_reports
just returns a generic report, hence,send
assumes the defaultoutput
report.
Interesting. Looking at the codes it does seem to differentiate feature report with output report, but maybe I am wrong. https://github.com/rene-aguirre/pywinusb/blob/master/pywinusb/hid/core.py
Hi,
First of all allow me to say thanks for maintaining this repository. It saves me a ton of work!
On Linux I use the usb library (import usb) along with the controlMsg() method for the device to send data, and this works for the particular device. On Windows 10 I'm importing the pywinusb.hid library and trying to send the same type of data. My first attempt was to use the set_raw_data() and send() methods of a feature report to send data to a device, as I did not know if there was a controlMsg() equivalent function in pywinusb. I see the data on the USB bus with my analyzer, but the last byte of the given transaction is always set to zero (0x00). The buffer for this feature report (0xE4) is 263 bytes long, which represents 256 bytes of data plus a 7 byte header.
How can I send the 263 byte data buffer without corruption? Is there another method I should be using?
Thank you.
Here is one transaction worth of data, the last byte should not be zero.
Here is a snippet of my Python code. The 'size' parameter from the hid caps does match the buffer size (263) in the case.