minor improvements for debugging

* Info page: status of Serial (can be disconnected on new MCUs), and owner of RX/TX pins
* improved handling of Serial (don't write if not connected)
* added min available stack size to debug output (esp32 only)
* webserver show remaining stack size
* webserver: show string buffer usage
This commit is contained in:
Frank
2023-03-25 21:10:15 +01:00
parent df9df5e4c8
commit f52e706c95
5 changed files with 42 additions and 7 deletions

View File

@@ -198,6 +198,9 @@ void WLED::loop()
DEBUG_PRINT(F("Runtime: ")); DEBUG_PRINTLN(millis());
DEBUG_PRINT(F("Unix time: ")); toki.printTime(toki.getTime());
DEBUG_PRINT(F("Free heap: ")); DEBUG_PRINTLN(ESP.getFreeHeap());
#ifdef ARDUINO_ARCH_ESP32
DEBUG_PRINT(pcTaskGetTaskName(NULL)); DEBUG_PRINT(F(" free stack ")); DEBUG_PRINTLN(uxTaskGetStackHighWaterMark(NULL));
#endif
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
if (psramFound()) {
//DEBUG_PRINT(F("Total PSRAM: ")); DEBUG_PRINT(ESP.getPsramSize()/1024); DEBUG_PRINTLN("kB");
@@ -292,17 +295,17 @@ void WLED::setup()
#else
#endif
#if defined(WLED_DEBUG) && defined(ARDUINO_ARCH_ESP32) && (defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || ARDUINO_USB_CDC_ON_BOOT)
delay(2500); // allow CDC USB serial to initialise
if (!Serial) delay(2500); // WLEDMM allow CDC USB serial to initialise
#endif
#if ARDUINO_USB_CDC_ON_BOOT
delay(2500); // WLEDMM: always allow CDC USB serial to initialise
if (!Serial) delay(2500); // WLEDMM: always allow CDC USB serial to initialise
Serial.println("wait 1"); // waiting a bit longer ensures that a debug messages are shown in serial monitor
delay(2500);
if (!Serial) delay(2500);
Serial.println("wait 2");
delay(2500);
if (!Serial) delay(2500);
Serial.flush();
if (Serial) Serial.flush(); // WLEDMM
Serial.setTimeout(350); // WLEDMM: don't change timeout, as it causes crashes later
// WLEDMM: redirect debug output to HWCDC
Serial0.setDebugOutput(false);
@@ -403,6 +406,12 @@ void WLED::setup()
DEBUG_PRINTLN(ESP.getCoreVersion());
#endif
DEBUG_PRINT(F("heap ")); DEBUG_PRINTLN(ESP.getFreeHeap());
#ifdef ARDUINO_ARCH_ESP32
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0) // unfortunately not availeable in older framework versions
USER_PRINT(F("\nArduino max stack ")); USER_PRINTLN(getArduinoLoopTaskStackSize());
#endif
USER_PRINT(pcTaskGetTaskName(NULL)); USER_PRINT(F(" free stack ")); USER_PRINTLN(uxTaskGetStackHighWaterMark(NULL));
#endif
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
if (psramFound()) {
@@ -456,6 +465,9 @@ void WLED::setup()
registerUsermods();
DEBUG_PRINT(F("heap ")); DEBUG_PRINTLN(ESP.getFreeHeap());
#ifdef ARDUINO_ARCH_ESP32
DEBUG_PRINT(pcTaskGetTaskName(NULL)); DEBUG_PRINT(F(" free stack ")); DEBUG_PRINTLN(uxTaskGetStackHighWaterMark(NULL));
#endif
for (uint8_t i=1; i<WLED_MAX_BUTTONS; i++) btnPin[i] = -1;
@@ -563,6 +575,9 @@ void WLED::setup()
DEBUG_PRINTLN(F("initServer"));
initServer();
DEBUG_PRINT(F("heap ")); DEBUG_PRINTLN(ESP.getFreeHeap());
#ifdef ARDUINO_ARCH_ESP32
DEBUG_PRINT(pcTaskGetTaskName(NULL)); DEBUG_PRINT(F(" free stack ")); DEBUG_PRINTLN(uxTaskGetStackHighWaterMark(NULL));
#endif
enableWatchdog();
@@ -827,9 +842,9 @@ void WLED::initConnection()
USER_PRINT(F("Connecting to "));
USER_PRINT(clientSSID);
USER_PRINT(" / ");
for(int i = 0; i<strlen(clientPass); i++){
for(unsigned i = 0; i<strlen(clientPass); i++) {
USER_PRINT("*");
}
}
USER_PRINTLN(" ...");
// convert the "serverDescription" into a valid DNS hostname (alphanumeric)