From 6b9ccf9f7e4fcd26fc7ced0396a3556b35f243ee Mon Sep 17 00:00:00 2001 From: Crash_Override Date: Thu, 11 Apr 2024 22:56:02 +0200 Subject: [PATCH] Add serial ping for debug --- src/main.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ed6d44e..ebc5f24 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -63,6 +63,7 @@ unsigned long standbyStartTime = 0; // Tracks the start time of standby mode // Internal variables bool serial_init = false; bool can_enabled = false; +int serial_ping = 0; // Function to initialize CAN bus void initCAN() @@ -285,11 +286,11 @@ void vSerialConsoleTask(void *pvParameters) ESP_LOGD("State machine", "Try to enable CAN Interface"); initCAN(); } - if (standbyStartTime != 0) { + if (standbyStartTime != 0) + { standbyStartTime = 0; // Reset standby timer - ESP_LOGI("State machine"," Ignition standby timer disabled"); + ESP_LOGI("State machine", " Ignition standby timer disabled"); } - } else if (input.endsWith("off")) { @@ -316,10 +317,10 @@ void vSerialConsoleTask(void *pvParameters) standbyStartTime = millis(); ESP_LOGI("State machine", "Ignition set to standby mode, retype command to see duration left"); if (!can_enabled) - { - ESP_LOGD("State machine", "Try to enable CAN Interface"); - initCAN(); - } + { + ESP_LOGD("State machine", "Try to enable CAN Interface"); + initCAN(); + } standbyState = true; ignitionState = true; } @@ -396,7 +397,13 @@ void vSerialConsoleTask(void *pvParameters) } } } - vTaskDelay(10); + vTaskDelay(50); + + if (millis() - serial_ping >= 10000) + { + serial_ping += 10000; + ESP_LOGI("Serial Console", "Ping, Time %d s", millis() / 1000); + } } } @@ -408,7 +415,7 @@ void setup() mutex = xSemaphoreCreateMutex(); - //Print state of variables during bootup + // Print state of variables during bootup ESP_LOGD("SYS", "Print actual variable states"); printVariableSummary(); @@ -416,10 +423,9 @@ void setup() ESP_LOGD("SYS", "Start CANSendTask"); xTaskCreatePinnedToCore(vSerialConsoleTask, "SerialConsoleTask", 8096, NULL, 10, &xSerialConsoleTaskHandle, 1); ESP_LOGD("SYS", "Start SerialConsoleTask"); - } void loop() { - //We are using tasks instead + // We are using tasks instead } \ No newline at end of file