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

Avoid discarding already read bytes on error #798

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jannic
Copy link
Member

@jannic jannic commented May 1, 2024

Closes: #782

It would be preferable to avoid the code duplication between UartPeripheral and Reader. However, before starting a bigger code restructuring, I'd like to get some feedback on the general approach:

  • Is it the right trade-off to reserve some memory in UartPeripheral and Reader to store the read error?
  • What are alternative approaches?
    • Ignore the issue, accept discarding bytes on error. (Might be acceptable, assuming that serial errors are rare and the received message is probably garbled anyway. Should be clearly documented.)
    • Don't implement embedded_io::Read at all. (Breaking change, lost functionality, IMHO not acceptable)
    • Don't implement embedded_io::Read directly on UartPeripheral and Reader, but instead on a separate wrapper type. (Breaking change, slightly less nice API, zero-cost when not using embedded_io::Read)

@jannic jannic marked this pull request as ready for review May 28, 2024 21:57
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.

embedded_io::serial::Reader implementations drop data on error
1 participant