Skip to content

Commit

Permalink
rp2/machine_uart: Fix poll ioctl to also check hardware FIFO.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
iabdalkader authored and dpgeorge committed Jul 25, 2021
1 parent aecb697 commit 2e62e13
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ports/rp2/machine_uart.c
Expand Up @@ -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) {
Expand Down

0 comments on commit 2e62e13

Please sign in to comment.