diff --git a/src/cyclic.cpp b/src/cyclic.cpp index d197e234..45bac2f2 100644 --- a/src/cyclic.cpp +++ b/src/cyclic.cpp @@ -22,44 +22,55 @@ void doHousekeeping() { if ((RTC_runmode == RUNMODE_UPDATE) || (RTC_runmode == RUNMODE_MAINTENANCE)) do_reset(true); // warmstart - // heap and task storage debugging + // print heap and task storage information ESP_LOGD(TAG, "Heap: Free:%d, Min:%d, Size:%d, Alloc:%d, StackHWM:%d", ESP.getFreeHeap(), ESP.getMinFreeHeap(), ESP.getHeapSize(), ESP.getMaxAllocHeap(), uxTaskGetStackHighWaterMark(NULL)); - ESP_LOGD(TAG, "IRQhandler %d bytes left | Taskstate = %d", - uxTaskGetStackHighWaterMark(irqHandlerTask), - eTaskGetState(irqHandlerTask)); - ESP_LOGD(TAG, "Rcommand interpreter %d bytes left | Taskstate = %d", - uxTaskGetStackHighWaterMark(rcmdTask), eTaskGetState(rcmdTask)); + + if (irqHandlerTask != NULL) + ESP_LOGD(TAG, "IRQhandler %d bytes left | Taskstate = %d", + uxTaskGetStackHighWaterMark(irqHandlerTask), + eTaskGetState(irqHandlerTask)); + if (rcmdTask != NULL) + ESP_LOGD(TAG, "Rcommand interpreter %d bytes left | Taskstate = %d", + uxTaskGetStackHighWaterMark(rcmdTask), eTaskGetState(rcmdTask)); #if (HAS_LORA) - ESP_LOGD(TAG, "LMiCtask %d bytes left | Taskstate = %d", - uxTaskGetStackHighWaterMark(lmicTask), eTaskGetState(lmicTask)); - ESP_LOGD(TAG, "Lorasendtask %d bytes left | Taskstate = %d", - uxTaskGetStackHighWaterMark(lorasendTask), - eTaskGetState(lorasendTask)); + if (lmicTask != NULL) + ESP_LOGD(TAG, "LMiCtask %d bytes left | Taskstate = %d", + uxTaskGetStackHighWaterMark(lmicTask), eTaskGetState(lmicTask)); + if (lorasendTask != NULL) + ESP_LOGD(TAG, "Lorasendtask %d bytes left | Taskstate = %d", + uxTaskGetStackHighWaterMark(lorasendTask), + eTaskGetState(lorasendTask)); #endif #if (HAS_GPS) - ESP_LOGD(TAG, "Gpsloop %d bytes left | Taskstate = %d", - uxTaskGetStackHighWaterMark(GpsTask), eTaskGetState(GpsTask)); + if (GpsTask != NULL) + ESP_LOGD(TAG, "Gpsloop %d bytes left | Taskstate = %d", + uxTaskGetStackHighWaterMark(GpsTask), eTaskGetState(GpsTask)); #endif #ifdef HAS_SPI - ESP_LOGD(TAG, "spiloop %d bytes left | Taskstate = %d", - uxTaskGetStackHighWaterMark(spiTask), eTaskGetState(spiTask)); + if (spiTask != NULL) + ESP_LOGD(TAG, "spiloop %d bytes left | Taskstate = %d", + uxTaskGetStackHighWaterMark(spiTask), eTaskGetState(spiTask)); #endif + #ifdef HAS_MQTT - ESP_LOGD(TAG, "MQTTloop %d bytes left | Taskstate = %d", - uxTaskGetStackHighWaterMark(mqttTask), eTaskGetState(mqttTask)); + if (mqttTask != NULL) + ESP_LOGD(TAG, "MQTTloop %d bytes left | Taskstate = %d", + uxTaskGetStackHighWaterMark(mqttTask), eTaskGetState(mqttTask)); #endif #if (defined HAS_DCF77 || defined HAS_IF482) - ESP_LOGD(TAG, "Clockloop %d bytes left | Taskstate = %d", - uxTaskGetStackHighWaterMark(ClockTask), eTaskGetState(ClockTask)); + if (ClockTask != NULL) + ESP_LOGD(TAG, "Clockloop %d bytes left | Taskstate = %d", + uxTaskGetStackHighWaterMark(ClockTask), eTaskGetState(ClockTask)); #endif #if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) - ESP_LOGD(TAG, "LEDloop %d bytes left | Taskstate = %d", - uxTaskGetStackHighWaterMark(ledLoopTask), - eTaskGetState(ledLoopTask)); + if (ledLoopTask != NULL) + ESP_LOGD(TAG, "LEDloop %d bytes left | Taskstate = %d", + uxTaskGetStackHighWaterMark(ledLoopTask), + eTaskGetState(ledLoopTask)); #endif // read battery voltage into global variable