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

USB: CDC adds set line coding callback #25613

Closed
xiongyihui opened this issue May 26, 2020 · 6 comments
Closed

USB: CDC adds set line coding callback #25613

xiongyihui opened this issue May 26, 2020 · 6 comments
Labels
area: USB Universal Serial Bus

Comments

@xiongyihui
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Want to create a USB to UART application, but no API to find out when the baud rate is changed

Describe the solution you'd like
May provide an API to register callbacks similar to USB HID callbacks

Describe alternatives you've considered
Or add a weak function to cdc_acm_class_handle_req, then we can override it.

@jfischer-no
Copy link
Collaborator

Or add a weak function to cdc_acm_class_handle_req, then we can override it.

This approach is not acceptable and not necessary.
Please use uart_line_ctrl_get from UART API, see samples/subsys/usb/cdc_acm

@jfischer-no jfischer-no added area: USB Universal Serial Bus question labels May 26, 2020
@xiongyihui
Copy link
Contributor Author

uart_line_ctrl_get() is OK if the USB CDC is opened once. But if the USB CDC is opened with a different baud rate at the second time, we don't know it.

@jfischer-no
Copy link
Collaborator

yes you have to poll it periodically.

@xiongyihui
Copy link
Contributor Author

Polling it periodically is not a good way. Maybe poll it when having new data to receive or to send.
But I still prefer an event-driven way to do that.

@jfischer-no
Copy link
Collaborator

But I still prefer an event-driven way to do that.

Well the UART API does not provide that and usually baudrate does not change in the middle of a communication. To place an app hook in the processing of the control or class request or make it weak for a specific and not generic reason it not acceptable. Actually it is a bad API extension and will always make a problem during internal stack rework or redesign. It would also cause unnecessary latency and security issues. It is also not comparable wit HID because CDC ACM is self-contained implementation with clearly defined user interface (UART API).

@xiongyihui
Copy link
Contributor Author

OK. I'd try it in my branch anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus
Projects
None yet
Development

No branches or pull requests

2 participants