|
|
@@ -20,11 +20,19 @@
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
#include "freertos/task.h"
|
|
|
#include "soc/rtc_cntl_reg.h"
|
|
|
+#include "sdkconfig.h"
|
|
|
+
|
|
|
+#ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
|
|
|
+#define WITH_TASKS_INFO 1
|
|
|
+#endif
|
|
|
|
|
|
static void register_free();
|
|
|
static void register_restart();
|
|
|
static void register_deep_sleep();
|
|
|
static void register_make();
|
|
|
+#if WITH_TASKS_INFO
|
|
|
+static void register_tasks();
|
|
|
+#endif
|
|
|
|
|
|
void register_system()
|
|
|
{
|
|
|
@@ -32,6 +40,9 @@ void register_system()
|
|
|
register_restart();
|
|
|
register_deep_sleep();
|
|
|
register_make();
|
|
|
+#if WITH_TASKS_INFO
|
|
|
+ register_tasks();
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
/** 'restart' command restarts the program */
|
|
|
@@ -72,6 +83,36 @@ static void register_free()
|
|
|
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
|
|
|
}
|
|
|
|
|
|
+/** 'tasks' command prints the list of tasks and related information */
|
|
|
+#if WITH_TASKS_INFO
|
|
|
+
|
|
|
+static int tasks_info(int argc, char** argv)
|
|
|
+{
|
|
|
+ const size_t bytes_per_task = 40; /* see vTaskList description */
|
|
|
+ char* task_list_buffer = malloc(uxTaskGetNumberOfTasks() * bytes_per_task);
|
|
|
+ if (task_list_buffer == NULL) {
|
|
|
+ ESP_LOGE(__func__, "failed to allocate buffer for vTaskList output");
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ vTaskList(task_list_buffer);
|
|
|
+ fputs(task_list_buffer, stdout);
|
|
|
+ free(task_list_buffer);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static void register_tasks()
|
|
|
+{
|
|
|
+ const esp_console_cmd_t cmd = {
|
|
|
+ .command = "tasks",
|
|
|
+ .help = "Get information about running tasks",
|
|
|
+ .hint = NULL,
|
|
|
+ .func = &tasks_info,
|
|
|
+ };
|
|
|
+ ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
|
|
|
+}
|
|
|
+
|
|
|
+#endif // WITH_TASKS_INFO
|
|
|
+
|
|
|
/** 'deep_sleep' command puts the chip into deep sleep mode */
|
|
|
|
|
|
static struct {
|