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

feature request: embedded_io_async::try_read #601

Closed
dvdsk opened this issue May 15, 2024 · 2 comments
Closed

feature request: embedded_io_async::try_read #601

dvdsk opened this issue May 15, 2024 · 2 comments

Comments

@dvdsk
Copy link

dvdsk commented May 15, 2024

Usecase
Catching up to a byte stream when lagging behind without waiting for new bytes to come in. Such as getting the last 10 bytes received.

Example:
Library code using a uart buffered by the Hal implementation (like with embassy). A read call is done with a buffer of 100 bytes. It may return 100 bytes read. Is the last byte in the buffer the last that was received?

A second read call could block forever so we can only guess. The only way to be certain is to ensure buffer provided to read is larger then what was provided to the bufferd uart.

Alternatives:
Could join on a near zero delay and a read. This should work but is less readable (the intent is less clear).

@Dirbaio
Copy link
Member

Dirbaio commented May 15, 2024

You can use ReadReady for this.

@dvdsk
Copy link
Author

dvdsk commented May 15, 2024

Totally missed that, thanks for pointing it out!

@dvdsk dvdsk closed this as completed May 15, 2024
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

No branches or pull requests

2 participants