-
Notifications
You must be signed in to change notification settings - Fork 397
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
README: Add warning about writing data to HID products #106
Conversation
README.md
Outdated
@@ -139,6 +142,10 @@ int main(int argc, char* argv[]) | |||
} | |||
``` | |||
|
|||
You can also use [hidtest/hidtest.c](https://github.com/libusb/hidapi/blob/master/hidtest/hidtest.c) | |||
as a starting point for your programmes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
programs
instead of programmes
? I know it's a bit British vs American English but it's more fitting in this context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applications
;)
README.md
Outdated
which communicates with a heavily hacked up version of the Microchip USB | ||
Generic HID sample looks like this (with error checking removed for | ||
simplicity): | ||
|
||
`Warning: Only run the code you understand, only against devices which firmware | ||
you control. Writing data at random to your HID devices can break them.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use *s instead of `s, so to make it bold because it looks a bit weird in this preformatted style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only against devices which firmware
you control
This statement is a bit too strong - you may not nesessary control the FW, but safely write, e.g. if you have official spec, etc.
I was thinking, maybe add explicit check for dev/ven before hid_write in the example
In response to #105
da992d2
to
5817a67
Compare
@Youw done.
I think that would be too much, since to write to the device in the sample you have to enumerate devices, check vid/pid and hardcode it to the sample. Or do you mean interactive check like with |
I was thinking something like: #define SAMPLE_VEN_ID ...
#define SAMPLE_DEV_ID ...
unsigned short ven_id = SAMPLE_VEN_ID;
unsigned short dev_id = SAMPLE_DEV_ID;
int main(/*...*/) {
if (argc /* ... */ ) {
// ...
ven_id = // parse arguments, etc.
// ...
}
handle = hid_open(ven_id, dev_id, NULL);
// ...
// a WARNING comment here, what we're know what we're doing, but only with a specific device
if (ven_id == SAMPLE_VEN_ID && dev_id == SAMPLE_DEV_ID) {
// ...
res = hid_write(handle, buf, 65);
// ...
}
// hid_close
// hid_exit
} So we can include #14 and a little more, like explicitly encourage to Maybe this is a little too large change, but anyway nice to have. |
@Youw thanks for your comments, I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and let's merge it after #115
Co-Authored-By: Ihor Dutchak <ihor.youw@gmail.com>
In response to #105