You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RFC: to include hidapitester as it is a very useful tool for debugging #285
hidtest is using a test device based on modified Microchip Simple HID demo. It can be kept as an example but not that useful as a test tool for the project.
Only issue to include hidapitester is probably the GPL 3 license, which may or may not be a problem. I do not see it as a problem. But if some people see it as a problem, we can ask @todbot to see if he is willing to change the license.
Just FYI on the original hidtest, it is based on Microchip Demo FW (part of Microchip USB Stack) but I do not know if Alan Ott published the modified FW or not.
With the original FW (04d8:003f), here is the output.
Device Found
type: 04d8 003f
path: \\?\hid#vid_04d8&pid_003f#e&24ba9f4d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Simple HID Device Demo
Release: 2
Interface: -1
Usage (page): 0x1 (0xff00)
Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Unable to read serial number string
Serial Number String: (0)
Indexed String 1: Microchip Technology Inc.
Unable to send a feature report.
Unable to get a feature report.
Incorrect function.waiting...
Data read:
81 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Press any key to continue . . .
With the enhancement for hidtest, it is of course worth to keep it now. But still I think hidapitester is a worthy add-on for the hidapi project as it is useful for different type of HID devices.
With the libusb test code, here is the output. Take note I purposefully send one more byte.
$ ./libusb1_lvrhid8.exe
Successfully find the LVR Generic HID device
Successfully set usb configuration 1
Successfully claimed MYINTERFACE
Testing control transfer using loop back test of feature report
03, 04; 21, 21; 22, 22; 23, 00;
Testing control transfer using loop back test of input/output report
02, 01; 31, 31; 32, 32; 33, 00;
Testing interrupt transfer using loop back test of input/output report
02, 01; 41, 41; 42, 42; 43, 00;
@todbot It seems to me that hidapitester report reading of one more bytes for the Feature report under Windows. Not so sure if this is a problem with hidapitester or hidapi under Windows. If it is related to hidapi under Windows, the test gui seems to be correct. That is strange.
hidapitester is using hidapi directly, and not doing anything platform-specific. If there's a byte miscount, I think it's either in the testgui or the build of hidapitester you're using uses a hidapi with off-by-one errors (this used to exist in hidapi for certain situations, I forget the details at the moment)
@todbot In the end I think hidapitester is good.
The issue is probably for feature report under Windows. Shall we report one more byte so that data will not be truncated? Or shall we discard the first byte (report id 0) to be consistent with the input report under Windows and other OS (edit: this may not be correct, please refer to the comments below)?
Now I start to question the following commit which I proposed in #232 with regard to feature report. It may be correct when the report id is not zero but may not be correct when the report id is zero. It seems to me for Windows, we may need to read one more byte when the report id is zero. 6fcb0bb
That is at least a reasonable interpretation of the documentation for hid_get_input_report. However, the same text appears in hid_get_feature_report which, in turn, seems to have conflicting implementations:
When looking into #229, I noticed that the behavior of hid_get_feature_report when report IDs are not used is not as clear as I thought, and perhaps not even well defined.
My recommendation is to discard the report id 0 for feature report under Windows, to be consistent with input report handing under Windows, and also other OS.
Edit: this may not be correct. From the Linux hidapitester output, indeed there is a difference in dealing with input report the feature report. Not so sure if this is because of API difference or real different on the wire.
changed the title [-]RFC: change hidtest to an example and potentially include hidapitester[/-][+]RFC: to include hidapitester as it is a very useful tool for debugging[/+]on Aug 31, 2021
Activity
mcuee commentedon Jun 15, 2021
Only issue to include hidapitester is probably the GPL 3 license, which may or may not be a problem. I do not see it as a problem. But if some people see it as a problem, we can ask @todbot to see if he is willing to change the license.
mcuee commentedon Jun 16, 2021
@todbot How do you like the idea of including hidapitester in HIDAPI project?
todbot commentedon Jun 16, 2021
Sounds great to me
todbot commentedon Jun 16, 2021
I can change the license to whatever is most useful
mcuee commentedon Jun 16, 2021
HIDAPI license:
https://github.com/libusb/hidapi/blob/master/LICENSE.txt
hidapitester is already licensed under GPL3, just need to add the other two licenses.
mcuee commentedon Jun 17, 2021
Just FYI on the original hidtest, it is based on Microchip Demo FW (part of Microchip USB Stack) but I do not know if Alan Ott published the modified FW or not.
With the original FW (04d8:003f), here is the output.
mcuee commentedon Jul 24, 2021
With the enhancement for hidtest, it is of course worth to keep it now. But still I think hidapitester is a worthy add-on for the hidapi project as it is useful for different type of HID devices.
mcuee commentedon Aug 27, 2021
Example run log of hidapitester with a modified Lakeview Research Generic HID example.
FW: https://github.com/mcuee/picusb/tree/master/lvr_genhid_mod
Device: input report ID 1, output report ID 2, feature in report id 3 and feature output report id 4.
From the run log, it seems that my FW sent an extra byte for the Feature IN report. But I need to check again under different OS.
With the libusb test code, here is the output. Take note I purposefully send one more byte.
mcuee commentedon Aug 27, 2021
HIDAPI Test GUI seems to say the FW is correct.

