mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-06 03:50:13 +02:00
Merge branch 'main' into feature/event-CAN-timing
This commit is contained in:
commit
4fbfe6f5e9
1 changed files with 50 additions and 33 deletions
|
@ -17,6 +17,10 @@
|
||||||
#include "src/lib/eModbus-eModbus/scripts/mbServerFCs.h"
|
#include "src/lib/eModbus-eModbus/scripts/mbServerFCs.h"
|
||||||
#include "src/lib/miwagner-ESP32-Arduino-CAN/CAN_config.h"
|
#include "src/lib/miwagner-ESP32-Arduino-CAN/CAN_config.h"
|
||||||
#include "src/lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h"
|
#include "src/lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "esp_system.h"
|
||||||
|
#include "esp_task_wdt.h"
|
||||||
|
|
||||||
#ifdef WEBSERVER
|
#ifdef WEBSERVER
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
|
@ -119,6 +123,8 @@ unsigned long timeSpentInFaultedMode = 0;
|
||||||
bool batteryAllowsContactorClosing = false;
|
bool batteryAllowsContactorClosing = false;
|
||||||
bool inverterAllowsContactorClosing = true;
|
bool inverterAllowsContactorClosing = true;
|
||||||
|
|
||||||
|
TaskHandle_t mainLoopTask;
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
void setup() {
|
void setup() {
|
||||||
init_serial();
|
init_serial();
|
||||||
|
@ -149,10 +155,19 @@ void setup() {
|
||||||
|
|
||||||
// BOOT button at runtime is used as an input for various things
|
// BOOT button at runtime is used as an input for various things
|
||||||
pinMode(0, INPUT_PULLUP);
|
pinMode(0, INPUT_PULLUP);
|
||||||
|
|
||||||
|
esp_task_wdt_deinit(); // Disable watchdog
|
||||||
|
|
||||||
|
xTaskCreatePinnedToCore((TaskFunction_t)&mainLoop, "mainLoop", 4096, NULL, 8, &mainLoopTask, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform main program functions
|
// Perform main program functions
|
||||||
void loop() {
|
void loop() {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainLoop(void* pvParameters) {
|
||||||
|
while (true) {
|
||||||
|
|
||||||
#ifdef WEBSERVER
|
#ifdef WEBSERVER
|
||||||
// Over-the-air updates by ElegantOTA
|
// Over-the-air updates by ElegantOTA
|
||||||
|
@ -204,6 +219,8 @@ void loop() {
|
||||||
} else {
|
} else {
|
||||||
test_all_colors = true;
|
test_all_colors = true;
|
||||||
}
|
}
|
||||||
|
delay(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WEBSERVER
|
#ifdef WEBSERVER
|
||||||
|
@ -347,7 +364,7 @@ void init_modbus() {
|
||||||
MBserver.registerWorker(MBTCP_ID, WRITE_MULT_REGISTERS, &FC16);
|
MBserver.registerWorker(MBTCP_ID, WRITE_MULT_REGISTERS, &FC16);
|
||||||
MBserver.registerWorker(MBTCP_ID, R_W_MULT_REGISTERS, &FC23);
|
MBserver.registerWorker(MBTCP_ID, R_W_MULT_REGISTERS, &FC23);
|
||||||
// Start ModbusRTU background task
|
// Start ModbusRTU background task
|
||||||
MBserver.begin(Serial2);
|
MBserver.begin(Serial2, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue