From c461d21136df52d615955d59387869173b57ae97 Mon Sep 17 00:00:00 2001 From: Derek Hageman Date: Sun, 16 Oct 2022 10:59:26 -0600 Subject: [PATCH] Fix UART read error discard data Limit the discarded data reference to the data that has actually been read so far, instead of the whole input buffer. Also fix a spelling error in the field name. --- rp2040-hal/src/uart/reader.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rp2040-hal/src/uart/reader.rs b/rp2040-hal/src/uart/reader.rs index 0528169..b4c9676 100644 --- a/rp2040-hal/src/uart/reader.rs +++ b/rp2040-hal/src/uart/reader.rs @@ -16,8 +16,8 @@ pub struct ReadError<'err> { /// The type of error pub err_type: ReadErrorType, - /// Reference to the data that was read but eventually discared because of the error. - pub discared: &'err [u8], + /// Reference to the data that was read but eventually discarded because of the error. + pub discarded: &'err [u8], } /// Possible types of read errors. See Chapter 4, Section 2 ยง8 - Table 436: "UARTDR Register" @@ -149,7 +149,7 @@ pub(crate) fn read_raw<'b, D: UartDevice>( if let Some(err_type) = error { return Err(Other(ReadError { err_type, - discared: buffer, + discarded: &buffer[..bytes_read], })); }