Add serial ping for debug
This commit is contained in:
parent
cc2499e0e5
commit
6b9ccf9f7e
28
src/main.cpp
28
src/main.cpp
|
@ -63,6 +63,7 @@ unsigned long standbyStartTime = 0; // Tracks the start time of standby mode
|
||||||
// Internal variables
|
// Internal variables
|
||||||
bool serial_init = false;
|
bool serial_init = false;
|
||||||
bool can_enabled = false;
|
bool can_enabled = false;
|
||||||
|
int serial_ping = 0;
|
||||||
|
|
||||||
// Function to initialize CAN bus
|
// Function to initialize CAN bus
|
||||||
void initCAN()
|
void initCAN()
|
||||||
|
@ -285,11 +286,11 @@ void vSerialConsoleTask(void *pvParameters)
|
||||||
ESP_LOGD("State machine", "Try to enable CAN Interface");
|
ESP_LOGD("State machine", "Try to enable CAN Interface");
|
||||||
initCAN();
|
initCAN();
|
||||||
}
|
}
|
||||||
if (standbyStartTime != 0) {
|
if (standbyStartTime != 0)
|
||||||
|
{
|
||||||
standbyStartTime = 0; // Reset standby timer
|
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"))
|
else if (input.endsWith("off"))
|
||||||
{
|
{
|
||||||
|
@ -316,10 +317,10 @@ void vSerialConsoleTask(void *pvParameters)
|
||||||
standbyStartTime = millis();
|
standbyStartTime = millis();
|
||||||
ESP_LOGI("State machine", "Ignition set to standby mode, retype command to see duration left");
|
ESP_LOGI("State machine", "Ignition set to standby mode, retype command to see duration left");
|
||||||
if (!can_enabled)
|
if (!can_enabled)
|
||||||
{
|
{
|
||||||
ESP_LOGD("State machine", "Try to enable CAN Interface");
|
ESP_LOGD("State machine", "Try to enable CAN Interface");
|
||||||
initCAN();
|
initCAN();
|
||||||
}
|
}
|
||||||
standbyState = true;
|
standbyState = true;
|
||||||
ignitionState = 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();
|
mutex = xSemaphoreCreateMutex();
|
||||||
|
|
||||||
//Print state of variables during bootup
|
// Print state of variables during bootup
|
||||||
ESP_LOGD("SYS", "Print actual variable states");
|
ESP_LOGD("SYS", "Print actual variable states");
|
||||||
printVariableSummary();
|
printVariableSummary();
|
||||||
|
|
||||||
|
@ -416,10 +423,9 @@ void setup()
|
||||||
ESP_LOGD("SYS", "Start CANSendTask");
|
ESP_LOGD("SYS", "Start CANSendTask");
|
||||||
xTaskCreatePinnedToCore(vSerialConsoleTask, "SerialConsoleTask", 8096, NULL, 10, &xSerialConsoleTaskHandle, 1);
|
xTaskCreatePinnedToCore(vSerialConsoleTask, "SerialConsoleTask", 8096, NULL, 10, &xSerialConsoleTaskHandle, 1);
|
||||||
ESP_LOGD("SYS", "Start SerialConsoleTask");
|
ESP_LOGD("SYS", "Start SerialConsoleTask");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
//We are using tasks instead
|
// We are using tasks instead
|
||||||
}
|
}
|
Loading…
Reference in a new issue