Closed holdersn closed 1 year ago
I've provided a pull request.
If interested, I could also change try.py to report the global error in its exception handling. Please let me know if I should do that.
I've provided a pull request.
If interested, I could also change try.py to report the global error in its exception handling. Please let me know if I should do that.
Please do - just add another commit to the PR branch and push. Thanks
Done.
Done
Thanks! Merged
device.error() is currently implemented to raise a ValueError if there is no device open. However, the C function being called can actually handle this case. If there is no device, it will report the last global error (which would typically be an error that occurred when trying to open a device).
Users of cython-hidapi should be able to retrieve these global errors as well. This would help a lot when diagnosing problems during open().
The change is easy: We just need to remove the null-check because the C code handles a NULL parameter by reporting the last global error.
For reference, here is the current implementaiton of device.error():
And here is the C code for hid_error():