Skip to content

Commit

Permalink
bricks/_common_stm32: Run pool hook on print if disconnected.
Browse files Browse the repository at this point in the history
Fixes certain tight loops with f-strings locking up the hub when disconnected.

Fixes pybricks/support#1668
  • Loading branch information
laurensvalk committed Oct 1, 2024
1 parent 68a59ef commit b460d6d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions bricks/_common_stm32/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit b460d6d

Please sign in to comment.