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

embedded_io::ReadReady/WriteReady not implemented for uart peripheral #836

Open
1 of 2 tasks
antbern opened this issue Aug 22, 2024 · 1 comment
Open
1 of 2 tasks

Comments

@antbern
Copy link
Contributor

antbern commented Aug 22, 2024

I am working on a project where I need to do some non-blocking reading from the uart peripheral based on the embedded_io traits. The regular Read trait specifies a blocking read such that it will wait for at least one byte to be available to be read. If one wants to do a non-blocking read, you need to use the ReadReady trait function read_ready to first check if there is data available before doing the read.

However, only the Read trait is implemented (in #727 and #781 ) for the split and unsplit peripherals, but not the ReadReady trait. Is there a reason this has been left out?

It looks like the implementation could be quite simple, something like this for the Reader split peripheral (not tested):

impl<D: UartDevice, P: ValidUartPinout<D>> embedded_io::ReadReady for Reader<D, P> {
    fn read_ready(&mut self) -> Result<bool, Self::Error> {
        Ok(is_readable(self.device))
    }
}

Fixed in:

@ithinuel
Copy link
Member

It might be simply because no one needed it before. Feel free to open a PR :)

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