diff options
| author | Scott Shawcroft <scott@adafruit.com> | 2020-03-26 12:59:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-26 12:59:36 -0700 |
| commit | e2785f9c5f4d0e08528525fca1af1aa7aa837521 (patch) | |
| tree | 28995e712d4fc601ac7d02c69db3bc9463194e44 | |
| parent | 59eb35da30c0141ce0b2eb5b9718d2a655f988ba (diff) | |
| parent | 18c12e782244c7dcdc95c0b09b9ddd365e9560f3 (diff) | |
Merge pull request #2732 from arturo182/mimxrt10xx_uart_fix
mimxrt10xx: Return proper UART read length when everything was read
| -rw-r--r-- | ports/mimxrt10xx/common-hal/busio/UART.c | 7 |
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. |
