Skip to content

Enhance HID_SendReport method signature #2014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
richardatsap opened this issue Apr 15, 2014 · 3 comments
Open

Enhance HID_SendReport method signature #2014

richardatsap opened this issue Apr 15, 2014 · 3 comments
Assignees
Labels
feature request A request to make an enhancement (not a bug fix) Library: HID The HID Arduino library

Comments

@richardatsap
Copy link

HID_SendReport (USBAPI.h and HID.cpp) does not return any value, although the underlying implementation uses USBSend which returns the number of bytes or -1 if failed. I suggest changing the signature of HID_SendReport to return an int value to enable consumers to detect error conditions.

I'd be willing to do the change in a pull request. Unfortunately I can't discuss that on the mailing list as I do not have a Google account (and I am not willing to get one ;-)).

@NicoHood
Copy link
Contributor

I'd say its not really needed. This only increases ram. The return value might be needed for other libs like cdc (not sure) because the usb function is more general. You can simply test if in this case the usb function would ever return -1, i believe it wont. Maybe if the decice is disconnected (havent actually looked in the code again).

I am working on a lot of USB updates. I am just searching through all issues and pull requests and collect and implement them all together. If you want to help, let me know.

@richardatsap
Copy link
Author

The reason why I am asking is the following: I am trying to implement digital rotary knobs, which, due to the receiving application, must be implemented as joystick buttons. On turning these knobs fast, generating more than 20 updates per second, Windows chokes on the events silently dropping some of the updates. The events are definitely being sent by the Arduino however I'd like to check whether the number of bytes sent have really the expected value. Therefore I not only need the -1 (which might be helpful anyway) but also the exact number of bytes sent.

I am not too familiar with C(++) therefore it is not exactly clear to me how this would waste RAM if you don't check the value. The compiler should drop the value in this case (i.e. not put it on the stack).

@NicoHood
Copy link
Contributor

A correction: i mean flash, no ram, sorry.

USB HID can send up to 1000 reports / second. more isnt possible. and as far as i know the sending always flushes and the bytes sent is ALWAYS the size of the report + report ID. Cause you can only send a full USB bank, not a half. The sending of the bank could fail but well i dont think this will happen. just set an led when it would return -1 and simply test it.

@facchinm facchinm reopened this Sep 21, 2015
@cmaglie cmaglie added Library: HID The HID Arduino library feature request A request to make an enhancement (not a bug fix) labels Sep 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A request to make an enhancement (not a bug fix) Library: HID The HID Arduino library
Projects
None yet
Development

No branches or pull requests

4 participants