diff --git a/sufst-controller/can.cpp b/sufst-controller/can.cpp index 4cc3e65b3620dcfb528ed77e92740565586e339f..c589acd217d359659fbca9226a07676028a40ceb 100644 --- a/sufst-controller/can.cpp +++ b/sufst-controller/can.cpp @@ -8,6 +8,7 @@ #include "buffer.h" #include <mcp_can.h> #include <mcp_can_dfs.h> +#include "evoScann-p.h" #include "ecuCan.h" @@ -187,6 +188,9 @@ void canParseRxMsg(CanMsgTemplate *canMsg) // This removes the need for a long if statement giving significant performance boosts (*ecuCanFuncPtrs[canMsg->idByte[0]])(canMsg); } + else if (canMsg->id == 0x487) { + evoScannNonMux(canMsg); + } } void canProcessRx() diff --git a/sufst-controller/daq.cpp b/sufst-controller/daq.cpp index 90da9c6817a853df1495b425aa8dd655bb607429..af4cd57bdcb4c3c7ec55500dc4b820a150922673 100644 --- a/sufst-controller/daq.cpp +++ b/sufst-controller/daq.cpp @@ -5,19 +5,11 @@ #include "daq.h" #include "sd.h" -struct DaqEcuFormat -{ - uint8_t startTag; - uint32_t timestamp; - uint16_t data; - uint8_t endTag; -}; - /* * e.g 1 is rpm and 2 is tps... etc */ -const uint8_t daqEcuDataToTag[8][4] = { +static const uint8_t daqEcuDataToTag[8][4] = { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, @@ -25,7 +17,7 @@ const uint8_t daqEcuDataToTag[8][4] = { {17, 18, 19, 20}, {21, 22, 23, 24}, {25, 26, 27, 28}, - {29, 30, 31, 32} + {29, 30, 31, 32}, }; void daqEcuWrite(CanMsgTemplate *canMsg, uint8_t index) diff --git a/sufst-controller/daq.h b/sufst-controller/daq.h index f5775568216f01223615d69114d45ceaaad14a27..dc72a47229aacefe5d27ee7b1670c7634d3c6977 100644 --- a/sufst-controller/daq.h +++ b/sufst-controller/daq.h @@ -7,6 +7,22 @@ #include "can.h" +struct DaqEcuFormat +{ + uint8_t startTag; + uint32_t timestamp; + uint16_t data; + uint8_t endTag; +}; + +struct DaqEvoScannPressureFormat +{ + uint8_t startTag; + uint32_t timestamp; + uint32_t data; + uint8_t endTag; +}; + void daqEcuWrite(CanMsgTemplate *canMsg, uint8_t index); #endif //DAQ_H diff --git a/sufst-controller/evoScann-p.cpp b/sufst-controller/evoScann-p.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5d35bf068fa8865d1467c1dae777b622be815d4c --- /dev/null +++ b/sufst-controller/evoScann-p.cpp @@ -0,0 +1,95 @@ +// +// Created by Sil on 27/07/2019. +// + +#include "evoScann-p.h" + +void evoScannMux0(CanMsgTemplate *canMsg); +void evoScannMux1(CanMsgTemplate *canMsg); +void evoScannMux2(CanMsgTemplate *canMsg); + +void (*evoScannFunc_ptrs[3])(CanMsgTemplate *) = {evoScannMux0, evoScannMux1, evoScannMux2}; + +void evoScannMux0(CanMsgTemplate *canMsg) +{ +#if EVO_SCANN_SEN_1_ENABLED + uint16_t sen1Raw = (canMsg->data[1] << 8) | canMsg->data[2]; + int sen1 = (sen1Raw + 60000); + +// Serial.print("S1 "); +// Serial.println(sen1); +#endif // EVO_SCANN_SEN_1_ENABLED + +#if EVO_SCANN_SEN_2_ENABLED + uint16_t sen2Raw = (canMsg->data[3] << 8) | canMsg->data[4]; + int sen2 = (sen2Raw + 60000); + +// Serial.print("S2 "); +// Serial.println(sen2); +#endif // EVO_SCANN_SEN_2_ENABLED + +#if EVO_SCANN_SEN_3_ENABLED + uint16_t sen3Raw = (canMsg->data[5] << 8) | canMsg->data[6]; + int sen3 = (sen3Raw + 60000); +// Serial.print("S3 "); +// Serial.println(sen3); + +#endif // EVO_SCANN_SEN_3_ENABLED + +// Serial.print("R "); +// Serial.println(canMsg->data[7]); +} + +void evoScannMux1(CanMsgTemplate *canMsg) +{ +#if EVO_SCANN_SEN_4_ENABLED + uint16_t sen4Raw = (canMsg->data[1] << 8) | canMsg->data[2]; + int sen4 = (sen4Raw + 60000); + +// Serial.print("S4 "); +// Serial.println(sen4); +#endif // EVO_SCANN_SEN_4_ENABLED + +#if EVO_SCANN_SEN_5_ENABLED + uint16_t sen5Raw = (canMsg->data[3] << 8) | canMsg->data[4]; + int sen5 = (sen5Raw + 60000); + +// Serial.print("S5 "); +// Serial.println(sen5); +#endif // EVO_SCANN_SEN_5_ENABLED + +#if EVO_SCANN_SEN_6_ENABLED + uint16_t sen6Raw = (canMsg->data[5] << 8) | canMsg->data[6]; + int sen6 = (sen6Raw + 60000); + +// Serial.print("S6 "); +// Serial.println(sen6); +#endif // EVO_SCANN_SEN_6_ENABLED + +// Serial.print("T "); +// Serial.println(canMsg->data[7]); +} + +void evoScannMux2(CanMsgTemplate *canMsg) +{ +#if EVO_SCANN_SEN_7_ENABLED + uint16_t sen7Raw = (canMsg->data[1] << 8) | canMsg->data[2]; + int sen7 = (sen7Raw + 60000); + +// Serial.print("S7 "); +// Serial.println(sen7); +#endif // EVO_SCANN_SEN_7_ENABLED + +#if EVO_SCANN_SEN_8_ENABLED + uint16_t sen8Raw = (canMsg->data[3] << 8) | canMsg->data[4]; + int sen8 = (sen8Raw + 60000); + +// Serial.print("S8 "); +// Serial.println(sen8); +#endif // EVO_SCANN_SEN_8_ENABLED +} + +void evoScannNonMux(CanMsgTemplate *canMsg) +{ + (*evoScannFunc_ptrs[canMsg->data[0]])(canMsg); +} \ No newline at end of file diff --git a/sufst-controller/evoScann-p.h b/sufst-controller/evoScann-p.h new file mode 100644 index 0000000000000000000000000000000000000000..0f1fe1f6d1cb52f1dab1ad91637b5acb4e7a1890 --- /dev/null +++ b/sufst-controller/evoScann-p.h @@ -0,0 +1,23 @@ +// +// Created by Sil on 27/07/2019. +// + +#ifndef EVOSCANN_P_H +#define EVOSCANN_P_H + +#include "can.h" + +#define DEBUG_EVO_SCANN 1 + +#define EVO_SCANN_SEN_1_ENABLED 1 +#define EVO_SCANN_SEN_2_ENABLED 1 +#define EVO_SCANN_SEN_3_ENABLED 0 +#define EVO_SCANN_SEN_4_ENABLED 0 +#define EVO_SCANN_SEN_5_ENABLED 0 +#define EVO_SCANN_SEN_6_ENABLED 0 +#define EVO_SCANN_SEN_7_ENABLED 0 +#define EVO_SCANN_SEN_8_ENABLED 0 + +void evoScannNonMux(CanMsgTemplate *canMsg); + +#endif //EVOSCANN_P_H