Introduce port_yield()
This allows the web workflow send code to yield briefly when waiting for more room to send in a socket. Waiting for an "interrupt" could wait forever because the select task only waits for read and error. Adding wait on write is tricky because much of the time we don't care if the sockets are ready to write. Using yield avoids this trickiness.
This commit is contained in:
parent
471053c315
commit
f1053fb963
|
@ -345,9 +345,6 @@ void reset_port(void) {
|
|||
|
||||
reset_all_pins();
|
||||
|
||||
// A larger delay so the idle task can run and do any IDF cleanup needed.
|
||||
vTaskDelay(4);
|
||||
|
||||
#if CIRCUITPY_ANALOGIO
|
||||
analogout_reset();
|
||||
#endif
|
||||
|
@ -402,6 +399,9 @@ void reset_port(void) {
|
|||
#if CIRCUITPY_WATCHDOG
|
||||
watchdog_reset();
|
||||
#endif
|
||||
|
||||
// Yield so the idle task can run and do any IDF cleanup needed.
|
||||
port_yield();
|
||||
}
|
||||
|
||||
void reset_to_bootloader(void) {
|
||||
|
@ -492,6 +492,10 @@ void port_wake_main_task_from_isr() {
|
|||
}
|
||||
}
|
||||
|
||||
void port_yield() {
|
||||
vTaskDelay(4);
|
||||
}
|
||||
|
||||
void sleep_timer_cb(void *arg) {
|
||||
port_wake_main_task();
|
||||
}
|
||||
|
|
|
@ -109,6 +109,11 @@ void port_wake_main_task(void);
|
|||
// default weak implementation is provided that does nothing.
|
||||
void port_wake_main_task_from_isr(void);
|
||||
|
||||
// Some ports may use real RTOS tasks besides the background task framework of
|
||||
// CircuitPython. Calling this will yield to other tasks and then return to the
|
||||
// CircuitPython task when others are done.
|
||||
void port_yield(void);
|
||||
|
||||
// Some ports need special handling just after completing boot.py execution.
|
||||
// This function is called once while boot.py's VM is still valid, and
|
||||
// then a second time after the VM is finalized.
|
||||
|
|
|
@ -31,3 +31,6 @@ MP_WEAK void port_wake_main_task(void) {
|
|||
|
||||
MP_WEAK void port_wake_main_task_from_isr(void) {
|
||||
}
|
||||
|
||||
MP_WEAK void port_yield(void) {
|
||||
}
|
||||
|
|
|
@ -334,7 +334,7 @@ void web_workflow_send_raw(socketpool_socket_obj_t *socket, const uint8_t *buf,
|
|||
total_sent += sent;
|
||||
if (total_sent < len) {
|
||||
// Yield so that network code can run.
|
||||
port_idle_until_interrupt();
|
||||
port_yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue