summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2021-07-19 23:58:26 +0200
committerDamien George <damien@micropython.org>2021-07-25 17:11:03 +1000
commit2e62e13455780517047c32279fc8bf2812810602 (patch)
tree84293ac9218d7256931531ff360c405fe9f154c1
parentaecb697c72ac1fdb9f549daa5734e2ffbd37a6d3 (diff)
rp2/machine_uart: Fix poll ioctl to also check hardware FIFO.
The RX IRQ does not trigger if the FIFO is less than the trigger level, in which case characters may be available in the FIFO, yet not in the ringbuf, and the ioctl returns false.
-rw-r--r--ports/rp2/machine_uart.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ports/rp2/machine_uart.c b/ports/rp2/machine_uart.c
index c6206cebe..2431f496e 100644
--- a/ports/rp2/machine_uart.c
+++ b/ports/rp2/machine_uart.c
@@ -477,7 +477,7 @@ STATIC mp_uint_t machine_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint
if (request == MP_STREAM_POLL) {
uintptr_t flags = arg;
ret = 0;
- if ((flags & MP_STREAM_POLL_RD) && ringbuf_avail(&self->read_buffer) > 0) {
+ if ((flags & MP_STREAM_POLL_RD) && (uart_is_readable(self->uart) || ringbuf_avail(&self->read_buffer) > 0)) {
ret |= MP_STREAM_POLL_RD;
}
if ((flags & MP_STREAM_POLL_WR) && ringbuf_free(&self->write_buffer) > 0) {