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