From 2d2a104521377b83c468e8c44a5ac6c6c1ac767c Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Wed, 3 Apr 2024 00:38:44 +0200 Subject: [PATCH] Some little fixes --- include/YaSolR.h | 2 +- include/YaSolRMacros.h | 18 +++++++++--------- platformio.ini | 4 ++-- src/YaSolR_API_REST.cpp | 2 +- src/YaSolR_Tasks.cpp | 14 ++++++++------ src/main.cpp | 6 +++--- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/include/YaSolR.h b/include/YaSolR.h index dd992a75..8806d691 100644 --- a/include/YaSolR.h +++ b/include/YaSolR.h @@ -77,7 +77,7 @@ extern Mycila::TemperatureSensor output2TemperatureSensor; extern Mycila::TemperatureSensor systemTemperatureSensor; extern Mycila::TaskManager loopTaskManager; -extern Mycila::TaskManager meterTaskManager; +// extern Mycila::TaskManager meterTaskManager; extern Mycila::TaskManager routerTaskManager; extern Mycila::Task assignOutput1PZEMTask; diff --git a/include/YaSolRMacros.h b/include/YaSolRMacros.h index a11d014f..9bd81f02 100644 --- a/include/YaSolRMacros.h +++ b/include/YaSolRMacros.h @@ -140,17 +140,17 @@ // default settings -#ifndef YASOLR_METER_TASK_PRIORITY -#define YASOLR_METER_TASK_PRIORITY 1 -#endif +// #ifndef YASOLR_METER_TASK_PRIORITY +// #define YASOLR_METER_TASK_PRIORITY 1 +// #endif -#ifndef YASOLR_METER_TASK_STACK -#define YASOLR_METER_TASK_STACK 256 * 12 -#endif +// #ifndef YASOLR_METER_TASK_STACK +// #define YASOLR_METER_TASK_STACK 256 * 12 +// #endif -#ifndef YASOLR_METER_TASK_CORE -#define YASOLR_METER_TASK_CORE 0 -#endif +// #ifndef YASOLR_METER_TASK_CORE +// #define YASOLR_METER_TASK_CORE 0 +// #endif #ifndef YASOLR_ROUTER_TASK_PRIORITY #define YASOLR_ROUTER_TASK_PRIORITY 1 diff --git a/platformio.ini b/platformio.ini index fe37f2a0..e2ea60f6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -59,7 +59,7 @@ build_flags = -Wunused -Wmisleading-indentation -Wduplicated-cond -Wlogical-op -Wnull-dereference -std=c++17 -std=gnu++17 - -D ARDUINO_LOOP_STACK_SIZE=256*18 + -D ARDUINO_LOOP_STACK_SIZE=256*20 -D CONFIG_ASYNC_TCP_RUNNING_CORE=1 -D CONFIG_ASYNC_TCP_STACK_SIZE=256*15 -D CONFIG_ETH_ENABLED @@ -79,7 +79,7 @@ build_flags = -D MYCILA_JSY_JSON_SUPPORT -D MYCILA_MQTT_BUFFER_SIZE=256 -D MYCILA_MQTT_STACK_SIZE=256*15 - -D MYCILA_MQTT_TASK_PRIORITY=2 + -D MYCILA_MQTT_TASK_PRIORITY=1 -D MYCILA_NTP_JSON_SUPPORT -D MYCILA_PZEM_JSON_SUPPORT -D MYCILA_RELAY_JSON_SUPPORT diff --git a/src/YaSolR_API_REST.cpp b/src/YaSolR_API_REST.cpp index d4676b6c..d861ee80 100644 --- a/src/YaSolR_API_REST.cpp +++ b/src/YaSolR_API_REST.cpp @@ -227,7 +227,7 @@ void YaSolR::YaSolRClass::_initREST() { Mycila::Lights.toJson(root["lights"].to()); Mycila::TaskMonitor.toJson(root["stack"].to()); loopTaskManager.toJson(root["task_managers"][0].to()); - meterTaskManager.toJson(root["task_managers"][1].to()); + // meterTaskManager.toJson(root["task_managers"][1].to()); routerTaskManager.toJson(root["task_managers"][2].to()); systemTemperatureSensor.toJson(root["temp_sensor"].to()); response->setLength(); diff --git a/src/YaSolR_Tasks.cpp b/src/YaSolR_Tasks.cpp index 4002ecd4..30ec3eeb 100644 --- a/src/YaSolR_Tasks.cpp +++ b/src/YaSolR_Tasks.cpp @@ -12,7 +12,7 @@ static const Mycila::TaskPredicate DEBUG_ENABLED = []() { return Mycila::Logger.isDebugEnabled(); }; static const Mycila::TaskDoneCallback LOG_EXEC_TIME = [](const Mycila::Task& me, const uint32_t elapsed) { - Mycila::Logger.debug(TAG, "%s in %u ms", me.getName(), elapsed / Mycila::TaskDuration::MILLISECONDS); + Mycila::Logger.debug(TAG, "%s in %u us", me.getName(), elapsed); }; // Core tasks @@ -23,7 +23,7 @@ Mycila::Task lightsTask("Lights", [](void* params) { Mycila::Lights.setYellow(re Mycila::Task stackMonitorTask("TaskMonitor.log()", [](void* params) { Mycila::TaskMonitor.log(); }); Mycila::Task profilerTask("TaskManager.log()", [](void* params) { loopTaskManager.log(); - meterTaskManager.log(); + // meterTaskManager.log(); routerTaskManager.log(); }); Mycila::Task systemTemperatureTask("systemTemperatureSensor.read()", [](void* params) { @@ -425,7 +425,7 @@ Mycila::Task configureTaskMonitorTask("configureTaskMonitorTask", [](void* param Mycila::TaskMonitor.begin(5); Mycila::TaskMonitor.addTask("async_tcp"); // ESPAsyncTCP Mycila::TaskMonitor.addTask("loopTask"); // Arduino - Mycila::TaskMonitor.addTask("meterTask"); // YaSolR + // Mycila::TaskMonitor.addTask("meterTask"); // YaSolR Mycila::TaskMonitor.addTask("mqtt_task"); // NycilaMQTT Mycila::TaskMonitor.addTask("routerTask"); // YaSolR }); @@ -455,7 +455,7 @@ Mycila::Task configureDebugTask("configureDebugTask", [](void* params) { } else { Mycila::Logger.info(TAG, "Disable profiling for all tasks"); loopTaskManager.disableProfiling(); - meterTaskManager.disableProfiling(); + // meterTaskManager.disableProfiling(); routerTaskManager.disableProfiling(); } }); @@ -551,12 +551,14 @@ void YaSolR::YaSolRClass::_initTasks() { // jsyTask.setInterval(100 * Mycila::TaskDuration::MILLISECONDS); output1PZEMTask.setType(Mycila::TaskType::FOREVER); - output1PZEMTask.setManager(&meterTaskManager); + // output1PZEMTask.setManager(&meterTaskManager); + output1PZEMTask.setManager(&routerTaskManager); output1PZEMTask.setEnabledWhen([]() { return output1PZEM.isEnabled() && !assignOutput1PZEMTask.isRunning() && !assignOutput2PZEMTask.isRunning(); }); // output1PZEMTask.setInterval(100 * Mycila::TaskDuration::MILLISECONDS); output2PZEMTask.setType(Mycila::TaskType::FOREVER); - output2PZEMTask.setManager(&meterTaskManager); + // output2PZEMTask.setManager(&meterTaskManager); + output2PZEMTask.setManager(&routerTaskManager); output2PZEMTask.setEnabledWhen([]() { return output2PZEM.isEnabled() && !assignOutput1PZEMTask.isRunning() && !assignOutput2PZEMTask.isRunning(); }); // output2PZEMTask.setInterval(100 * Mycila::TaskDuration::MILLISECONDS); diff --git a/src/main.cpp b/src/main.cpp index 3c8ac59b..c6115a41 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,8 +12,8 @@ #define TAG "YASOLR" Mycila::TaskManager loopTaskManager("loopTask", 49); -Mycila::TaskManager meterTaskManager("meterTask", 2); -Mycila::TaskManager routerTaskManager("routerTask", 1); +// Mycila::TaskManager meterTaskManager("meterTask", 2); +Mycila::TaskManager routerTaskManager("routerTask", 3); // TODO: switch to PsychicHttp (when WS perf will be better) AsyncWebServer webServer(80); @@ -121,7 +121,7 @@ void setup() { configureNetworkTask.forceRun(); assert(routerTaskManager.asyncStart(YASOLR_ROUTER_TASK_STACK, YASOLR_ROUTER_TASK_PRIORITY, YASOLR_ROUTER_TASK_CORE)); - assert(meterTaskManager.asyncStart(YASOLR_METER_TASK_STACK, YASOLR_METER_TASK_PRIORITY, YASOLR_METER_TASK_CORE)); + // assert(meterTaskManager.asyncStart(YASOLR_METER_TASK_STACK, YASOLR_METER_TASK_PRIORITY, YASOLR_METER_TASK_CORE)); // STARTUP READY! Mycila::Logger.info(TAG, "Started %s %s %s", Mycila::AppInfo.name.c_str(), Mycila::AppInfo.model.c_str(), Mycila::AppInfo.version.c_str());