From c483347e412dec6779890f93ed41f35124bd2c79 Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Sat, 28 Sep 2024 23:12:47 +0200 Subject: [PATCH] Feature: show task details in system info view shows whether or not known tasks are alive, and in particular shows how much of the respective stack is still available. --- src/WebApi_sysstatus.cpp | 14 ++++++++++ webapp/src/components/TaskDetails.vue | 40 +++++++++++++++++++++++++++ webapp/src/locales/de.json | 18 ++++++++++++ webapp/src/locales/en.json | 18 ++++++++++++ webapp/src/types/SystemStatus.ts | 8 ++++++ webapp/src/views/SystemInfoView.vue | 4 +++ 6 files changed, 102 insertions(+) create mode 100644 webapp/src/components/TaskDetails.vue diff --git a/src/WebApi_sysstatus.cpp b/src/WebApi_sysstatus.cpp index 3a6b8f440..c25db2303 100644 --- a/src/WebApi_sysstatus.cpp +++ b/src/WebApi_sysstatus.cpp @@ -52,6 +52,20 @@ void WebApiSysstatusClass::onSystemStatus(AsyncWebServerRequest* request) root["chipcores"] = ESP.getChipCores(); root["flashsize"] = ESP.getFlashChipSize(); + JsonArray taskDetails = root["task_details"].to(); + static std::array constexpr task_names = { + "IDLE0", "IDLE1", "wifi", "tiT", "loopTask", "async_tcp", "mqttclient", + "HUAWEI_CAN_0", "PM:SDM", "PM:HTTP+JSON", "PM:SML", "PM:HTTP+SML" + }; + for (char const* task_name : task_names) { + TaskHandle_t const handle = xTaskGetHandle(task_name); + if (!handle) { continue; } + JsonObject task = taskDetails.add(); + task["name"] = task_name; + task["stack_watermark"] = uxTaskGetStackHighWaterMark(handle); + task["priority"] = uxTaskPriorityGet(handle); + } + String reason; reason = ResetReason::get_reset_reason_verbose(0); root["resetreason_0"] = reason; diff --git a/webapp/src/components/TaskDetails.vue b/webapp/src/components/TaskDetails.vue new file mode 100644 index 000000000..a9ab86ac3 --- /dev/null +++ b/webapp/src/components/TaskDetails.vue @@ -0,0 +1,40 @@ + + + diff --git a/webapp/src/locales/de.json b/webapp/src/locales/de.json index 4fa446830..b424c74a1 100644 --- a/webapp/src/locales/de.json +++ b/webapp/src/locales/de.json @@ -286,6 +286,24 @@ "MaxUsage": "Maximale Speichernutzung seit Start", "Fragmentation": "Grad der Fragmentierung" }, + "taskdetails": { + "TaskDetails": "Detailinformationen zu Tasks", + "Name": "Name", + "StackFree": "Stack Frei", + "Priority": "Priorität", + "Task_idle0": "Leerlauf (CPU-Kern 0)", + "Task_idle1": "Leerlauf (CPU-Kern 1)", + "Task_wifi": "Wi-Fi", + "Task_tit": "TCP/IP", + "Task_looptask": "Arduino Hauptschleife (loop)", + "Task_asynctcp": "Async TCP", + "Task_mqttclient": "MQTT Client", + "Task_huaweican0": "AC Ladegerät CAN", + "Task_pmsdm": "Stromzähler (SDM)", + "Task_pmhttpjson": "Stromzähler (HTTP+JSON)", + "Task_pmsml": "Stromzähler (Serial SML)", + "Task_pmhttpsml": "Stromzähler (HTTP+SML)" + }, "radioinfo": { "RadioInformation": "Funkmodulinformationen", "Status": "{module} Status", diff --git a/webapp/src/locales/en.json b/webapp/src/locales/en.json index 087fcb262..6b641edb7 100644 --- a/webapp/src/locales/en.json +++ b/webapp/src/locales/en.json @@ -287,6 +287,24 @@ "MaxUsage": "Maximum usage since start", "Fragmentation": "Level of fragmentation" }, + "taskdetails": { + "TaskDetails": "Task Details", + "Name": "Name", + "StackFree": "Stack Free", + "Priority": "Priority", + "Task_idle0": "Idle (CPU Core 0)", + "Task_idle1": "Idle (CPU Core 1)", + "Task_wifi": "Wi-Fi", + "Task_tit": "TCP/IP", + "Task_looptask": "Arduino Main Loop", + "Task_asynctcp": "Async TCP", + "Task_mqttclient": "MQTT Client", + "Task_huaweican0": "AC Charger CAN", + "Task_pmsdm": "PowerMeter (SDM)", + "Task_pmhttpjson": "PowerMeter (HTTP+JSON)", + "Task_pmsml": "PowerMeter (Serial SML)", + "Task_pmhttpsml": "PowerMeter (HTTP+SML)" + }, "radioinfo": { "RadioInformation": "Radio Information", "Status": "{module} Status", diff --git a/webapp/src/types/SystemStatus.ts b/webapp/src/types/SystemStatus.ts index 3937361d9..41fdd3cf5 100644 --- a/webapp/src/types/SystemStatus.ts +++ b/webapp/src/types/SystemStatus.ts @@ -1,3 +1,9 @@ +export interface TaskDetail { + name: string; + stack_watermark: number; + priority: number; +} + export interface SystemStatus { // HardwareInfo chipmodel: string; @@ -6,6 +12,8 @@ export interface SystemStatus { cpufreq: number; cputemp: number; flashsize: number; + // TaskDetails + task_details: TaskDetail[]; // FirmwareInfo hostname: string; sdkversion: string; diff --git a/webapp/src/views/SystemInfoView.vue b/webapp/src/views/SystemInfoView.vue index aaccea0eb..8742383a1 100644 --- a/webapp/src/views/SystemInfoView.vue +++ b/webapp/src/views/SystemInfoView.vue @@ -8,6 +8,8 @@
+ +
@@ -19,6 +21,7 @@ import FirmwareInfo from '@/components/FirmwareInfo.vue'; import HardwareInfo from '@/components/HardwareInfo.vue'; import MemoryInfo from '@/components/MemoryInfo.vue'; import HeapDetails from '@/components/HeapDetails.vue'; +import TaskDetails from '@/components/TaskDetails.vue'; import RadioInfo from '@/components/RadioInfo.vue'; import type { SystemStatus } from '@/types/SystemStatus'; import { authHeader, handleResponse } from '@/utils/authentication'; @@ -31,6 +34,7 @@ export default defineComponent({ HardwareInfo, MemoryInfo, HeapDetails, + TaskDetails, RadioInfo, }, data() {