Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Event Queue Overflow #1048

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified vehicle/OVMS.V3/components/ovms_webserver/assets/charts.js.gz
Binary file not shown.
23 changes: 21 additions & 2 deletions vehicle/OVMS.V3/main/ovms_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -246,6 +246,7 @@ OvmsEvents::~OvmsEvents()
void OvmsEvents::EventTask()
{
event_queue_t msg;
int detect_event_loop_blockage = 0;

esp_task_wdt_add(NULL); // WATCHDOG is active for this task
while(1)
Expand All @@ -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;
Expand Down