Improve stability, fix task scheduler to fit ESP doc

This commit is contained in:
Carsten Schmiemann 2024-03-30 00:58:26 +01:00
parent 73e8b6f0c4
commit c3fc2959ab

View file

@ -4,6 +4,8 @@
#include <CAN.h>
#include "esp_log.h"
static SemaphoreHandle_t mutex;
// Task handles
TaskHandle_t xCANSendTaskHandle = NULL;
TaskHandle_t xSerialConsoleTaskHandle = NULL;
@ -172,7 +174,7 @@ void printVariableSummary()
Serial.println("-------------------------");
Serial.print("Ignition: ");
Serial.println(ignitionState ? "on" : "off");
Serial.print("Standby:");
Serial.print("Standby: ");
Serial.println(standbyState ? "yes" : "no");
Serial.print("Reverse: ");
Serial.println(reverseState ? "on" : "off");
@ -392,18 +394,17 @@ void setup()
Serial.setTimeout(5000);
ESP_LOGI("SYS", "Easylink CAN Waker application starting up...");
//Print state of variables during bootup
printVariableSummary();
ESP_LOGD("SYS", "Print actual variable states");
mutex = xSemaphoreCreateMutex();
//Start tasks one per CPU, because we have enough ressources :-)
vTaskStartScheduler();
ESP_LOGD("SYS", "Start FreeRTOS scheduler");
//Print state of variables during bootup
ESP_LOGD("SYS", "Print actual variable states");
printVariableSummary();
xTaskCreatePinnedToCore(vCANSendTask, "CANSendTask", 8096, NULL, 10, &xCANSendTaskHandle, 0);
ESP_LOGD("SYS", "Start CANSendTask");
xTaskCreatePinnedToCore(vSerialConsoleTask, "SerialConsoleTask", 8096, NULL, 10, &xSerialConsoleTaskHandle, 1);
ESP_LOGD("SYS", "Start SerialConsoleTask");
}
void loop()