reworked DTC-Data handling
This commit is contained in:
@@ -10,7 +10,7 @@ void Init_CAN()
|
||||
{
|
||||
|
||||
if (CAN0.begin(MCP_STDEXT, CAN_500KBPS, MCP_16MHZ) != CAN_OK)
|
||||
MaintainDTC(DTC_CAN_TRANSCEIVER_FAILED, DTC_CRITICAL, true);
|
||||
MaintainDTC(DTC_CAN_TRANSCEIVER_FAILED, true);
|
||||
|
||||
CAN0.init_Mask(0, 0, 0x07FF0000); // Init first mask...
|
||||
CAN0.init_Mask(1, 0, 0x07FF0000); // Init second mask...
|
||||
@@ -55,7 +55,7 @@ uint32_t Process_CAN_WheelSpeed()
|
||||
|
||||
if (lastRecTimestamp > 1000)
|
||||
{
|
||||
MaintainDTC(DTC_NO_CAN_SIGNAL, DTC_CRITICAL, (millis() > lastRecTimestamp + 10000 ? true : false));
|
||||
MaintainDTC(DTC_NO_CAN_SIGNAL, (millis() > lastRecTimestamp + 10000 ? true : false));
|
||||
}
|
||||
|
||||
return milimeters_to_add;
|
||||
|
@@ -83,6 +83,12 @@ void StoreConfig_EEPROM()
|
||||
return;
|
||||
|
||||
ee.updateBlock(startofLubeConfig, (uint8_t *)&LubeConfig, sizeof(LubeConfig));
|
||||
|
||||
uint32_t ConfigSanityCheckResult = ConfigSanityCheck(false);
|
||||
if (ConfigSanityCheckResult > 0)
|
||||
{
|
||||
MaintainDTC(DTC_EEPROM_CFG_SANITY, true, ConfigSanityCheckResult);
|
||||
}
|
||||
}
|
||||
|
||||
void GetConfig_EEPROM()
|
||||
@@ -97,16 +103,14 @@ void GetConfig_EEPROM()
|
||||
|
||||
if (Checksum_EEPROM((uint8_t *)&LubeConfig, sizeof(LubeConfig)) != checksum)
|
||||
{
|
||||
MaintainDTC(DTC_EEPROM_CFG_BAD, DTC_CRITICAL, true);
|
||||
MaintainDTC(DTC_EEPROM_CFG_BAD, true);
|
||||
}
|
||||
LubeConfig.checksum = checksum;
|
||||
|
||||
uint32_t ConfigSanityCheckResult = ConfigSanityCheck(false);
|
||||
|
||||
if (ConfigSanityCheckResult > 0)
|
||||
{
|
||||
MaintainDTC(DTC_EEPROM_CFG_SANITY, DTC_WARN, true, ConfigSanityCheckResult);
|
||||
globals.requestEEAction = EE_CFG_SAVE;
|
||||
MaintainDTC(DTC_EEPROM_CFG_SANITY, true, ConfigSanityCheckResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +142,7 @@ void GetPersistence_EEPROM()
|
||||
{
|
||||
MovePersistencePage_EEPROM(true);
|
||||
FormatPersistence_EEPROM();
|
||||
MaintainDTC(DTC_EEPROM_PDSADRESS_BAD, DTC_CRITICAL, true);
|
||||
MaintainDTC(DTC_EEPROM_PDSADRESS_BAD, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -149,7 +153,7 @@ void GetPersistence_EEPROM()
|
||||
|
||||
if (Checksum_EEPROM((uint8_t *)&PersistenceData, sizeof(PersistenceData)) != checksum)
|
||||
{
|
||||
MaintainDTC(DTC_EEPROM_PDS_BAD, DTC_CRITICAL, true);
|
||||
MaintainDTC(DTC_EEPROM_PDS_BAD, true);
|
||||
}
|
||||
PersistenceData.checksum = checksum;
|
||||
}
|
||||
@@ -245,10 +249,10 @@ boolean checkEEPROMavailable()
|
||||
{
|
||||
if (!ee.isConnected())
|
||||
{
|
||||
MaintainDTC(DTC_NO_EEPROM_FOUND, DTC_CRITICAL, true);
|
||||
MaintainDTC(DTC_NO_EEPROM_FOUND, true);
|
||||
return false;
|
||||
}
|
||||
MaintainDTC(DTC_NO_EEPROM_FOUND, DTC_CRITICAL, false);
|
||||
MaintainDTC(DTC_NO_EEPROM_FOUND, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -325,7 +325,7 @@ void Debug_ShowDTCs()
|
||||
else
|
||||
strcpy(buff_active, "none");
|
||||
|
||||
Debug_pushMessage("%s %7d %8s %8d\n", buff_timestamp, DTCStorage[i].Number, buff_active, DTCStorage[i].severity);
|
||||
Debug_pushMessage("%s %7d %8s %8d\n", buff_timestamp, DTCStorage[i].Number, buff_active);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#include "dtc.h"
|
||||
#include "debugger.h"
|
||||
|
||||
DTCEntry_s DTCStorage[MAX_DTC_STORAGE];
|
||||
DTCEntry_t DTCStorage[MAX_DTC_STORAGE];
|
||||
|
||||
void MaintainDTC(DTCNums_t DTC_no, DTCSeverity_t DTC_severity, boolean active, uint32_t DebugValue)
|
||||
void MaintainDTC(DTCNum_t DTC_no, boolean active, uint32_t DebugValue)
|
||||
{
|
||||
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
||||
{
|
||||
@@ -14,7 +14,6 @@ void MaintainDTC(DTCNums_t DTC_no, DTCSeverity_t DTC_severity, boolean active, u
|
||||
Debug_pushMessage("DTC gone active: %d, DebugVal: %d\n", DTC_no, DebugValue);
|
||||
DTCStorage[i].timestamp = millis();
|
||||
DTCStorage[i].active = DTC_ACTIVE;
|
||||
DTCStorage[i].severity = DTC_severity;
|
||||
DTCStorage[i].debugVal = DebugValue;
|
||||
}
|
||||
if (!active && DTCStorage[i].active == DTC_ACTIVE)
|
||||
@@ -39,21 +38,20 @@ void MaintainDTC(DTCNums_t DTC_no, DTCSeverity_t DTC_severity, boolean active, u
|
||||
DTCStorage[i].timestamp = millis();
|
||||
DTCStorage[i].active = DTC_ACTIVE;
|
||||
DTCStorage[i].debugVal = DebugValue;
|
||||
DTCStorage[i].severity = DTC_severity;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClearDTC(DTCNums_t DTC_no)
|
||||
void ClearDTC(DTCNum_t DTC_no)
|
||||
{
|
||||
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
||||
{
|
||||
if (DTCStorage[i].Number == DTC_no)
|
||||
{
|
||||
DTCStorage[i].Number = DTC_LAST_DTC;
|
||||
DTCStorage[i].active = DTC_NONE;
|
||||
DTCStorage[i].active = DTC_INACTIVE;
|
||||
DTCStorage[i].timestamp = 0;
|
||||
}
|
||||
}
|
||||
@@ -64,12 +62,12 @@ void ClearAllDTC()
|
||||
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
||||
{
|
||||
DTCStorage[i].Number = DTC_LAST_DTC;
|
||||
DTCStorage[i].active = DTC_NONE;
|
||||
DTCStorage[i].active = DTC_INACTIVE;
|
||||
DTCStorage[i].timestamp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
DTCNums_t getlastDTC(boolean only_active)
|
||||
DTCNum_t getlastDTC(boolean only_active)
|
||||
{
|
||||
int8_t pointer = -1;
|
||||
uint32_t lasttimestamp = 0;
|
||||
@@ -89,34 +87,28 @@ DTCNums_t getlastDTC(boolean only_active)
|
||||
return pointer >= 0 ? DTCStorage[pointer].Number : DTC_LAST_DTC;
|
||||
}
|
||||
|
||||
DTCNums_t getlastDTC_Severity(boolean only_active, DTCSeverity_t severity)
|
||||
DTCSeverity_t getSeverityForDTC(DTCNum_t targetCode)
|
||||
{
|
||||
int8_t pointer = -1;
|
||||
uint32_t lasttimestamp = 0;
|
||||
|
||||
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
||||
for (int i = 0; i < DTC_LAST_DTC; i++)
|
||||
{
|
||||
if (DTCStorage[i].Number > 0 && DTCStorage[i].timestamp > lasttimestamp)
|
||||
if (dtc_definitions[i].code == targetCode)
|
||||
{
|
||||
if ((only_active == false || DTCStorage[i].active == DTC_ACTIVE) && DTCStorage[i].severity == severity)
|
||||
{
|
||||
pointer = i;
|
||||
lasttimestamp = DTCStorage[i].timestamp;
|
||||
}
|
||||
return dtc_definitions[i].severity;
|
||||
}
|
||||
}
|
||||
|
||||
return pointer >= 0 ? DTCStorage[pointer].Number : DTC_LAST_DTC;
|
||||
return DTC_NONE;
|
||||
}
|
||||
|
||||
void DTC_Process()
|
||||
{
|
||||
static tSystem_Status preserverSysStatusError;
|
||||
DTCNum_t lastDTC = getlastDTC(true);
|
||||
|
||||
if (getlastDTC(false) < DTC_LAST_DTC)
|
||||
if (lastDTC < DTC_LAST_DTC)
|
||||
{
|
||||
globals.hasDTC = true;
|
||||
if (getlastDTC_Severity(true, DTC_CRITICAL) < DTC_LAST_DTC && globals.systemStatus != sysStat_Shutdown)
|
||||
|
||||
if (getSeverityForDTC(lastDTC) == DTC_CRITICAL && globals.systemStatus != sysStat_Shutdown)
|
||||
{
|
||||
if (globals.systemStatus != sysStat_Error)
|
||||
{
|
||||
@@ -124,16 +116,14 @@ void DTC_Process()
|
||||
}
|
||||
globals.systemStatus = sysStat_Error;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (globals.systemStatus == sysStat_Error)
|
||||
{
|
||||
globals.systemStatus = preserverSysStatusError;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
globals.hasDTC = false;
|
||||
|
||||
if (globals.systemStatus == sysStat_Error)
|
||||
{
|
||||
globals.systemStatus = preserverSysStatusError;
|
||||
}
|
||||
}
|
||||
}
|
16
Software/src/dtc_defs.txt
Normal file
16
Software/src/dtc_defs.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
# No. | DTC-Constant | Severity | Title | Description
|
||||
#-----|------------------------------|---------------|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
1; DTC_TANK_EMPTY; DTC_CRITICAL; Ölvorrat leer; Ölvorrat ist komplett leer. Den Ölvorrat auffüllen und im Menu 'Wartung' zurück setzen
|
||||
2; DTC_TANK_LOW; DTC_WARN; Ölvorrat niedrig; Ölvorrat ist unter der Warnschwelle. Den Ölvorrat demnächst auffüllen und im Menu 'Wartung' zurück setzen
|
||||
3; DTC_NO_EEPROM_FOUND; DTC_CRITICAL; kein EEPROM erkannt; Es wurde kein EEPROM gefunden. Dies lässt einen Hardware-Defekt vermuten.
|
||||
4; DTC_EEPROM_CFG_BAD; DTC_CRITICAL; EEPROM CFG Checksumme; Die Checksumme der Config-Partition des EEPROM ist ungültig. Setzen sie den EEPROM-Bereich 'CFG' im Menu 'Wartung' zurück
|
||||
5; DTC_EEPROM_PDS_BAD; DTC_CRITICAL; EEPROM PDS Checksumme; Die Checksumme der Betriebsdaten-Partition des EEPROM ist ungültig. Setzen sie den EEPROM-Bereich 'PDS' im Menu 'Wartung' zurück
|
||||
6; DTC_EEPROM_PDSADRESS_BAD; DTC_CRITICAL; EEPROM PDS Adresse; Die Adresse der Betriebsdaten-Partition im EEPROM ist ungültig. Setzen sie den EEPROM-Bereich 'PDS' im Menu 'Wartung' zurück
|
||||
7; DTC_EEPROM_VERSION_BAD; DTC_CRITICAL; EEPROM Version falsch; Die Layout-Version des EEPROM stimmt nicht mit der Firmware-Version überein. Setzen sie den EEPROM-Bereich 'CFG' im Menu 'Wartung' zurück
|
||||
8; DTC_FLASHFS_ERROR; DTC_CRITICAL; Flashspeicher Fehler; Der Flashspeicher konnte nicht initialisiert werden. Aktualisieren sie Flash & Firmware
|
||||
9; DTC_FLASHFS_VERSION_ERROR; DTC_CRITICAL; Flashversion falsch; Die Version des Flashspeicher stimmt nicht mit der Firmware-Version überein. Aktualisieren sie den Flash mit der passenden Update-Datei
|
||||
10; DTC_NO_GPS_SERIAL; DTC_CRITICAL; Keine GPS-Verbindung; Es wurde kein GPS-Signal über die serielle Schnittstelle empfangen, Prüfen sie die Verbindung und das GPS-Modul
|
||||
11; DTC_CAN_TRANSCEIVER_FAILED; DTC_CRITICAL; CAN-Transceiver Error; Es konnte keine Verbindung zum CAN-Transceiver hergestellt werden. Prüfen Sie die Hardware auf Defekte
|
||||
12; DTC_NO_CAN_SIGNAL; DTC_WARN; Keine CAN-Verbindung; Es konnte kein CAN-Signal empfangen werden. Prüfen sie die Verbindung und die Einstellungen
|
||||
13; DTC_EEPROM_CFG_SANITY; DTC_WARN; Config-Validierung; Ein oder mehrer Einstellungswerte sind ausserhalb plausibler Werte. Prüfen Sie Ihre Einstellungen
|
||||
|
@@ -7,8 +7,8 @@ void RunLubeApp(uint32_t add_milimeters)
|
||||
|
||||
globals.TankPercentage = PersistenceData.tankRemain_microL / (LubeConfig.tankCapacity_ml * 10);
|
||||
|
||||
MaintainDTC(DTC_TANK_EMPTY, DTC_CRITICAL, (PersistenceData.tankRemain_microL < LubeConfig.amountPerDose_microL));
|
||||
MaintainDTC(DTC_TANK_LOW, DTC_WARN, (globals.TankPercentage < LubeConfig.TankRemindAtPercentage));
|
||||
MaintainDTC(DTC_TANK_EMPTY, (PersistenceData.tankRemain_microL < LubeConfig.amountPerDose_microL));
|
||||
MaintainDTC(DTC_TANK_LOW, (globals.TankPercentage < LubeConfig.TankRemindAtPercentage));
|
||||
|
||||
// Add traveled Distance in mm
|
||||
PersistenceData.TravelDistance_highRes_mm += add_milimeters;
|
||||
|
@@ -19,6 +19,7 @@ AsyncWebSocket webSocket("/ws");
|
||||
|
||||
void WebsocketEvent_Callback(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len);
|
||||
void Websocket_HandleMessage(void *arg, uint8_t *data, size_t len);
|
||||
void Websocket_RefreshClientData_DTCs();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,7 +28,7 @@ void initWebUI()
|
||||
if (!LittleFS.begin())
|
||||
{
|
||||
Debug_pushMessage("An Error has occurred while mounting LittleFS\n");
|
||||
MaintainDTC(DTC_FLASHFS_ERROR, DTC_CRITICAL, true);
|
||||
MaintainDTC(DTC_FLASHFS_ERROR, true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,7 +38,7 @@ void initWebUI()
|
||||
snprintf(buffer, sizeof(buffer), "%d.%02d", constants.Required_Flash_Version_major, constants.Required_Flash_Version_minor);
|
||||
if (strcmp(globals.FlashVersion, buffer))
|
||||
{
|
||||
MaintainDTC(DTC_FLASHFS_VERSION_ERROR, DTC_WARN, true);
|
||||
MaintainDTC(DTC_FLASHFS_VERSION_ERROR, true);
|
||||
}
|
||||
|
||||
MDNS.begin(globals.DeviceName);
|
||||
@@ -183,7 +184,7 @@ String processor(const String &var)
|
||||
temp = temp + " data-debugval=" + String(DTCStorage[i].debugVal) + "><td>" + String(buff_timestamp);
|
||||
temp = temp + "</td><td>" + String(DTCStorage[i].Number) + "</td><td>";
|
||||
temp = temp + "<img src=static/img/";
|
||||
switch (DTCStorage[i].severity)
|
||||
switch (getSeverityForDTC(DTCStorage[i].Number))
|
||||
{
|
||||
case DTC_CRITICAL:
|
||||
temp = temp + "critical";
|
||||
@@ -194,6 +195,9 @@ String processor(const String &var)
|
||||
case DTC_INFO:
|
||||
temp = temp + "info";
|
||||
break;
|
||||
case DTC_NONE:
|
||||
temp = temp + "none";
|
||||
break;
|
||||
}
|
||||
temp = temp + ".png></td><td>";
|
||||
|
||||
|
Reference in New Issue
Block a user