Skip to content
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

Add a backend for Silicon Labs CP2110/4 HID-to-UART bridge. #411

Merged
merged 1 commit into from
Aug 13, 2019

Conversation

Flameeyes
Copy link
Contributor

These two chips implement UART access via a HID protocol, which can be
implemented purely in user space. The protocol is documented by Silicon
Labs AN434:
https://www.silabs.com/documents/public/application-notes/AN434-CP2110-4-Interface-Specification.pdf

The backend is implemented based on cython-hidapi
(https://github.com/trezor/cython-hidapi), making it OS-independent, if a
bit awkward.

@zsquareplusc
Copy link
Member

could you move the complete code into serial/urlhandler/protocol_cp2110.py? I don't think that anyone would need to import serial.cp2110.

And there should probably be a note in documentation/url_handlers.rst mentioning the handler and that the hidapi module needs to be installed separately (i would not like to install that by default, but as option would be possible, via extras_require={'cp2210': [hidapi']} in setup.py).

I've also used HID here and did my own low-level access:
https://github.com/zsquareplusc/python-msp430-tools/blob/master/msp430/bsl5/hid.py#L84
hoever that does not (yet) support MacOSX

These two chips implement UART access via a HID protocol, which can be
implemented purely in user space. The protocol is documented by Silicon
Labs AN434:
https://www.silabs.com/documents/public/application-notes/AN434-CP2110-4-Interface-Specification.pdf

The backend is implemented based on cython-hidapi
(https://github.com/trezor/cython-hidapi), making it OS-independent, if a
bit awkward.
@Flameeyes
Copy link
Contributor Author

Thanks for the review!

Code moved and documentation and extras_require added.

I have implemented raw HID support myself before, and honestly it's sometimes nicer particularly with the ability to have a more rational path compared to hidapi. But the problem with that is that implementing select/timeout on it is more fragile than HIDAPI, which is why I'm not terribly keen on doing that here.

@zsquareplusc zsquareplusc merged commit 3a6ae5a into pyserial:master Aug 13, 2019
@zsquareplusc
Copy link
Member

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants