migrated lot of stuff from Chainoiler-Project
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
DTCEntry_s DTCStorage[MAX_DTC_STORAGE];
|
||||
|
||||
void MaintainDTC(DTCNums_t DTC_no, boolean active)
|
||||
void MaintainDTC(DTCNums_t DTC_no, DTCSeverity_t DTC_severity, boolean active, uint32_t DebugValue)
|
||||
{
|
||||
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
||||
{
|
||||
@@ -10,13 +10,15 @@ void MaintainDTC(DTCNums_t DTC_no, boolean active)
|
||||
{
|
||||
if (active && DTCStorage[i].active != DTC_ACTIVE)
|
||||
{
|
||||
Serial.printf("DTC gone active: %d", DTC_no);
|
||||
Serial.printf("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)
|
||||
{
|
||||
Serial.printf("DTC gone previous: %d", DTC_no);
|
||||
Serial.printf("DTC gone previous: %d\n", DTC_no);
|
||||
DTCStorage[i].active = DTC_PREVIOUS;
|
||||
}
|
||||
return;
|
||||
@@ -31,10 +33,11 @@ void MaintainDTC(DTCNums_t DTC_no, boolean active)
|
||||
{
|
||||
if (DTCStorage[i].Number == DTC_LAST_DTC)
|
||||
{
|
||||
Serial.printf("new DTC registered: %d", DTC_no);
|
||||
Serial.printf("new DTC registered: %d, DebugVal: %d\n", DTC_no, DebugValue);
|
||||
DTCStorage[i].Number = DTC_no;
|
||||
DTCStorage[i].timestamp = millis();
|
||||
DTCStorage[i].active = DTC_ACTIVE;
|
||||
DTCStorage[i].debugVal = DebugValue;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -81,5 +84,25 @@ 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)
|
||||
{
|
||||
int8_t pointer = -1;
|
||||
uint32_t lasttimestamp = 0;
|
||||
|
||||
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
||||
{
|
||||
if (DTCStorage[i].Number > 0 && DTCStorage[i].timestamp > lasttimestamp)
|
||||
{
|
||||
if ((only_active == false || DTCStorage[i].active == DTC_ACTIVE) && DTCStorage[i].severity == severity)
|
||||
{
|
||||
pointer = i;
|
||||
lasttimestamp = DTCStorage[i].timestamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pointer >= 0 ? DTCStorage[pointer].Number : DTC_LAST_DTC;
|
||||
}
|
Reference in New Issue
Block a user