From 11bddb1b1da603a7d6c0e9f239eb89fb724be08e Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 10 Jul 2024 15:18:33 +1000 Subject: add a console command for dumping intr allocations --- src/tangara/dev_console/console.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/tangara/dev_console/console.cpp') diff --git a/src/tangara/dev_console/console.cpp b/src/tangara/dev_console/console.cpp index a7f7a721..fcb987bb 100644 --- a/src/tangara/dev_console/console.cpp +++ b/src/tangara/dev_console/console.cpp @@ -13,6 +13,7 @@ #include #include "esp_console.h" +#include "esp_intr_alloc.h" #include "esp_log.h" #include "esp_system.h" @@ -66,12 +67,34 @@ void RegisterLogLevel() { esp_console_cmd_register(&cmd); } +int CmdInterrupts(int argc, char** argv) { + static const std::pmr::string usage = "usage: intr"; + if (argc != 1) { + std::cout << usage << std::endl; + return 1; + } + esp_intr_dump(NULL); + return 0; +} + +void RegisterInterrupts() { + esp_console_cmd_t cmd{.command = "intr", + .help = "Dumps a table of all allocated interrupts", + .hint = NULL, + .func = &CmdInterrupts, + .argtable = NULL}; + esp_console_cmd_register(&cmd); + cmd.command = "interrupts"; + esp_console_cmd_register(&cmd); +} + Console::Console() {} Console::~Console() {} auto Console::RegisterCommonComponents() -> void { esp_console_register_help_command(); RegisterLogLevel(); + RegisterInterrupts(); } static Console* sInstance; -- cgit v1.2.3 From 9e1fc64c8880bf6920b156e9f9d19fd0b098a468 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 13 Aug 2024 14:21:07 +1000 Subject: Accept a specific tag in `loglevel` --- src/tangara/dev_console/console.cpp | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'src/tangara/dev_console/console.cpp') diff --git a/src/tangara/dev_console/console.cpp b/src/tangara/dev_console/console.cpp index fcb987bb..bc3a7aca 100644 --- a/src/tangara/dev_console/console.cpp +++ b/src/tangara/dev_console/console.cpp @@ -23,34 +23,47 @@ namespace console { int CmdLogLevel(int argc, char** argv) { static const std::pmr::string usage = - "usage: loglevel [VERBOSE,DEBUG,INFO,WARN,ERROR,NONE]"; - if (argc != 2) { + "usage: loglevel [tag] [VERBOSE,DEBUG,INFO,WARN,ERROR,NONE]"; + if (argc < 2 || argc > 3) { std::cout << usage << std::endl; return 1; } - std::pmr::string level_str = argv[1]; - std::transform(level_str.begin(), level_str.end(), level_str.begin(), + + std::string tag; + if (argc == 2) { + tag = "*"; + } else { + tag = argv[1]; + } + + std::string raw_level; + if (argc == 2) { + raw_level = argv[1]; + } else { + raw_level = argv[2]; + } + std::transform(raw_level.begin(), raw_level.end(), raw_level.begin(), [](unsigned char c) { return std::toupper(c); }); esp_log_level_t level; - if (level_str == "VERBOSE") { + if (raw_level == "VERBOSE") { level = ESP_LOG_VERBOSE; - } else if (level_str == "DEBUG") { + } else if (raw_level == "DEBUG") { level = ESP_LOG_DEBUG; - } else if (level_str == "INFO") { + } else if (raw_level == "INFO") { level = ESP_LOG_INFO; - } else if (level_str == "WARN") { + } else if (raw_level == "WARN") { level = ESP_LOG_WARN; - } else if (level_str == "ERROR") { + } else if (raw_level == "ERROR") { level = ESP_LOG_ERROR; - } else if (level_str == "NONE") { + } else if (raw_level == "NONE") { level = ESP_LOG_NONE; } else { std::cout << usage << std::endl; return 1; } - esp_log_level_set("*", level); + esp_log_level_set(tag.c_str(), level); return 0; } -- cgit v1.2.3