File tree Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 1212- Raise a descriptive error when the ` Car ` class can't find a steering mechanism
1313 end stop within 10 seconds ([ support #1564 ] ).
1414
15+ ### Fixed
16+ - Fixed hubs not shutting down when holding hub button ([ support #1419 ] ).
17+
18+ [ support#1419 ] : https://github.com/pybricks/support/issues/1419
1519[ support#1564 ] : https://github.com/pybricks/support/issues/1564
1620[ support#1574 ] : https://github.com/pybricks/support/issues/1574
1721
Original file line number Diff line number Diff line change @@ -331,10 +331,8 @@ void pbsys_main_run_program(pbsys_main_program_t *program) {
331331 }
332332 #endif // PYBRICKS_OPT_COMPILER
333333
334- // Ensure all buffered output has been sent over the air.
335- mp_hal_stdout_tx_flush ();
336-
337- // Clean up non-MicroPython resources used by the pybricks package.
334+ // De-init bluetooth resources (including flushing stdout) that may use
335+ // memory allocated by MicroPython before we wipe it.
338336 pb_package_pybricks_deinit ();
339337
340338 gc_sweep_all ();
Original file line number Diff line number Diff line change 1212
1313#include <pbdrv/bluetooth.h>
1414#include <pbio/version.h>
15+ #include <pbsys/bluetooth.h>
16+ #include <pbsys/status.h>
1517
1618#include <pybricks/common.h>
1719#include <pybricks/hubs.h>
@@ -146,8 +148,13 @@ void pb_package_pybricks_deinit(void) {
146148 // tasks and deinit tasks have completed.
147149 static pbio_task_t noop_task ;
148150 pbdrv_bluetooth_queue_noop (& noop_task );
149- while (noop_task .status == PBIO_ERROR_AGAIN ) {
151+ while (noop_task .status == PBIO_ERROR_AGAIN || ! pbsys_bluetooth_tx_is_idle () ) {
150152 MICROPY_VM_HOOK_LOOP
153+
154+ // Stop waiting (and potentially blocking) in case of forced shutdown.
155+ if (pbsys_status_test (PBIO_PYBRICKS_STATUS_SHUTDOWN_REQUEST )) {
156+ break ;
157+ }
151158 }
152159 #endif
153160}
You can’t perform that action at this time.
0 commit comments