canio: Run background tasks while waiting for message reception
Closes: #5004
This commit is contained in:
parent
5b0009cbc4
commit
cabe96e188
@ -30,6 +30,8 @@
|
|||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
|
|
||||||
|
#include "lib/utils/interrupt_char.h"
|
||||||
|
|
||||||
#include "common-hal/canio/__init__.h"
|
#include "common-hal/canio/__init__.h"
|
||||||
#include "common-hal/canio/Listener.h"
|
#include "common-hal/canio/Listener.h"
|
||||||
#include "shared-bindings/canio/Listener.h"
|
#include "shared-bindings/canio/Listener.h"
|
||||||
@ -356,6 +358,11 @@ mp_obj_t common_hal_canio_listener_receive(canio_listener_obj_t *self) {
|
|||||||
if (supervisor_ticks_ms64() > deadline) {
|
if (supervisor_ticks_ms64() > deadline) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
RUN_BACKGROUND_TASKS;
|
||||||
|
// Allow user to break out of a timeout with a KeyboardInterrupt.
|
||||||
|
if (mp_hal_is_interrupted()) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
} while (!common_hal_canio_listener_in_waiting(self));
|
} while (!common_hal_canio_listener_in_waiting(self));
|
||||||
}
|
}
|
||||||
int index = self->hw->RXFS.bit.F0GI;
|
int index = self->hw->RXFS.bit.F0GI;
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
|
|
||||||
|
#include "lib/utils/interrupt_char.h"
|
||||||
|
|
||||||
#include "common-hal/canio/__init__.h"
|
#include "common-hal/canio/__init__.h"
|
||||||
#include "common-hal/canio/Listener.h"
|
#include "common-hal/canio/Listener.h"
|
||||||
#include "shared-bindings/canio/Listener.h"
|
#include "shared-bindings/canio/Listener.h"
|
||||||
@ -272,6 +274,11 @@ mp_obj_t common_hal_canio_listener_receive(canio_listener_obj_t *self) {
|
|||||||
if (supervisor_ticks_ms64() > deadline) {
|
if (supervisor_ticks_ms64() > deadline) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
RUN_BACKGROUND_TASKS;
|
||||||
|
// Allow user to break out of a timeout with a KeyboardInterrupt.
|
||||||
|
if ( mp_hal_is_interrupted() ) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
} while (!common_hal_canio_listener_in_waiting(self));
|
} while (!common_hal_canio_listener_in_waiting(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user