Skip to content

Commit e2785f9

Browse files
authored
Merge pull request #2732 from arturo182/mimxrt10xx_uart_fix
mimxrt10xx: Return proper UART read length when everything was read
2 parents 59eb35d + 18c12e7 commit e2785f9

File tree

1 file changed

+6
-1
lines changed
  • ports/mimxrt10xx/common-hal/busio

1 file changed

+6
-1
lines changed

ports/mimxrt10xx/common-hal/busio/UART.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,14 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
270270
LPUART_TransferAbortReceive(self->uart, &self->handle);
271271
}
272272

273+
// No data left, we got it all
274+
if (self->handle.rxData == NULL) {
275+
return len;
276+
}
277+
273278
// The only place we can reliably tell how many bytes have been received is from the current
274279
// wp in the handle (because the abort nukes rxDataSize, and reading it before abort is a race.)
275-
return self->handle.rxData-data;
280+
return self->handle.rxData - data;
276281
}
277282

278283
// Write characters.

0 commit comments

Comments
 (0)