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.
This commit is contained in:
Bernhard Kirchen 2024-09-28 23:12:47 +02:00 committed by Bernhard Kirchen
parent f760520489
commit c483347e41
6 changed files with 102 additions and 0 deletions

View File

@ -52,6 +52,20 @@ void WebApiSysstatusClass::onSystemStatus(AsyncWebServerRequest* request)
root["chipcores"] = ESP.getChipCores();
root["flashsize"] = ESP.getFlashChipSize();
JsonArray taskDetails = root["task_details"].to<JsonArray>();
static std::array<char const*, 12> 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<JsonObject>();
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;

View File

@ -0,0 +1,40 @@
<template>
<CardElement :text="$t('taskdetails.TaskDetails')" textVariant="text-bg-primary">
<div class="table-responsive">
<table class="table table-hover table-condensed">
<tbody>
<tr>
<th>{{ $t('taskdetails.Name') }}</th>
<th>{{ $t('taskdetails.StackFree') }}</th>
<th>{{ $t('taskdetails.Priority') }}</th>
</tr>
<tr v-for="task in taskDetails" v-bind:key="task.name">
<td>{{ $te(taskLangToken(task.name)) ? $t(taskLangToken(task.name)) : task.name }}</td>
<td>{{ $n(task.stack_watermark, 'byte') }}</td>
<td>{{ task.priority }}</td>
</tr>
</tbody>
</table>
</div>
</CardElement>
</template>
<script lang="ts">
import CardElement from '@/components/CardElement.vue';
import type { TaskDetail } from '@/types/SystemStatus';
import { defineComponent, type PropType } from 'vue';
export default defineComponent({
components: {
CardElement,
},
props: {
taskDetails: { type: Array as PropType<TaskDetail[]>, required: true },
},
methods: {
taskLangToken(rawTask: string) {
return 'taskdetails.Task_' + rawTask.replace(/[^A-Za-z0-9]/g, '').toLowerCase();
},
},
});
</script>

View File

@ -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",

View File

@ -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",

View File

@ -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;

View File

@ -8,6 +8,8 @@
<div class="mt-5"></div>
<HeapDetails :systemStatus="systemDataList" />
<div class="mt-5"></div>
<TaskDetails :taskDetails="systemDataList.task_details" />
<div class="mt-5"></div>
<RadioInfo :systemStatus="systemDataList" />
<div class="mt-5"></div>
</BasePage>
@ -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() {