Open skzvlad opened 5 years ago
I also meet the question . I solve the questsion after I browse the address https://stackoverflow.com/questions/37213634/createfilea-fails-to-open-hid-device-in-windows . After then, I am meeting the question about read buffer, which show code -1 that hid_read(handle, buf, sizeof(buf)) return .
If you are continuing to notice this topic , we can discuss togethor.
with CreateFileA's params, e.g. replacing GENERIC_READ | GENERIC_WRITE with STANDARD_RIGHTS_READ | STANDARD_RIGHTS_WRITE. But I can't knwo why.....
Only for Windows OS.
We should use "desired_access = GENERIC_READ" at the enumeration devices in the "open_device"-function. So a valid code for the "open_device"-function:
I have some USB HID devices that do not support the ability to send data and read data. The “CreateFile” function always fails (for these devices) when I try to use a non-empty “desired_access” (GENERIC_READ, GENERIC_WRITE, GENERIC_WRITE | GENERIC_READ, ...). But “CreateFile” return a "valid" handle (for these devices) when I use a empty “desired_access” (desired_access = 0) and "ReadFile"/"WriteFile" WInAPI functions always fails for this "valid" handle.