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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

stm32/usart: impl {eio, eio_async}::Read for Uart, UartRx #2185

Closed
wants to merge 1 commit into from

Conversation

tcbennun
Copy link
Contributor

Hopefully self-explanatory. 馃檪

@Dirbaio
Copy link
Member

Dirbaio commented Nov 14, 2023

The raw Uart can't impl embedded_io::Read for a few reasons:

  • It is is unbuffered, this means it can only receive while the task is actively waiting on a .read().await call. Data that's received between read calls is lost. The embedded_io::Read contract requires that data is not so easily lost, drivers using it can assume that.
  • It must return early if less than buf.len() bytes are received. Drivers can call read() with a buffer bigger than the data they're expecting (for example, if they don't know the size of the data in advance) and get back a partially filled buffer with the data that arrived and process that. With this impl, they'd hang instead.

if you want embedded_io::Read there's BufferedUartRx (irq-driven) or RingBufferedUartRx (dma-driven), which do extra fancy things to fulill the embedded-io contract.

@tcbennun
Copy link
Contributor Author

Gotcha. Worth a shot.

Might look at impling the ring-buffered driver for GPDMA then

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