Hi,
I'm a new to USB/HID development.
I need to interact with a HID-device.
I've followed the way decribed in "USB Complete" book (ch.11) for finding my device and getting a handler for him.
The handler is good as I can use it with HidP_GetCaps function.
But when I try to send some bytes with calling WriteFile to my device I get 87 error (parameter is incorrect).
Frankly I don't fully understand all this concepts of report id/report types/pipes/collections etc. But I used a sniffer tool to get interaction log with my device (when it's used from some proprietary software). This tool is BusDog. I also tried USB Monitor (Device Monitoring Studio) but it's more complex.
I can see in the BusDog's log the following bytes when the device is used from proprietary software:
0b 04... and some vendor specific payload
Then tried to send exactly such bytes from my program:
var bytes = new byte[] { 0x0b, 0x04, 0x2f, 0x7a, 0x77, 0x0d, 0, 0 };
bool success = NativeMethods.WriteFile(m_hDevice, bytes,
bytes.Length,
ref numberOfBytesWritten,
IntPtr.Zero);
I tried adding 0x00 byte at the begging.
I tried allocate 64-bytes array. Tried to get OutputReportByteLength from HidP_GetCaps (it equals
.
But in all cases WriteFile fails with 87 error.
Any ideas?
update: I also tried allocate 65 byte length buffer and first zero.