From 8fd17206dd92c68e99cc3276fc64a417e1f971c3 Mon Sep 17 00:00:00 2001 From: technyon Date: Sun, 26 Feb 2023 11:55:35 +0100 Subject: [PATCH] print stack watermarks in sysinfo page --- Config.h | 2 +- WebCfgServer.cpp | 8 ++++++++ WebCfgServer.h | 4 ++++ main.cpp | 17 +++++++++++++---- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Config.h b/Config.h index f90b06b..538eb48 100644 --- a/Config.h +++ b/Config.h @@ -1,6 +1,6 @@ #pragma once -#define NUKI_HUB_VERSION "8.12-pre-8" +#define NUKI_HUB_VERSION "8.12-pre-9" #define MQTT_QOS_LEVEL 1 #define MQTT_CLEAN_SESSIONS false \ No newline at end of file diff --git a/WebCfgServer.cpp b/WebCfgServer.cpp index e186297..652c1b1 100644 --- a/WebCfgServer.cpp +++ b/WebCfgServer.cpp @@ -785,6 +785,14 @@ void WebCfgServer::buildInfoHtml(String &response) response.concat(esp_get_free_heap_size()); response.concat("\n"); + response.concat("Stack watermarks: nw: "); + response.concat(uxTaskGetStackHighWaterMark(networkTaskHandle)); + response.concat(", nuki: "); + response.concat(uxTaskGetStackHighWaterMark(nukiTaskHandle)); + response.concat(", pd: "); + response.concat(uxTaskGetStackHighWaterMark(presenceDetectionTaskHandle)); + response.concat("\n"); + response.concat("Restart reason FW: "); response.concat(getRestartReason()); response.concat( "\n"); diff --git a/WebCfgServer.h b/WebCfgServer.h index 007f140..ec05e06 100644 --- a/WebCfgServer.h +++ b/WebCfgServer.h @@ -7,6 +7,10 @@ #include "NukiOpenerWrapper.h" #include "Ota.h" +extern TaskHandle_t networkTaskHandle; +extern TaskHandle_t nukiTaskHandle; +extern TaskHandle_t presenceDetectionTaskHandle; + enum class TokenType { None, diff --git a/main.cpp b/main.cpp index 2a955a5..39780c9 100644 --- a/main.cpp +++ b/main.cpp @@ -32,6 +32,10 @@ unsigned long restartTs = (2^32) - 5 * 60000; RTC_NOINIT_ATTR int restartReason; RTC_NOINIT_ATTR uint64_t restartReasonValid; +TaskHandle_t networkTaskHandle = nullptr; +TaskHandle_t nukiTaskHandle = nullptr; +TaskHandle_t presenceDetectionTaskHandle = nullptr; + void networkTask(void *pvParameters) { while(true) @@ -53,7 +57,12 @@ void networkTask(void *pvParameters) delay(100); -// Serial.println(uxTaskGetStackHighWaterMark(NULL)); +// if(wmts < millis()) +// { +// Serial.print("# "); +// Serial.println(uxTaskGetStackHighWaterMark(NULL)); +// wmts = millis() + 60000; +// } } } @@ -96,9 +105,9 @@ void setupTasks() { // configMAX_PRIORITIES is 25 - xTaskCreatePinnedToCore(networkTask, "ntw", 8192, NULL, 3, NULL, 1); - xTaskCreatePinnedToCore(nukiTask, "nuki", 4096, NULL, 2, NULL, 1); - xTaskCreatePinnedToCore(presenceDetectionTask, "prdet", 768, NULL, 5, NULL, 1); + xTaskCreatePinnedToCore(networkTask, "ntw", 8192, NULL, 3, &networkTaskHandle, 1); + xTaskCreatePinnedToCore(nukiTask, "nuki", 4096, NULL, 2, &nukiTaskHandle, 1); + xTaskCreatePinnedToCore(presenceDetectionTask, "prdet", 768, NULL, 5, &presenceDetectionTaskHandle, 1); } uint32_t getRandomId()