From 3565c29895b0f6d612041f9bd304390c8d2d3efe Mon Sep 17 00:00:00 2001 From: cfif Date: Tue, 9 Dec 2025 17:41:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CommandLines.h | 2 ++ TasksInfo.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 TasksInfo.c diff --git a/CommandLines.h b/CommandLines.h index 074df77..7814d43 100644 --- a/CommandLines.h +++ b/CommandLines.h @@ -30,6 +30,8 @@ typedef struct { } tCommandLine; +void vTaskGetRunTime(void *env, tCliCmd *cli); + void CommandLine_Init(tCommandLine *env, tSerialPortIO *cliVirtualPortIn_Io, tSerialPortIO *cliVirtualPortOut_Io); void CommandLine_StartThread(tCommandLine *env); diff --git a/TasksInfo.c b/TasksInfo.c new file mode 100644 index 0000000..bde45f0 --- /dev/null +++ b/TasksInfo.c @@ -0,0 +1,43 @@ +// +// Created by cfif on 17.12.2024. +// +#include +#include +#include "CliRedirectTable.h" +#include "CmsisRtosThreadUtils.h" + +char bufSprintf[1024]; + +int32_t vTaskGetRunTime(void *env, tCliCmd *cli) { + + volatile UBaseType_t uxArraySize, x; + + uxArraySize = uxTaskGetNumberOfTasks(); + + TaskStatus_t pxTaskStatusArray[uxArraySize]; + + + uxArraySize = uxTaskGetSystemState((void *) pxTaskStatusArray, uxArraySize, NULL); + + uint16_t p = 1; + bufSprintf[0] = '\n'; + + for (x = 0; x < uxArraySize; x++) { + + sprintf(&bufSprintf[p], "%lu\t%d\t%s\n", + pxTaskStatusArray[x].xTaskNumber, + pxTaskStatusArray[x].usStackHighWaterMark, + pxTaskStatusArray[x].pcTaskName); + + p = strlen(bufSprintf); + + } + + CliCmd_Print(cli, bufSprintf, p); + + sprintf(bufSprintf, "Free Heap Size = %u bytes\n", (unsigned int)xPortGetFreeHeapSize()); + p = strlen(bufSprintf); + CliCmd_Print(cli, bufSprintf, p); + + return 0; +} \ No newline at end of file