From 86f4014f834e4c33449cb35a7b7fb0bae8071790 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 8 Aug 2022 13:52:05 -0700 Subject: [PATCH 1/3] Add exception filename to title bar Add the exception filename after the line number and change the line number so it is in that file. It used to always be code.py. Fixes #6702 --- main.c | 3 ++- shared/runtime/pyexec.c | 4 +++- shared/runtime/pyexec.h | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index f17731950f..bbc73d560c 100644 --- a/main.c +++ b/main.c @@ -213,8 +213,9 @@ void supervisor_execution_status(void) { if (_current_executing_filename != NULL) { serial_write(_current_executing_filename); } else if ((_exec_result.return_code & PYEXEC_EXCEPTION) != 0 && + _exec_result.exception_line > 0 && exception != NULL) { - mp_printf(&mp_plat_print, "@%d %q", _exec_result.exception_line, exception->base.type->name); + mp_printf(&mp_plat_print, "@%d %s %q", _exec_result.exception_line, _exec_result.exception_filename, exception->base.type->name); } else { serial_write_compressed(translate("Done")); } diff --git a/shared/runtime/pyexec.c b/shared/runtime/pyexec.c index b1f94db5e5..72714b9a2b 100644 --- a/shared/runtime/pyexec.c +++ b/shared/runtime/pyexec.c @@ -199,7 +199,9 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input size_t n, *values; mp_obj_exception_get_traceback(return_value, &n, &values); if (values != NULL) { - result->exception_line = values[n - 2]; + result->exception_line = values[1]; + result->exception_filename[sizeof(result->exception_filename) - 1] = '\0'; + strncpy(result->exception_filename, qstr_str(values[0]), sizeof(result->exception_filename) - 1); } } } diff --git a/shared/runtime/pyexec.h b/shared/runtime/pyexec.h index d31a7fe816..411426eaaa 100644 --- a/shared/runtime/pyexec.h +++ b/shared/runtime/pyexec.h @@ -37,6 +37,9 @@ typedef struct { int return_code; mp_obj_t exception; int exception_line; + // Only store the first 32 characters of the filename. It is very unlikely that they can all be + // seen. + char exception_filename[33]; } pyexec_result_t; extern pyexec_mode_kind_t pyexec_mode_kind; From f3ca15265ea511af2d5701e6dc9b60f3cc4a5586 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 9 Aug 2022 10:42:20 -0700 Subject: [PATCH 2/3] Change to line@filename --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index bbc73d560c..12de1b6c0e 100644 --- a/main.c +++ b/main.c @@ -215,7 +215,7 @@ void supervisor_execution_status(void) { } else if ((_exec_result.return_code & PYEXEC_EXCEPTION) != 0 && _exec_result.exception_line > 0 && exception != NULL) { - mp_printf(&mp_plat_print, "@%d %s %q", _exec_result.exception_line, _exec_result.exception_filename, exception->base.type->name); + mp_printf(&mp_plat_print, "%d@%s %q", _exec_result.exception_line, _exec_result.exception_filename, exception->base.type->name); } else { serial_write_compressed(translate("Done")); } From ce1273be7aac73cd275d8e2eae5c6da0e9f5c990 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 9 Aug 2022 10:42:56 -0700 Subject: [PATCH 3/3] Pull Feather S2 TFT LED down on reset --- .../boards/adafruit_feather_esp32s2_tft/board.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c index aab7fbc608..ea21bcc0f9 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c @@ -144,6 +144,18 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) { gpio_set_level(21, true); return true; } + // Pull LED down on reset rather than the default up + if (pin_number == 13) { + gpio_config_t cfg = { + .pin_bit_mask = BIT64(pin_number), + .mode = GPIO_MODE_DISABLE, + .pull_up_en = false, + .pull_down_en = true, + .intr_type = GPIO_INTR_DISABLE, + }; + gpio_config(&cfg); + return true; + } return false; }