mcuee commentedon Aug 27, 2021
Test under Linux (Raspberry Pi 400), hidapitester performs fine (tested with the hidraw backend).
mcuee commentedon Aug 27, 2021
@todbot It seems to me that hidapitester report reading of one more bytes for the Feature report under Windows. Not so sure if this is a problem with hidapitester or hidapi under Windows. If it is related to hidapi under Windows, the test gui seems to be correct. That is strange.
todbot commentedon Aug 27, 2021
hidapitester is using hidapi directly, and not doing anything platform-specific. If there's a byte miscount, I think it's either in the testgui or the build of hidapitester you're using uses a hidapi with off-by-one errors (this used to exist in hidapi for certain situations, I forget the details at the moment)
5 remaining items
mcuee commentedon Aug 28, 2021
@todbot In the end I think hidapitester is good.
The issue is probably for feature report under Windows. Shall we report one more byte so that data will not be truncated? Or shall we discard the first byte (report id 0) to be consistent with the input report under Windows and other OS (edit: this may not be correct, please refer to the comments below)?
mcuee commentedon Aug 28, 2021
Now I start to question the following commit which I proposed in #232 with regard to feature report. It may be correct when the report id is not zero but may not be correct when the report id is zero. It seems to me for Windows, we may need to read one more byte when the report id is zero.
6fcb0bb
mcuee commentedon Aug 28, 2021
@Youw : please take a look as well for the feature report. Thanks.
Ref:
#229 (comment)
liquidctl/liquidctl#312
mcuee commentedon Aug 28, 2021
My recommendation is to discard the report id 0 for feature report under Windows, to be consistent with input report handing under Windows, and also other OS.
Edit: this may not be correct. From the Linux hidapitester output, indeed there is a difference in dealing with input report the feature report. Not so sure if this is because of API difference or real different on the wire.
mcuee commentedon Aug 28, 2021
Output under Linux:
Output under macOS (Mac Mini M1, macOS Big Sur ARM64), same as Linux.
mcuee commentedon Aug 28, 2021
Linux test gui is consistent with hidapitester

mcuee commentedon Aug 28, 2021
Hopefully other Windows users can chime in and test latest git of hidapi to see if there is a real issue for the feature report or not.
mcuee commentedon Aug 28, 2021
Just tried hidapitester with hidapi-0.10.1 release and hidapi git head, with regard to input report, the result is the same since it is using hid_read_timeout(). So #232 does not matter in that case.
https://github.com/todbot/hidapitester/blob/master/hidapitester.c#L379
With regard to feature report, then the result will be different as it uses hid_get_feature_report(). So commit 6fcb0bb does matter for getting the feature report. In this particular case without report id (report id zero), it seems to me the commit is not correct.
https://github.com/todbot/hidapitester/blob/master/hidapitester.c#L403
mcuee commentedon Aug 28, 2021
For those with report id, commit 6fcb0bb seems to be correct.
mcuee commentedon Aug 30, 2021
Here is a quick hack of hidapitester with libusb backend (todbot/hidapitester#8)
With patched libusb-1.0.dll (libusb/libusb#986), it works fine.
hidapitester_mingw64_libusb.zip
It also works fine with devices with report ids (my mod FW of the above generic hid example from Jan Axelson).
mcuee commentedon Aug 30, 2021
All in all, hidapitester is okay. But we may need to fix hidapi under Windows, for reading of feature report. Therefore I have created an issue #328.
[-]RFC: change hidtest to an example and potentially include hidapitester[/-][+]RFC: to include hidapitester as it is a very useful tool for debugging[/+]mcuee commentedon Apr 25, 2022
I will close this as hidapitester is already mentioned in hidapi README.md.
https://github.com/libusb/hidapi/blob/master/README.md