Skip to content

Commit

Permalink
pbio/sys/program_stop: Drop hack to stop Bluetooth.
Browse files Browse the repository at this point in the history
We have an old hack that shuts down the bluetooth process. When starting a new task after that in a cleanup routine such as added in 04fd2e7, the hub will never finish the task, which prevents the user program from stopping.

We have several proper fixes in place now, and we are about to merge some updates that will make all Bluetooth task objects static, so we should remove this hack.

Fixes pybricks/support#1438
  • Loading branch information
laurensvalk committed Feb 11, 2024
1 parent b42da81 commit c4fb3dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
- Added `pybricks.iodevices.XboxController` ([support#191], [support#1024]).
- Re-enable `pybricks.iodevices.LWP3Device` missing from last beta.

### Fixes
- Fix hub not shutting down while a program runs ([support#1438]).

### Changed
- On Technic Hub and City Hub, the Bluetooth chip is now configured to reject
connection parameter updates from peripherals. This avoids interference with
broadcast when used with the Xbox controller.

[support#191]: https://github.com/pybricks/support/issues/191
[support#1024]: https://github.com/pybricks/support/issues/1024
[support#1438]: https://github.com/pybricks/support/issues/1438

## [3.4.0b1] - 2023-11-24

Expand Down
6 changes: 0 additions & 6 deletions lib/pbio/sys/program_stop.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ static bool stop_button_pressed;
*/
void pbsys_program_stop(bool force_stop) {
if (pbsys_status_test(PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING)) {
if (force_stop) {
// HACK: Bluetooth drivers have issues with pending tasks not being
// cancellable, so this should force them to be canceled and avoid
// undefined behavior due to use after free.
pbdrv_bluetooth_power_on(false);
}
pbsys_main_stop_program(force_stop);
}
}
Expand Down

0 comments on commit c4fb3dd

Please sign in to comment.