Skip to content

Commit 6378343

Browse files
committed
As I mentioned in issue #6332,
there return of a read operation that times out with no data received is inconsistent: ``` Adafruit CircuitPython 7.3.0-beta.1-31-g73f6b4867-dirty on 2022-04-30; Adafruit Feather RP2040 with rp2040 >>> >>> import board, busio >>> print(board.UART().read(5)) None Adafruit CircuitPython 6.3.0 on 2021-06-01; FeatherS2 with ESP32S2 >>> import board,busio >>> print(board.UART().read(5)) None Adafruit CircuitPython 7.3.0-beta.1 on 2022-04-07; Adafruit Feather STM32F405 Express with STM32F405RG >>> import board, busio >>> print(board.UART().read(5)) None Adafruit CircuitPython 7.3.0-beta.1-31-g73f6b4867-dirty on 2022-04-28; Teensy 4.1 with IMXRT1062DVJ6A >>> import board, busio >>> print(board.UART().read(5)) b'' ``` Since I have a PR on this file anyway, I thought I would put in the change to make it consistent with the other 3 board types I tried. Can not say about any of the others.
1 parent 73f6b48 commit 6378343

File tree

1 file changed

+4
-0
lines changed
  • ports/mimxrt10xx/common-hal/busio

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
428428
uint32_t recvd = 0;
429429
LPUART_TransferGetReceiveCount(self->uart, &self->handle, &recvd);
430430
LPUART_TransferAbortReceive(self->uart, &self->handle);
431+
if (recvd == 0) {
432+
*errcode = EAGAIN;
433+
return MP_STREAM_ERROR;
434+
}
431435
return recvd;
432436
}
433437

0 commit comments

Comments
 (0)