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.
This commit is contained in:
parent
73f6b48676
commit
6378343bb3
@ -428,6 +428,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
|
|||||||
uint32_t recvd = 0;
|
uint32_t recvd = 0;
|
||||||
LPUART_TransferGetReceiveCount(self->uart, &self->handle, &recvd);
|
LPUART_TransferGetReceiveCount(self->uart, &self->handle, &recvd);
|
||||||
LPUART_TransferAbortReceive(self->uart, &self->handle);
|
LPUART_TransferAbortReceive(self->uart, &self->handle);
|
||||||
|
if (recvd == 0) {
|
||||||
|
*errcode = EAGAIN;
|
||||||
|
return MP_STREAM_ERROR;
|
||||||
|
}
|
||||||
return recvd;
|
return recvd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user