From b460d6dc4706b9ade1c2f5bb06d3fdb07c07c343 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Tue, 1 Oct 2024 16:38:04 +0200 Subject: [PATCH] bricks/_common_stm32: Run pool hook on print if disconnected. Fixes certain tight loops with f-strings locking up the hub when disconnected. Fixes https://github.com/pybricks/support/issues/1668 --- CHANGELOG.md | 2 ++ bricks/_common_stm32/mphalport.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d4df1227..ead41ae2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,8 +14,10 @@ from `3.6.0b1` to `3.5.0` and back to `3.6.0b1` ([support#1846]). - Fixed controls stopping if `use_gyro` is called again with the same argument as already active ([support#1858]). +- Fixed lockup and reboot with f-strings in tight loops ([support#1668]). [support#1623]: https://github.com/pybricks/support/issues/1623 +[support#1668]: https://github.com/pybricks/support/issues/1668 [support#1846]: https://github.com/pybricks/support/issues/1846 [support#1858]: https://github.com/pybricks/support/issues/1858 diff --git a/bricks/_common_stm32/mphalport.c b/bricks/_common_stm32/mphalport.c index d2a2fc30c..19356583d 100644 --- a/bricks/_common_stm32/mphalport.c +++ b/bricks/_common_stm32/mphalport.c @@ -138,13 +138,13 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) { continue; } + MICROPY_EVENT_POLL_HOOK + if (err != PBIO_ERROR_AGAIN) { // Ignoring error for now. This means stdout lost if Bluetooth is // disconnected. return; } - - MICROPY_EVENT_POLL_HOOK } }