mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #1817 from openmv/exception_fixes
ports/All: Improve script execution and exception handling.
This commit is contained in:
commit
27db34d8d5
@ -1 +1 @@
|
|||||||
Subproject commit 01a75d8501bc60e969d7fb4c1096c208693a2609
|
Subproject commit 887c134328f75d46215b85275af8eccbc46afd9d
|
||||||
@ -86,6 +86,11 @@ vstr_t *usbdbg_get_script()
|
|||||||
return &script_buf;
|
return &script_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool usbdbg_is_busy()
|
||||||
|
{
|
||||||
|
return cmd != USBDBG_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
void usbdbg_set_script_running(bool running)
|
void usbdbg_set_script_running(bool running)
|
||||||
{
|
{
|
||||||
script_running = running;
|
script_running = running;
|
||||||
|
|||||||
@ -55,6 +55,7 @@ void usbdbg_init();
|
|||||||
void usbdbg_wait_for_command(uint32_t timeout);
|
void usbdbg_wait_for_command(uint32_t timeout);
|
||||||
bool usbdbg_script_ready();
|
bool usbdbg_script_ready();
|
||||||
vstr_t *usbdbg_get_script();
|
vstr_t *usbdbg_get_script();
|
||||||
|
bool usbdbg_is_busy();
|
||||||
bool usbdbg_get_irq_enabled();
|
bool usbdbg_get_irq_enabled();
|
||||||
void usbdbg_set_irq_enabled(bool enabled);
|
void usbdbg_set_irq_enabled(bool enabled);
|
||||||
void usbdbg_set_script_running(bool running);
|
void usbdbg_set_script_running(bool running);
|
||||||
|
|||||||
@ -296,10 +296,9 @@ soft_reset:
|
|||||||
nlr_buf_t nlr;
|
nlr_buf_t nlr;
|
||||||
|
|
||||||
if (nlr_push(&nlr) == 0) {
|
if (nlr_push(&nlr) == 0) {
|
||||||
// enable IDE interrupt
|
// Enable IDE interrupt
|
||||||
usbdbg_set_irq_enabled(true);
|
usbdbg_set_irq_enabled(true);
|
||||||
|
|
||||||
//__WFI();
|
|
||||||
// run REPL
|
// run REPL
|
||||||
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
|
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
|
||||||
if (pyexec_raw_repl() != 0) {
|
if (pyexec_raw_repl() != 0) {
|
||||||
@ -320,35 +319,37 @@ soft_reset:
|
|||||||
if (nlr_push(&nlr) == 0) {
|
if (nlr_push(&nlr) == 0) {
|
||||||
// Enable IDE interrupt
|
// Enable IDE interrupt
|
||||||
usbdbg_set_irq_enabled(true);
|
usbdbg_set_irq_enabled(true);
|
||||||
|
|
||||||
// Execute the script.
|
// Execute the script.
|
||||||
pyexec_str(usbdbg_get_script(), true);
|
pyexec_str(usbdbg_get_script(), true);
|
||||||
|
// Disable IDE interrupts
|
||||||
|
usbdbg_set_irq_enabled(false);
|
||||||
nlr_pop();
|
nlr_pop();
|
||||||
} else {
|
} else {
|
||||||
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
|
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (usbdbg_is_busy() && nlr_push(&nlr) == 0) {
|
||||||
|
// Enable IDE interrupt
|
||||||
|
usbdbg_set_irq_enabled(true);
|
||||||
|
// Wait for the current command to finish.
|
||||||
|
usbdbg_wait_for_command(1000);
|
||||||
|
// Disable IDE interrupts
|
||||||
|
usbdbg_set_irq_enabled(false);
|
||||||
|
nlr_pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usbdbg_wait_for_command(1000);
|
|
||||||
|
|
||||||
usbdbg_set_irq_enabled(false);
|
|
||||||
|
|
||||||
mp_deinit();
|
|
||||||
|
|
||||||
printf("MPY: soft reboot\n");
|
printf("MPY: soft reboot\n");
|
||||||
|
|
||||||
#if MICROPY_PY_AUDIO
|
#if MICROPY_PY_AUDIO
|
||||||
py_audio_deinit();
|
py_audio_deinit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BLUETOOTH_SD
|
#if BLUETOOTH_SD
|
||||||
sd_softdevice_disable();
|
sd_softdevice_disable();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MICROPY_BOARD_DEINIT)
|
#if defined(MICROPY_BOARD_DEINIT)
|
||||||
MICROPY_BOARD_DEINIT();
|
MICROPY_BOARD_DEINIT();
|
||||||
#endif
|
#endif
|
||||||
|
mp_deinit();
|
||||||
goto soft_reset;
|
goto soft_reset;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -267,16 +267,24 @@ soft_reset:
|
|||||||
usbdbg_set_irq_enabled(true);
|
usbdbg_set_irq_enabled(true);
|
||||||
// Execute the script.
|
// Execute the script.
|
||||||
pyexec_str(usbdbg_get_script(), true);
|
pyexec_str(usbdbg_get_script(), true);
|
||||||
|
// Disable IDE interrupts
|
||||||
|
usbdbg_set_irq_enabled(false);
|
||||||
nlr_pop();
|
nlr_pop();
|
||||||
} else {
|
} else {
|
||||||
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
|
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (usbdbg_is_busy() && nlr_push(&nlr) == 0) {
|
||||||
|
// Enable IDE interrupt
|
||||||
|
usbdbg_set_irq_enabled(true);
|
||||||
|
// Wait for the current command to finish.
|
||||||
|
usbdbg_wait_for_command(1000);
|
||||||
|
// Disable IDE interrupts
|
||||||
|
usbdbg_set_irq_enabled(false);
|
||||||
|
nlr_pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usbdbg_wait_for_command(1000);
|
|
||||||
|
|
||||||
usbdbg_set_irq_enabled(false);
|
|
||||||
|
|
||||||
mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n");
|
mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n");
|
||||||
#if MICROPY_PY_AUDIO
|
#if MICROPY_PY_AUDIO
|
||||||
py_audio_deinit();
|
py_audio_deinit();
|
||||||
|
|||||||
@ -607,25 +607,35 @@ soft_reset:
|
|||||||
if (usbdbg_script_ready()) {
|
if (usbdbg_script_ready()) {
|
||||||
nlr_buf_t nlr;
|
nlr_buf_t nlr;
|
||||||
if (nlr_push(&nlr) == 0) {
|
if (nlr_push(&nlr) == 0) {
|
||||||
|
// Enable IDE interrupts
|
||||||
|
usbdbg_set_irq_enabled(true);
|
||||||
|
#if OMV_ENABLE_WIFIDBG && MICROPY_PY_WINC1500
|
||||||
|
wifidbg_set_irq_enabled(openmv_config.wifidbg);
|
||||||
|
#endif
|
||||||
|
// Execute the script.
|
||||||
|
pyexec_str(usbdbg_get_script(), true);
|
||||||
|
// Disable IDE interrupts
|
||||||
|
usbdbg_set_irq_enabled(false);
|
||||||
|
nlr_pop();
|
||||||
|
} else {
|
||||||
|
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usbdbg_is_busy() && nlr_push(&nlr) == 0) {
|
||||||
// Enable IDE interrupt
|
// Enable IDE interrupt
|
||||||
usbdbg_set_irq_enabled(true);
|
usbdbg_set_irq_enabled(true);
|
||||||
#if OMV_ENABLE_WIFIDBG && MICROPY_PY_WINC1500
|
#if OMV_ENABLE_WIFIDBG && MICROPY_PY_WINC1500
|
||||||
wifidbg_set_irq_enabled(openmv_config.wifidbg);
|
wifidbg_set_irq_enabled(openmv_config.wifidbg);
|
||||||
#endif
|
#endif
|
||||||
|
// Wait for the current command to finish.
|
||||||
// Execute the script.
|
usbdbg_wait_for_command(1000);
|
||||||
pyexec_str(usbdbg_get_script(), true);
|
// Disable IDE interrupts
|
||||||
|
usbdbg_set_irq_enabled(false);
|
||||||
nlr_pop();
|
nlr_pop();
|
||||||
} else {
|
|
||||||
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (openmv_config.wifidbg == true);
|
|
||||||
|
|
||||||
nlr_buf_t nlr;
|
} while (openmv_config.wifidbg == true);
|
||||||
if (nlr_push(&nlr) == 0) {
|
|
||||||
usbdbg_wait_for_command(1000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// soft reset
|
// soft reset
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user