Add serial ping for debug

This commit is contained in:
Carsten Schmiemann 2024-04-11 22:56:02 +02:00
parent cc2499e0e5
commit 6b9ccf9f7e
1 changed files with 17 additions and 11 deletions

View File

@ -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
}