Skip to content

Commit

Permalink
Let UART write return some bytes were written
Browse files Browse the repository at this point in the history
embedded_io::Write::write(buf) should not block until the full buffer
was written. Instead, it should only block until at least one byte
was written.
  • Loading branch information
jannic committed Aug 22, 2024
1 parent 32a29e0 commit 7a1a4fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions rp2040-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ The Minimum-Supported Rust Version (MSRV) for the next release is 1.77
- Support for *binary info*, which is metadata that `picotool` can read from your binary.
- Bump MSRV to 1.77, because *binary info* examples need C-Strings.

### Fixed

- Let UART embedded\_io::Write::write return some bytes were written.

## [0.10.0] - 2024-03-10

### Added
Expand Down
4 changes: 2 additions & 2 deletions rp2040-hal/src/uart/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ impl<D: UartDevice, P: ValidUartPinout<D>> embedded_io::ErrorType for Writer<D,

impl<D: UartDevice, P: ValidUartPinout<D>> embedded_io::Write for Writer<D, P> {
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write_full_blocking(buf);
Ok(buf.len())
let remaining = nb::block!(write_raw(&self.device, buf)).unwrap(); // Infallible
Ok(buf.len() - remaining.len())
}
fn flush(&mut self) -> Result<(), Self::Error> {
nb::block!(transmit_flushed(&self.device)).unwrap(); // Infallible
Expand Down

0 comments on commit 7a1a4fd

Please sign in to comment.