rp2/machine_uart: Fix event wait in uart.flush() and uart.read().

Do not wait in the worst case up to the timeout.

Fixes issue #13377.

Signed-off-by: robert-hh <robert@hammelrath.com>
This commit is contained in:
robert-hh 2024-01-07 17:53:53 +01:00 committed by Damien George
parent d5f3fcd935
commit 068aa28fc5
1 changed files with 2 additions and 2 deletions

View File

@ -483,7 +483,7 @@ STATIC mp_uint_t mp_machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t
return i; return i;
} }
} }
mp_event_wait_ms(timeout - elapsed); mp_event_handle_nowait();
} }
*dest++ = ringbuf_get(&(self->read_buffer)); *dest++ = ringbuf_get(&(self->read_buffer));
start = mp_hal_ticks_ms(); // Inter-character timeout start = mp_hal_ticks_ms(); // Inter-character timeout
@ -559,7 +559,7 @@ STATIC mp_uint_t mp_machine_uart_ioctl(mp_obj_t self_in, mp_uint_t request, uint
if (now >= timeout) { if (now >= timeout) {
break; break;
} }
mp_event_wait_ms((timeout - now) / 1000); mp_event_handle_nowait();
} }
*errcode = MP_ETIMEDOUT; *errcode = MP_ETIMEDOUT;
ret = MP_STREAM_ERROR; ret = MP_STREAM_ERROR;