diff --git a/rp2040-hal/src/uart.rs b/rp2040-hal/src/uart.rs index 6b46788..a842321 100644 --- a/rp2040-hal/src/uart.rs +++ b/rp2040-hal/src/uart.rs @@ -311,8 +311,8 @@ impl UartPeripheral { /// This function reads as long as it can. As soon that the FIFO is empty, if : /// - 0 bytes were read, a WouldBlock Error is returned /// - some bytes were read, it is deemed to be a success - /// Upon success, the remaining slice is returned. - pub fn read_raw<'b>(&self, buffer: &'b mut [u8]) -> nb::Result<&'b mut [u8], ReadError<'b>> { + /// Upon success, it will return how many bytes were read. + pub fn read_raw<'b>(&self, buffer: &'b mut [u8]) -> nb::Result> { let mut bytes_read = 0; Ok(loop { @@ -320,7 +320,7 @@ impl UartPeripheral { if bytes_read == 0 { return Err(WouldBlock); } else { - break &mut buffer[bytes_read..]; + break bytes_read; } } @@ -355,7 +355,7 @@ impl UartPeripheral { buffer[bytes_read] = read.data().bits(); bytes_read += 1; } else { - break &mut buffer[bytes_read..]; + break bytes_read; } }) } @@ -381,7 +381,7 @@ impl UartPeripheral { while offset != buffer.len() { offset += match self.read_raw(&mut buffer[offset..]) { - Ok(remaining) => remaining.len(), + Ok(bytes_read) => bytes_read, Err(e) => match e { Other(inner) => return Err(inner.err_type), WouldBlock => continue,