From 7a84b801269108abe1c7dde10260f1a1f54a5209 Mon Sep 17 00:00:00 2001 From: Marcel Peterkau Date: Tue, 8 Mar 2022 21:23:06 +0100 Subject: [PATCH] added dtcs for Signal-Timeout and empty tank --- Software/ChainLube/src/can.cpp | 14 ++++++++++++++ Software/ChainLube/src/can.h | 2 ++ Software/ChainLube/src/dtc.h | 2 ++ Software/ChainLube/src/gps.cpp | 9 ++++++++- Software/ChainLube/src/lubeapp.cpp | 12 ++++++++++++ Software/ChainLube/src/lubeapp.h | 1 + 6 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Software/ChainLube/src/can.cpp b/Software/ChainLube/src/can.cpp index 277f6ba..ef0d54c 100644 --- a/Software/ChainLube/src/can.cpp +++ b/Software/ChainLube/src/can.cpp @@ -39,5 +39,19 @@ uint32_t Process_CAN_WheelSpeed() return milimeters_to_add; } + + if (millis() > lastRecTimestamp + 10000) + { + if (globals.systemStatus != sysStat_Shutdown) + globals.systemStatus = sysStat_Error; + MaintainDTC(DTC_NO_CAN_SIGNAL, true); + } + else + { + if (globals.systemStatus != sysStat_Shutdown) + globals.systemStatus = globals.resumeStatus; + MaintainDTC(DTC_NO_CAN_SIGNAL, false); + } + return 0; } diff --git a/Software/ChainLube/src/can.h b/Software/ChainLube/src/can.h index 37aa013..b646297 100644 --- a/Software/ChainLube/src/can.h +++ b/Software/ChainLube/src/can.h @@ -5,6 +5,8 @@ #include #include #include "common.h" +#include "globals.h" +#include "dtc.h" struct can_frame { diff --git a/Software/ChainLube/src/dtc.h b/Software/ChainLube/src/dtc.h index 3ed4a00..21ee505 100644 --- a/Software/ChainLube/src/dtc.h +++ b/Software/ChainLube/src/dtc.h @@ -6,6 +6,8 @@ #define MAX_DTC_STORAGE 16 #define DTC_NO_GPS_SERIAL 100 +#define DTC_NO_CAN_SIGNAL 101 +#define DTC_TANK_EMPTY 102 typedef enum DTCActive_e { diff --git a/Software/ChainLube/src/gps.cpp b/Software/ChainLube/src/gps.cpp index 46ce049..2b79c23 100644 --- a/Software/ChainLube/src/gps.cpp +++ b/Software/ChainLube/src/gps.cpp @@ -52,9 +52,16 @@ uint32_t Process_GPS_WheelSpeed() if (millis() > lastRecTimestamp + 10000) { - globals.systemStatus = sysStat_Error; + if (globals.systemStatus != sysStat_Shutdown) + globals.systemStatus = sysStat_Error; MaintainDTC(DTC_NO_GPS_SERIAL, true); } + else + { + if (globals.systemStatus != sysStat_Shutdown) + globals.systemStatus = globals.resumeStatus; + MaintainDTC(DTC_NO_GPS_SERIAL, false); + } return 0; } diff --git a/Software/ChainLube/src/lubeapp.cpp b/Software/ChainLube/src/lubeapp.cpp index c032867..2657095 100644 --- a/Software/ChainLube/src/lubeapp.cpp +++ b/Software/ChainLube/src/lubeapp.cpp @@ -4,6 +4,17 @@ uint32_t lubePulseTimestamp = 0; void RunLubeApp(uint32_t add_milimeters) { + if (PersistenceData.tankRemain_µl < LubeConfig.amountPerDose_µl) + { + MaintainDTC(DTC_TANK_EMPTY, true); + } + else + { + if (globals.systemStatus != sysStat_Shutdown) + globals.systemStatus = globals.resumeStatus; + MaintainDTC(DTC_TANK_EMPTY, false); + } + // Add traveled Distance in mm PersistenceData.TravelDistance_highRes += add_milimeters; @@ -47,6 +58,7 @@ void RunLubeApp(uint32_t add_milimeters) } break; case sysStat_Error: + case sysStat_Shutdown: default: break; } diff --git a/Software/ChainLube/src/lubeapp.h b/Software/ChainLube/src/lubeapp.h index 70c9b2f..5f351fe 100644 --- a/Software/ChainLube/src/lubeapp.h +++ b/Software/ChainLube/src/lubeapp.h @@ -6,6 +6,7 @@ #include "config.h" #include "common.h" #include "globals.h" +#include "dtc.h" #define LUBE_PULSE_LENGHT_MS 160 #define LUBE_PULSE_PAUSE_MS 100