Skip to content

Commit 78bb2d6

Browse files
committed
bricks/_common/micropython: Run event loop before raising exception.
This was initially removed in #298, but we are restoring it to be sure that it isn't a breaking change.
1 parent 9a6cc19 commit 78bb2d6

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

bricks/_common/micropython.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@
4040
// Implementation for MICROPY_EVENT_POLL_HOOK
4141
void pb_event_poll_hook(void) {
4242

43+
while (pbio_os_run_processes_once()) {
44+
}
45+
4346
mp_handle_pending(true);
4447

45-
pbio_os_run_while_idle();
48+
pbio_os_run_processes_and_wait_for_event();
4649
}
4750

4851
// callback for when stop button is pressed in IDE or on hub

bricks/virtualhub/mp_port.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,12 @@ void pb_virtualhub_port_deinit(void) {
8989
// Implementation for MICROPY_EVENT_POLL_HOOK
9090
void pb_event_poll_hook(void) {
9191

92+
while (pbio_os_run_processes_once()) {
93+
}
94+
9295
mp_handle_pending(true);
9396

94-
pbio_os_run_while_idle();
97+
pbio_os_run_processes_and_wait_for_event();
9598
}
9699

97100
pbio_os_irq_flags_t pbio_os_hook_disable_irq(void) {

lib/pbio/include/pbio/os.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ struct _pbio_os_process_t {
269269

270270
bool pbio_os_run_processes_once(void);
271271

272-
void pbio_os_run_while_idle(void);
272+
void pbio_os_run_processes_and_wait_for_event(void);
273273

274274
void pbio_os_request_poll(void);
275275

lib/pbio/src/os.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ bool pbio_os_run_processes_once(void) {
149149
* enter a low power mode when possible. It will sleep for at most one
150150
* millisecond.
151151
*/
152-
void pbio_os_run_while_idle(void) {
152+
void pbio_os_run_processes_and_wait_for_event(void) {
153153

154154
// Run the event loop until there is no more pending poll request.
155155
while (pbio_os_run_processes_once()) {

lib/pbio/sys/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ int main(int argc, char **argv) {
9595
#endif
9696

9797
// Drives all processes while we wait for user input.
98-
pbio_os_run_while_idle();
98+
pbio_os_run_processes_and_wait_for_event();
9999

100100
if (!pbsys_main_program_start_requested()) {
101101
continue;

0 commit comments

Comments
 (0)