You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
52 lines
1.2 KiB
2 years ago
|
//
|
||
|
// Created by MightyPork on 2018/12/08.
|
||
|
//
|
||
|
|
||
|
#include <esp_log.h>
|
||
|
|
||
|
#include <freertos/FreeRTOS.h>
|
||
|
#include <freertos/task.h>
|
||
|
|
||
|
#include "console/cmd_common.h"
|
||
|
#include <console/cmddef.h>
|
||
|
|
||
|
|
||
|
static const char* TAG = "cmd_tasks";
|
||
|
|
||
|
static int cmd_tasks_info(console_ctx_t *ctx, cmd_signature_t *reg)
|
||
|
{
|
||
|
static struct {
|
||
|
struct arg_end *end;
|
||
|
} cmd_args;
|
||
|
|
||
|
if (reg) {
|
||
|
cmd_args.end = arg_end(1);
|
||
|
|
||
|
reg->argtable = &cmd_args;
|
||
|
reg->command = "ps";
|
||
|
reg->help = "List running emulator tasks (for debug)";
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
const size_t bytes_per_task = 40; /* see vTaskList description */
|
||
|
char *task_list_buffer = calloc(uxTaskGetNumberOfTasks() * bytes_per_task, 1);
|
||
|
if (task_list_buffer == NULL) {
|
||
|
ESP_LOGE(TAG, "failed to allocate buffer for vTaskList output");
|
||
|
return 1;
|
||
|
}
|
||
|
console_fputs("\x1b[1mTask Name\tStatus\tPrio\tHWM\tTask#");
|
||
|
#ifdef CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID
|
||
|
console_fputs("\tAffinity");
|
||
|
#endif
|
||
|
console_fputs("\x1b[m\r\n");
|
||
|
vTaskList(task_list_buffer);
|
||
|
console_fputs(task_list_buffer);
|
||
|
free(task_list_buffer);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
void register_cmd_tasks()
|
||
|
{
|
||
|
console_cmd_register(cmd_tasks_info, "ps");
|
||
|
}
|