Closed presscot closed 2 years ago
According to the attached Report Descriptor, there is only an input report with ID 4, but not an feature report with this ID.
Therefore the response on Windows seems to be the correct one.
Which backend do you use on Linux, hidraw or libusb? I wonder why Linux does not return a proper error here.
You should use hid_get_feature_report for report 1-3 of this device, and hid_get_input_report or hid_read for report 4 & 5 of this device.
I wonder why Linux does not return a proper error here
As far as I know, Windows is the only backend that checks requested reports with HID descriptor. WinAPI validates all report requests.
Maybe macOS and hidraw does something similar (at least those backends could do so - it is up to OS implementation).
Libusb definitely doesn't perform any validations. HIDAPI just sends corresponding USB requests to the device, and device may choose to handle those, even if HID descriptor doesn't contain the information about the requested report.
Fist of all Thank You @JoergAtGithub and @Youw for response.
I want to connect to the device via node-hid based on hidapi. However, I did some tests using different libraries, here are the results:
On Ubuntu 20.04:
On Windows10:
Example for libusb 1.0.24:
unsigned char reportId = 4;
rc = libusb_init(&context); // return LIBUSB_SUCCESS
count = libusb_get_device_list(context, &devs);
// foreach and select device
rc = libusb_open(device, &dev_handle); // return LIBUSB_SUCCESS
rc = libusb_claim_interface(dev_handle, 0); // return LIBUSB_SUCCESS
rc = libusb_control_transfer(
dev_handle,
LIBUSB_ENDPOINT_IN + LIBUSB_REQUEST_TYPE_CLASS + LIBUSB_RECIPIENT_INTERFACE,
0x01,
reportId + (0x03 << 8),
0,
buf, size, 5000);
// return -1 LIBUSB_ERROR_IO; for id higher or equal than 4, works well for ID 1,2,3
Example for libusb-win32-1.2.6.0:
usb_init();
usb_find_busses();
usb_find_devices();
// foreach and select device
dev_handle = usb_open(dev);
usb_claim_interface(dev_handle, 0);
ret = usb_control_msg(
dev_handle,
USB_ENDPOINT_IN + USB_TYPE_CLASS + USB_RECIP_INTERFACE,
0x01,
reportId + (0x03 << 8),
0,
buf, size, 5000);
// works with each reportId and returns length of response
Installing additional drivers for libusb-win32-1.2.6.0 is problematic so i would like to use hidapi or libusb. Therefore, I would like to ask you for help if it is possible to skip the descriptor checking when sending a feature report, or if is possible to introduce a corrected descriptor in fly. Is the only option to stay with libusb-win32?
Thank you in advance for your help!!
You must use the correct API commands in your code! These are hid_get_feature_report for report 1-3 of this device, and hid_get_input_report (or hid_read) for report 4 & 5 of this device.
You must use the correct API commands in your code! These are hid_get_feature_report for report 1-3 of this device, and hid_get_input_report (or hid_read) for report 4 & 5 of this device.
I forgot to write that I also tested the hid_get_feature_report functions, unfortunately without success. Besides, there is a lot of functionality in feature report ID higher than 6. I just think the descryptor is invalid.
skip the descriptor checking
That check is performed by Windows HID driver, not by HIDAPI - so it is not possible.
if is possible to introduce a corrected descriptor in fly
Not possible - not supported by HID standard, nor by any of the driver/implementation.
If you need "different reports" depending on some current state of the device - use a single report, and write your own protocol on top of it. E.g.: byte[0] - fixed report ID, byte[1] - your "dynamic report ID" (other bytes - additional payload, if needed).
Closing this as there are no further updates.
On linux everything works fine and receives well results. ReportId from 1 to 254 works fine. Unfortunately, on windows only get results for Report from id 1 to 3. Report id 4 on linux returns correct results and the device responds. Unfortunately on windows the device does not respond and the result is incorrect. For example:
linux:
windows:
Please help me. I have a ready-made application written in the Electron running on linux, but unfortunately the principals only depend on the windows version.
Cheers Patryk