Consider merging changes to test.c back into libusb/hidapi #168

Closed
lenniea wants to merge 16 commits from master into master
lenniea commented 2020-06-06 14:49:05 -05:00 (Migrated from github.com)

Review the (generic) changes I added to test.c (for testing arbitrary custom HID devices instead of hardcoding VID, PID, reports, etc.

Review the (generic) changes I added to test.c (for testing arbitrary custom HID devices instead of hardcoding VID, PID, reports, etc.
Youw commented 2020-06-09 06:41:30 -05:00 (Migrated from github.com)

Thanks for your effort!

test.c is intended to be a very simple example of the API usage, but with this change, it becomes too complicated I'd say. Most of the "example" becomes a int/hex/command-line converters which doesn't help its original purpose.

Instead, I'd rather leave this test as is, and recommend to use https://github.com/todbot/hidapitester.

Thanks for your effort! test.c is intended to be a _very simple_ example of the API usage, but with this change, it becomes too complicated I'd say. Most of the "example" becomes a int/hex/command-line converters which doesn't help its original purpose. Instead, I'd rather leave this test as is, and recommend to use https://github.com/todbot/hidapitester.
lenniea commented 2020-06-09 10:48:05 -05:00 (Migrated from github.com)

ok but I think its bad to have hardcoded vendor & product ids and
input/output reports in a test program like that. I attempted to get
basically the same API calls as the original without hardcoding
everything. The only "addition" I made was to support both 8-bit byte and
16-bit word formatting for a custom HID joystick interface.

-Lennie

On Tue, Jun 9, 2020 at 4:41 AM Ihor Dutchak notifications@github.com
wrote:

Thanks for your effort!

test.c is intended to be a very simple example of the API usage, but
with this change, it becomes too complicated I'd say. Most of the "example"
becomes a int/hex/command-line converters which doesn't help its original
intention.

Instead, I'd rather leave this test as is, and recommend to use
https://github.com/todbot/hidapitester.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/libusb/hidapi/pull/168#issuecomment-641235669, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAPCMHLHWHPNTHOZJ33CCP3RVYNXPANCNFSM4NWJ7NGA
.

ok but I think its bad to have hardcoded vendor & product ids and input/output reports in a test program like that. I attempted to get basically the same API calls as the original without hardcoding everything. The only "addition" I made was to support both 8-bit byte and 16-bit word formatting for a custom HID joystick interface. -Lennie On Tue, Jun 9, 2020 at 4:41 AM Ihor Dutchak <notifications@github.com> wrote: > Thanks for your effort! > > test.c is intended to be a *very simple* example of the API usage, but > with this change, it becomes too complicated I'd say. Most of the "example" > becomes a int/hex/command-line converters which doesn't help its original > intention. > > Instead, I'd rather leave this test as is, and recommend to use > https://github.com/todbot/hidapitester. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <https://github.com/libusb/hidapi/pull/168#issuecomment-641235669>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAPCMHLHWHPNTHOZJ33CCP3RVYNXPANCNFSM4NWJ7NGA> > . >
Youw commented 2020-06-09 11:13:18 -05:00 (Migrated from github.com)

My position - readability and simplicity in the example is the most value.

That hard-coded device was used by the original author years ago. I don't even know what that is, or does it exist at all.
I'd rather remove that part completely to make the example even simpler. When the bigger part of an example is a helper functions - it doesn't make it a good example.

My position - readability and simplicity in the _example_ is the most value. That hard-coded device was used by the original author years ago. I don't even know what that is, or does it exist at all. I'd rather remove that part completely to make the example even simpler. When the bigger part of an example is a helper functions - it doesn't make it a _good example_.
todbot commented 2020-06-09 14:27:42 -05:00 (Migrated from github.com)

Maybe for the example code, we use an extant, known piece of hardware that is easily and cheaply obtainable, and the VID/PID pair is known to be for development, not a commercial product. For this, I would recommend a Teensy 2.0 (USD 16.00) running the Teensy RawHID Basic example:
https://www.pjrc.com/teensy/rawhid.html
https://github.com/PaulStoffregen/Teensyduino_Examples/blob/master/USB_RawHID/Basic/Basic.pde
Even though there are more modern examples, the Teensy RawHID stuff has been around since at least 2010, so it's pretty familiar to anyone doing USB HID.

Maybe for the example code, we use an extant, known piece of hardware that is easily and cheaply obtainable, and the VID/PID pair is known to be for development, not a commercial product. For this, I would recommend a Teensy 2.0 (USD 16.00) running the Teensy RawHID Basic example: https://www.pjrc.com/teensy/rawhid.html https://github.com/PaulStoffregen/Teensyduino_Examples/blob/master/USB_RawHID/Basic/Basic.pde Even though there are more modern examples, the Teensy RawHID stuff has been around since at least 2010, so it's pretty familiar to anyone doing USB HID.

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi!168
No description provided.