Merge branch 'main' into feature/double-lilygo

This commit is contained in:
Daniel 2023-11-25 11:36:40 +02:00
commit 44fa2ba3b0
8 changed files with 175 additions and 26 deletions

View file

@ -11,15 +11,12 @@
#include "src/lib/eModbus-eModbus/Logging.h"
#include "src/lib/eModbus-eModbus/ModbusServerRTU.h"
#include "src/lib/eModbus-eModbus/scripts/mbServerFCs.h"
#include "src/lib/mackelec-SerialDataLink/SerialDataLink.h"
#include "src/lib/miwagner-ESP32-Arduino-CAN/CAN_config.h"
#include "src/lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h"
// Interval settings
int intervalUpdateValues = 4800; // Interval at which to update inverter values / Modbus registers
const int interval1 = 1; // Interval for 1ms tasks
const int interval10 = 10; // Interval for 10ms tasks
unsigned long previousMillis1ms = 0;
unsigned long previousMillis10ms = 50;
unsigned long previousMillisUpdateVal = 0;
@ -131,9 +128,12 @@ void loop() {
#ifdef DUAL_CAN
receive_can2();
#endif
<<<<<<< HEAD
#ifdef SERIAL_LINK_RECEIVER
receive_serial();
#endif
=======
>>>>>>> main
// Process
if (millis() - previousMillis10ms >= interval10) // Every 10ms
@ -156,9 +156,12 @@ void loop() {
#ifdef DUAL_CAN
send_can2();
#endif
<<<<<<< HEAD
#ifdef SERIAL_LINK_TRANSMITTER
send_serial();
#endif
=======
>>>>>>> main
}
// Initialization functions
@ -226,6 +229,7 @@ void init_modbus() {
pinMode(PIN_5V_EN, OUTPUT);
digitalWrite(PIN_5V_EN, HIGH);
<<<<<<< HEAD
#if defined(SERIAL_LINK_RECEIVER) || defined(SERIAL_LINK_TRANSMITTER)
Serial2.begin(9600, SERIAL_8N1, RS485_RX_PIN, RS485_TX_PIN); // If the Modbus RTU port will be used for serial link
#if defined(BYD_MODBUS) || defined(LUNA2000_MODBUS)
@ -233,6 +237,8 @@ void init_modbus() {
#endif
#endif
=======
>>>>>>> main
#ifdef BYD_MODBUS
// Init Static data to the RTU Modbus
handle_static_data_modbus_byd();
@ -304,6 +310,9 @@ void inform_user_on_battery() {
#ifdef TEST_FAKE_BATTERY
Serial.println("Test mode with fake battery selected");
#endif
#if !defined(ABSOLUTE_MAX_VOLTAGE)
#error No battery selected! Choose one from the USER_SETTINGS.h file
#endif
}
// Functions
@ -399,6 +408,7 @@ void send_can() {
#endif
}
<<<<<<< HEAD
#ifdef SERIAL_LINK_RECEIVER
//---- Receives serial data and transfers to the Inverter
void receive_serial() {
@ -421,6 +431,8 @@ void send_serial() {
}
#endif
=======
>>>>>>> main
#ifdef DUAL_CAN
void receive_can2() { // This function is similar to receive_can, but just takes care of inverters in the 2nd bus.
// Depending on which inverter is selected, we forward this to their respective CAN routines