From dcd23fdb8d1d10cd95fd1328885303c33ecd208d Mon Sep 17 00:00:00 2001 From: Jaime Date: Mon, 12 Aug 2024 17:52:03 -0400 Subject: [PATCH 1/3] avoid task overflow --- vehicle/OVMS.V3/main/ovms_events.cpp | 23 +++++++++++++++++++++-- vehicle/OVMS.V3/main/ovms_events.h | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/vehicle/OVMS.V3/main/ovms_events.cpp b/vehicle/OVMS.V3/main/ovms_events.cpp index b758eae34..e83755fff 100644 --- a/vehicle/OVMS.V3/main/ovms_events.cpp +++ b/vehicle/OVMS.V3/main/ovms_events.cpp @@ -225,7 +225,7 @@ OvmsEvents::OvmsEvents() cmd_eventtrace->RegisterCommand("off","Turn event tracing OFF",event_trace); m_taskqueue = xQueueCreate(CONFIG_OVMS_HW_EVENT_QUEUE_SIZE,sizeof(event_queue_t)); - xTaskCreatePinnedToCore(EventLaunchTask, "OVMS Events", 8192, (void*)this, 8, &m_taskid, CORE(1)); + xTaskCreatePinnedToCore(EventLaunchTask, "OVMS Events", 12288, (void*)this, 8, &m_taskid, CORE(1)); AddTaskToMap(m_taskid); #ifdef CONFIG_OVMS_SC_JAVASCRIPT_DUKTAPE @@ -246,6 +246,7 @@ OvmsEvents::~OvmsEvents() void OvmsEvents::EventTask() { event_queue_t msg; + detect_event_loop_blockage = 0; esp_task_wdt_add(NULL); // WATCHDOG is active for this task while(1) @@ -259,7 +260,25 @@ void OvmsEvents::EventTask() break; case EVENT_signal: m_current_event = msg.body.signal.event; - HandleQueueSignalEvent(&msg); + if (startsWith(m_current_event, "ticker.") && uxQueueSpacesAvailable(m_taskqueue) < CONFIG_OVMS_HW_EVENT_QUEUE_SIZE/5) + { + ESP_LOGE(TAG, "Droped %s, counter %i", m_current_event.c_str(), detect_event_loop_blockage); + FreeQueueSignalEvent(&msg); + detect_event_loop_blockage++; + if (detect_event_loop_blockage > 30) + { + ESP_LOGE(TAG, "Timer service / ticker timer has died => aborting"); + MyBoot.Restart(); + } + } + else + { + HandleQueueSignalEvent(&msg); + if (startsWith(m_current_event, "ticker.") && detect_event_loop_blockage > 0) + { + detect_event_loop_blockage--; + } + } esp_task_wdt_reset(); // Reset WATCHDOG timer for this task m_current_event.clear(); break; diff --git a/vehicle/OVMS.V3/main/ovms_events.h b/vehicle/OVMS.V3/main/ovms_events.h index f1120a286..ef9f8ae08 100644 --- a/vehicle/OVMS.V3/main/ovms_events.h +++ b/vehicle/OVMS.V3/main/ovms_events.h @@ -129,6 +129,7 @@ class OvmsEvents TimerList m_timers; TimerStatusMap m_timer_active; OvmsMutex m_timers_mutex; + int detect_event_loop_blockage; #if ESP_IDF_VERSION_MAJOR >= 4 esp_event_handler_instance_t event_handler_instance; #endif From d0b625f0cb74229a4a79f507bb102e8229d4d596 Mon Sep 17 00:00:00 2001 From: Jaime Date: Mon, 26 Aug 2024 16:10:16 -0400 Subject: [PATCH 2/3] fix style --- .../ovms_webserver/assets/charts.js.gz | Bin 80477 -> 80477 bytes vehicle/OVMS.V3/main/ovms_events.cpp | 12 ++++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/vehicle/OVMS.V3/components/ovms_webserver/assets/charts.js.gz b/vehicle/OVMS.V3/components/ovms_webserver/assets/charts.js.gz index c7f8bf7e96641532ab14504950f7e70821a21a92..8e4a16f1f607cafcf250c01fb81a7a525c5a1585 100644 GIT binary patch delta 22 bcmccnh2`!S77qDt4h9ft 30) - { + { ESP_LOGE(TAG, "Timer service / ticker timer has died => aborting"); MyBoot.Restart(); + } } - } else - { + { HandleQueueSignalEvent(&msg); if (startsWith(m_current_event, "ticker.") && detect_event_loop_blockage > 0) - { + { detect_event_loop_blockage--; + } } - } esp_task_wdt_reset(); // Reset WATCHDOG timer for this task m_current_event.clear(); break; From f7c0c2f44abe5c4bbd7e365ce67adcfea8dd8cde Mon Sep 17 00:00:00 2001 From: Jaime Date: Mon, 26 Aug 2024 16:51:55 -0400 Subject: [PATCH 3/3] make variable detect_event_loop_blockage local --- vehicle/OVMS.V3/main/ovms_events.cpp | 2 +- vehicle/OVMS.V3/main/ovms_events.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/vehicle/OVMS.V3/main/ovms_events.cpp b/vehicle/OVMS.V3/main/ovms_events.cpp index bd6ce9321..d158a55e6 100644 --- a/vehicle/OVMS.V3/main/ovms_events.cpp +++ b/vehicle/OVMS.V3/main/ovms_events.cpp @@ -246,7 +246,7 @@ OvmsEvents::~OvmsEvents() void OvmsEvents::EventTask() { event_queue_t msg; - detect_event_loop_blockage = 0; + int detect_event_loop_blockage = 0; esp_task_wdt_add(NULL); // WATCHDOG is active for this task while(1) diff --git a/vehicle/OVMS.V3/main/ovms_events.h b/vehicle/OVMS.V3/main/ovms_events.h index ef9f8ae08..f1120a286 100644 --- a/vehicle/OVMS.V3/main/ovms_events.h +++ b/vehicle/OVMS.V3/main/ovms_events.h @@ -129,7 +129,6 @@ class OvmsEvents TimerList m_timers; TimerStatusMap m_timer_active; OvmsMutex m_timers_mutex; - int detect_event_loop_blockage; #if ESP_IDF_VERSION_MAJOR >= 4 esp_event_handler_instance_t event_handler_instance; #endif