summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarturo182 <arturo182@tlen.pl>2020-03-26 00:15:48 +0100
committerarturo182 <arturo182@tlen.pl>2020-03-26 00:15:48 +0100
commit18c12e782244c7dcdc95c0b09b9ddd365e9560f3 (patch)
tree28995e712d4fc601ac7d02c69db3bc9463194e44
parent59eb35da30c0141ce0b2eb5b9718d2a655f988ba (diff)
mimxrt10xx: Return proper UART read length when everything was read
-rw-r--r--ports/mimxrt10xx/common-hal/busio/UART.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c
index b34b948b2..4633507d8 100644
--- a/ports/mimxrt10xx/common-hal/busio/UART.c
+++ b/ports/mimxrt10xx/common-hal/busio/UART.c
@@ -270,9 +270,14 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
LPUART_TransferAbortReceive(self->uart, &self->handle);
}
+ // No data left, we got it all
+ if (self->handle.rxData == NULL) {
+ return len;
+ }
+
// The only place we can reliably tell how many bytes have been received is from the current
// wp in the handle (because the abort nukes rxDataSize, and reading it before abort is a race.)
- return self->handle.rxData-data;
+ return self->handle.rxData - data;
}
// Write characters.