From 4cf741a32be7bf2f545d5e868dbafd11866f179d Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 20 Feb 2024 21:24:32 +0200 Subject: [PATCH] Make serial compile, add github workflow --- .../workflows/compile-all-combinations.yml | 1 + .github/workflows/compile-all-inverters.yml | 1 + Software/Software.ino | 27 +++++++++---------- Software/USER_SETTINGS.h | 4 +-- Software/src/battery/BATTERIES.h | 7 ++++- .../SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp | 14 +++++++--- .../SERIAL-LINK-RECEIVER-FROM-BATTERY.h | 3 +++ .../SERIAL-LINK-TRANSMITTER-INVERTER.h | 2 -- 8 files changed, 37 insertions(+), 22 deletions(-) diff --git a/.github/workflows/compile-all-combinations.yml b/.github/workflows/compile-all-combinations.yml index 38f5aba4..e2c24be9 100644 --- a/.github/workflows/compile-all-combinations.yml +++ b/.github/workflows/compile-all-combinations.yml @@ -55,6 +55,7 @@ jobs: - SMA_TRIPOWER_CAN - SOFAR_CAN - SOLAX_CAN + - SERIAL_LINK_TRANSMITTER # This is the platform GitHub will use to run our workflow. runs-on: ubuntu-latest diff --git a/.github/workflows/compile-all-inverters.yml b/.github/workflows/compile-all-inverters.yml index 55a6787b..f9504af9 100644 --- a/.github/workflows/compile-all-inverters.yml +++ b/.github/workflows/compile-all-inverters.yml @@ -50,6 +50,7 @@ jobs: - SMA_TRIPOWER_CAN - SOFAR_CAN - SOLAX_CAN + - SERIAL_LINK_TRANSMITTER # This is the platform GitHub will use to run our workflow. runs-on: ubuntu-latest diff --git a/Software/Software.ino b/Software/Software.ino index 41744ad3..5de96b4c 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -361,9 +361,7 @@ void inform_user_on_inverter() { void init_battery() { // Inform user what battery is used and perform setup setup_battery(); -#ifdef SERIAL_LINK_RECEIVER - Serial.println("SERIAL_DATA_LINK_RECEIVER selected"); -#endif + #ifndef BATTERY_SELECTED #error No battery selected! Choose one from the USER_SETTINGS.h file #endif @@ -375,9 +373,11 @@ void receive_can() { // This section checks if we have a complete CAN message i CAN_frame_t rx_frame; if (xQueueReceive(CAN_cfg.rx_queue, &rx_frame, 3 * portTICK_PERIOD_MS) == pdTRUE) { if (rx_frame.FIR.B.FF == CAN_frame_std) { - //printf("New standard frame"); - // Battery +//printf("New standard frame"); +// Battery +#ifndef SERIAL_LINK_RECEIVER receive_can_battery(rx_frame); +#endif // Inverter #ifdef BYD_CAN receive_can_byd(rx_frame); @@ -651,23 +651,22 @@ void update_values() { #endif } +#if defined(SERIAL_LINK_RECEIVER) || defined(SERIAL_LINK_TRANSMITTER) void runSerialDataLink() { static unsigned long updateTime = 0; unsigned long currentMillis = millis(); -#ifdef SERIAL_LINK_RECEIVER - if ((currentMillis - updateTime) > 1) { //Every 2ms - updateTime = currentMillis; - manageSerialLinkReceiver(); - } -#endif -#ifdef SERIAL_LINK_TRANSMITTER if ((currentMillis - updateTime) > 1) { //Every 2ms updateTime = currentMillis; - manageSerialLinkTransmitter(); - } +#ifdef SERIAL_LINK_RECEIVER + manageSerialLinkReceiver(); #endif +#ifdef SERIAL_LINK_TRANSMITTER + manageSerialLinkTransmitter(); +#endif + } } +#endif void init_serialDataLink() { #if defined(SERIAL_LINK_RECEIVER) || defined(SERIAL_LINK_TRANSMITTER) diff --git a/Software/USER_SETTINGS.h b/Software/USER_SETTINGS.h index f78ee7b5..960d7d05 100644 --- a/Software/USER_SETTINGS.h +++ b/Software/USER_SETTINGS.h @@ -12,7 +12,7 @@ //#define CHADEMO_BATTERY //#define IMIEV_CZERO_ION_BATTERY //#define KIA_HYUNDAI_64_BATTERY -//#define NISSAN_LEAF_BATTERY +//define NISSAN_LEAF_BATTERY //#define RENAULT_KANGOO_BATTERY //#define RENAULT_ZOE_BATTERY //#define SANTA_FE_PHEV_BATTERY @@ -30,7 +30,7 @@ //#define SOLAX_CAN //Enable this line to emulate a "SolaX Triple Power LFP" over CAN bus /* Other options */ -#define DEBUG_VIA_USB //Enable this line to have the USB port output serial diagnostic data while program runs +//#define DEBUG_VIA_USB //Enable this line to have the USB port output serial diagnostic data while program runs //#define INTERLOCK_REQUIRED //Nissan LEAF specific setting, if enabled requires both high voltage conenctors to be seated before starting //#define CONTACTOR_CONTROL //Enable this line to have pins 25,32,33 handle automatic precharge/contactor+/contactor- closing sequence //#define PWM_CONTACTOR_CONTROL //Enable this line to use PWM logic for contactors, which lower power consumption and heat generation diff --git a/Software/src/battery/BATTERIES.h b/Software/src/battery/BATTERIES.h index f6efe68e..054d95ad 100644 --- a/Software/src/battery/BATTERIES.h +++ b/Software/src/battery/BATTERIES.h @@ -47,7 +47,12 @@ #include "SERIAL-LINK-RECEIVER-FROM-BATTERY.h" //See this file for more Serial-battery settings #endif -#ifndef SERIAL_LINK_RECEIVER // The serial thing does its thing +#ifdef SERIAL_LINK_RECEIVER // The serial thing does its thing +void update_values_battery(); +void receive_can_battery(); +void send_can_battery(); +void setup_battery(void); +#else void update_values_battery(); void receive_can_battery(CAN_frame_t rx_frame); void send_can_battery(); diff --git a/Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp b/Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp index bf2d970b..8e6e5dc7 100644 --- a/Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp +++ b/Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp @@ -1,8 +1,8 @@ -// SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp - -#include "SERIAL-LINK-RECEIVER-FROM-BATTERY.h" +#include "BATTERIES.h" +#ifdef SERIAL_LINK_RECEIVER #include #include "../devboard/utils/events.h" +#include "SERIAL-LINK-RECEIVER-FROM-BATTERY.h" #define INVERTER_SEND_NUM_VARIABLES 1 #define INVERTER_RECV_NUM_VARIABLES 16 @@ -212,3 +212,11 @@ void update_values_serial_link() { Serial.println(""); } + +void setup_battery(void) { + Serial.println("SERIAL_DATA_LINK_RECEIVER selected"); +} +void update_values_battery() {} +void send_can_battery() {} + +#endif diff --git a/Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.h b/Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.h index 097d09ef..8c4ab623 100644 --- a/Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.h +++ b/Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.h @@ -3,6 +3,8 @@ #ifndef SERIAL_LINK_RECEIVER_FROM_BATTERY_H #define SERIAL_LINK_RECEIVER_FROM_BATTERY_H +#define BATTERY_SELECTED + #include #include "../../USER_SETTINGS.h" #include "../devboard/config.h" // Needed for all defines @@ -35,5 +37,6 @@ extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false void manageSerialLinkReceiver(); void update_values_serial_link(); +void setup_battery(void); #endif diff --git a/Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.h b/Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.h index 5d782306..6078c941 100644 --- a/Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.h +++ b/Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.h @@ -1,5 +1,3 @@ -//SERIAL-LINK-TRANSMITTER-INVERTER.h - #ifndef SERIAL_LINK_TRANSMITTER_INVERTER_H #define SERIAL_LINK_TRANSMITTER_INVERTER_H