Skip to content

Commit 4e2f01c

Browse files
authored
Merge pull request #838 from jannic/fix_write
Let UART write return some bytes were written
2 parents 32a29e0 + 7a1a4fd commit 4e2f01c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

rp2040-hal/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ The Minimum-Supported Rust Version (MSRV) for the next release is 1.77
1616
- Support for *binary info*, which is metadata that `picotool` can read from your binary.
1717
- Bump MSRV to 1.77, because *binary info* examples need C-Strings.
1818

19+
### Fixed
20+
21+
- Let UART embedded\_io::Write::write return some bytes were written.
22+
1923
## [0.10.0] - 2024-03-10
2024

2125
### Added

rp2040-hal/src/uart/writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ impl<D: UartDevice, P: ValidUartPinout<D>> embedded_io::ErrorType for Writer<D,
214214

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

0 commit comments

Comments
 (0)