Compare commits

..

6 Commits

16 changed files with 212 additions and 76 deletions

View File

@ -75,13 +75,25 @@
<table class="table">
<tbody>
<tr>
<th class="col-md-4" scope="col">Timestamp</th>
<th class="col-md-4" scope="col">DTC</th>
<th class="col-md-4" scope="col">active</th>
<th class="col-md-3" scope="col">Zeitstempel</th>
<th class="col-md-3" scope="col">Fehlercode</th>
<th class="col-md-3" scope="col">Schwere</th>
<th class="col-md-3" scope="col">Aktiv</th>
</tr>
%DTC_TABLE%
</tbody>
</table>
<p>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseDTCDescription"
aria-expanded="false" aria-controls="collapseDTCDescription">
DTC Beschreibung
</button>
</p>
<div class="collapse" id="collapseDTCDescription">
<div class="card card-body">
<embed type="text/html" src="static/dtc.txt" width="100&#37;">
</div>
</div>
</div>
</p>
</div>
@ -252,24 +264,7 @@
<h3>Wartung</h3>
<hr>
<p>
<form action="\post.htm" method="POST" class="form-horizontal">
<div class="form-group">
<label for="purgepulse" class="control-label col-xs-5">Entl&uuml;ftung Impulse</label>
<div class="col-xs-7">
<div class="input-group">
<input id="purgepulse" name="purgepulse" value="%BLEEDING_PULSES%" type="text" class="form-control">
<div class="input-group-addon"></div>
</div>
</div>
</div>
<div class="form-group row">
<div class="col-xs-offset-5 col-xs-7">
<button name="maintsave" type="submit" class="btn btn-primary">Speichern</button>
</div>
</div>
</form>
</p>
<p>
<h4>&Ouml;lvorrat</h4>
<form action="\post.htm" method="POST" class="form-horizontal">
<div class="form-group">
<label for="tankremain_maint" class="control-label col-xs-5">Tankinhalt verbleibend</label>
@ -290,6 +285,53 @@
</div>
</form>
</p>
<hr>
<p>
<h4>Entl&uuml;ftung</h4>
<form action="\post.htm" method="POST" class="form-horizontal">
<div class="form-group">
<label for="purgepulse" class="control-label col-xs-5">Entl&uuml;ftung Dosierung</label>
<div class="col-xs-7">
<div class="input-group">
<input id="purgepulse" name="purgepulse" value="%BLEEDING_PULSES%" type="text" class="form-control">
<div class="input-group-addon">Pulse</div>
</div>
</div>
</div>
<div class="form-group row">
<div class="col-xs-offset-5 col-xs-7">
<button name="maintsave" type="submit" class="btn btn-primary">Speichern</button>
</div>
</div>
</form>
</p>
<hr>
<h4>EEPROM</h4>
<p>
<form action="\post.htm" method="POST" class="form-horizontal">
<div class="form-group">
<div class="col-xs-offset-5 col-xs-7">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="reset_ee_cfg_check">
<label class="form-check-label" for="reset_ee_cfg_check">
JA, EEPROM-Bereich "CFG" formatieren und Konfiguration zurück setzen
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="reset_ee_pds_check">
<label class="form-check-label" for="reset_ee_pds_check">
JA, EEPROM-Bereich "PDS" formatieren und Betriebsdaten zurück setzen
</label>
</div>
</div>
</div>
<div class="form-group row">
<div class="col-xs-offset-5 col-xs-7">
<button name="reset_ee_btn" type="submit" class="btn btn-primary">EEPROM formatieren</button>
</div>
</div>
</form>
</p>
</div>
<!-- Div Tab Maintenance -->
<!-- Div Tank Settings-->

View File

@ -0,0 +1,12 @@
1 - TANK_EMPTY
2 - DTC_TANK_LOW
3 - DTC_NO_EEPROM_FOUND
4 - DTC_EEPROM_CFG_BAD
5 - DTC_EEPROM_PDS_BAD
6 - DTC_EEPROM_PDSADRESS_BAD
7 - DTC_EEPROM_VERSION_BAD
8 - DTC_FLASHFS_ERROR
9 - DTC_FLASHFS_VERSION_ERROR
10 - DTC_NO_GPS_SERIAL
11 - DTC_CAN_TRANSCEIVER_FAILED
12 - DTC_NO_CAN_SIGNAL

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -7,7 +7,7 @@ void Init_CAN()
{
if (CAN0.begin(MCP_STDEXT, CAN_500KBPS, MCP_16MHZ) != CAN_OK)
MaintainDTC(DTC_CAN_TRANSCEIVER_FAILED, true);
MaintainDTC(DTC_CAN_TRANSCEIVER_FAILED, DTC_CRITICAL, true);
CAN0.init_Mask(0, 0, 0x07FF0000); // Init first mask...
CAN0.init_Mask(1, 0, 0x07FF0000); // Init second mask...
@ -39,7 +39,7 @@ uint32_t Process_CAN_WheelSpeed()
return milimeters_to_add;
}
MaintainDTC(DTC_NO_CAN_SIGNAL, (millis() > lastRecTimestamp + 10000 ? true : false));
MaintainDTC(DTC_NO_CAN_SIGNAL, DTC_CRITICAL, (millis() > lastRecTimestamp + 10000 ? true : false));
return 0;
}

View File

@ -29,6 +29,8 @@
#define SW_VERSION_MAJOR 1
#define SW_VERSION_MINOR 1
#define FLASH_FS_VERSION 1.1
#ifndef OTA_DELAY
#define OTA_DELAY 50 // ticks -> 10ms / tick
#endif

View File

@ -19,15 +19,6 @@ void InitEEPROM()
{
return;
}
GetConfig_EEPROM();
if (LubeConfig.EEPROM_Version != eeVersion)
{
FormatConfig_EEPROM();
globals.systemStatus = sysStat_Error;
MaintainDTC(DTC_EEPROM_VERSION_BAD, true);
return;
}
}
void EEPROM_Process()
@ -84,7 +75,7 @@ void GetConfig_EEPROM()
if (Checksum_EEPROM((uint8_t *)&LubeConfig, sizeof(LubeConfig)) != checksum)
{
MaintainDTC(DTC_EEPROM_CFG_BAD, true);
MaintainDTC(DTC_EEPROM_CFG_BAD, DTC_CRITICAL, true);
FormatConfig_EEPROM();
}
LubeConfig.checksum = checksum;
@ -118,7 +109,7 @@ void GetPersistence_EEPROM()
{
MovePersistencePage_EEPROM(true);
FormatPersistence_EEPROM();
MaintainDTC(DTC_EEPROM_PDSADRESS_BAD, true);
MaintainDTC(DTC_EEPROM_PDSADRESS_BAD, DTC_CRITICAL, true);
}
else
{
@ -129,7 +120,7 @@ void GetPersistence_EEPROM()
if (Checksum_EEPROM((uint8_t *)&PersistenceData, sizeof(PersistenceData)) != checksum)
{
MaintainDTC(DTC_EEPROM_PDS_BAD, true);
MaintainDTC(DTC_EEPROM_PDS_BAD, DTC_CRITICAL, true);
}
PersistenceData.checksum = checksum;
}
@ -224,10 +215,10 @@ boolean checkEEPROMavailable()
{
if (!ee.isConnected())
{
MaintainDTC(DTC_NO_EEPROM_FOUND, true);
MaintainDTC(DTC_NO_EEPROM_FOUND, DTC_CRITICAL, true);
globals.systemStatus = sysStat_Error;
return false;
}
MaintainDTC(DTC_NO_EEPROM_FOUND, false);
MaintainDTC(DTC_NO_EEPROM_FOUND, DTC_CRITICAL, false);
return true;
}

View File

@ -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)
{
for (int i = 0; i < MAX_DTC_STORAGE; i++)
{
@ -13,6 +13,7 @@ void MaintainDTC(DTCNums_t DTC_no, boolean active)
Serial.printf("DTC gone active: %d\n", DTC_no);
DTCStorage[i].timestamp = millis();
DTCStorage[i].active = DTC_ACTIVE;
DTCStorage[i].severity = DTC_severity;
}
if (!active && DTCStorage[i].active == DTC_ACTIVE)
{
@ -83,3 +84,23 @@ 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;
}

View File

@ -8,12 +8,14 @@
typedef enum DTCNums_e
{
DTC_TANK_EMPTY = 1,
DTC_TANK_LOW,
DTC_NO_EEPROM_FOUND,
DTC_EEPROM_CFG_BAD,
DTC_EEPROM_PDS_BAD,
DTC_EEPROM_PDSADRESS_BAD,
DTC_EEPROM_VERSION_BAD,
DTC_FLASHFS_ERROR,
DTC_FLASHFS_VERSION_ERROR,
#ifdef FEATURE_ENABLE_GPS
DTC_NO_GPS_SERIAL,
#endif
@ -31,17 +33,26 @@ typedef enum DTCActive_e
DTC_PREVIOUS
} DTCActive_t;
typedef enum DTCSeverity_e
{
DTC_INFO,
DTC_WARN,
DTC_CRITICAL
} DTCSeverity_t;
typedef struct DTCEntry_s
{
DTCNums_t Number;
uint32_t timestamp;
DTCActive_t active;
DTCSeverity_t severity;
} DTCEntry_t;
void MaintainDTC(DTCNums_t DTC_no, boolean active);
void MaintainDTC(DTCNums_t DTC_no, DTCSeverity_t DTC_severity, boolean active);
void ClearDTC(DTCNums_t DTC_no);
void ClearAllDTC();
DTCNums_t getlastDTC(boolean only_active);
DTCNums_t getlastDTC_Severity(boolean only_active, DTCSeverity_t severity);
extern DTCEntry_s DTCStorage[MAX_DTC_STORAGE];
#endif

View File

@ -18,9 +18,12 @@ typedef enum eEERequest
EE_IDLE,
EE_CFG_SAVE,
EE_CFG_LOAD,
EE_CFG_FORMAT,
EE_PDS_SAVE,
EE_PDS_LOAD,
EE_PDS_FORMAT,
EE_ALL_SAVE
} tEERequest;
typedef struct Globals_s
@ -31,8 +34,10 @@ typedef struct Globals_s
uint16_t purgePulses = 0;
eEERequest requestEEAction = EE_IDLE;
char DeviceName[33];
uint32_t FlashVersion;
char FlashVersion[5];
uint16_t eePersistanceAdress;
uint8_t TankPercentage;
bool hasDTC;
} Globals_t;
extern Globals_t globals;

View File

@ -51,7 +51,7 @@ uint32_t Process_GPS_WheelSpeed()
}
}
MaintainDTC(DTC_NO_GPS_SERIAL, (millis() > lastRecTimestamp + 10000));
MaintainDTC(DTC_NO_GPS_SERIAL,DTC_CRITICAL, (millis() > lastRecTimestamp + 10000));
return 0;
}

View File

@ -5,15 +5,22 @@ uint32_t lubePulseTimestamp = 0;
void RunLubeApp(uint32_t add_milimeters)
{
MaintainDTC(DTC_TANK_EMPTY, (PersistenceData.tankRemain_µl < LubeConfig.amountPerDose_µl));
globals.TankPercentage = PersistenceData.tankRemain_µl / (LubeConfig.tankCapacity_ml * 1000);
MaintainDTC(DTC_TANK_EMPTY, DTC_CRITICAL, (PersistenceData.tankRemain_µl < LubeConfig.amountPerDose_µl));
MaintainDTC(DTC_TANK_LOW, DTC_WARN, (globals.TankPercentage < LubeConfig.TankRemindAtPercentage));
static tSystem_Status preserverSysStatusError;
if (globals.systemStatus != sysStat_Error)
preserverSysStatusError = globals.systemStatus;
if (getlastDTC(true) < DTC_LAST_DTC)
if (getlastDTC(false) < DTC_LAST_DTC)
{
globals.hasDTC = true;
if (getlastDTC_Severity(true, DTC_CRITICAL) < DTC_LAST_DTC)
{
if (globals.systemStatus != sysStat_Error)
{
preserverSysStatusError = globals.systemStatus;
}
globals.systemStatus = sysStat_Error;
}
else
@ -23,6 +30,11 @@ void RunLubeApp(uint32_t add_milimeters)
globals.systemStatus = preserverSysStatusError;
}
}
}
else
{
globals.hasDTC = false;
}
// Add traveled Distance in mm
PersistenceData.TravelDistance_highRes_mm += add_milimeters;
@ -109,9 +121,13 @@ void RunLubeApp(uint32_t add_milimeters)
void LubePulse()
{
if (PersistenceData.tankRemain_µl > 0) // Only Lube if theres Oil remaining!
{
lubePulseTimestamp = millis() + LUBE_PULSE_LENGHT_MS;
if (PersistenceData.tankRemain_µl < LubeConfig.amountPerDose_µl)
if (PersistenceData.tankRemain_µl < LubeConfig.amountPerDose_µl) // Prevent underrun and shiftover
PersistenceData.tankRemain_µl = 0;
else
PersistenceData.tankRemain_µl = PersistenceData.tankRemain_µl - LubeConfig.amountPerDose_µl;
}
}

View File

@ -11,6 +11,8 @@
#include "common.h"
#include "sanitycheck.h"
#include "lubeapp.h"
#include "webui.h"
#include "config.h"
@ -94,7 +96,7 @@ void setup()
#ifdef FEATURE_ENABLE_WIFI_CLIENT
WiFi.mode(WIFI_STA);
WiFi.setHostname(globals.DeviceName);
wifiMulti.addAP(QUOTE(WIFI_SSID), QUOTE(WIFI_PASSWORD));
wifiMulti.addAP(QUOTE(WIFI_SSID_CLIENT), QUOTE(WIFI_PASSWORD_CLIENT));
WiFiMaintainConnectionTicker.start();
#else
WiFi.mode(WIFI_OFF);
@ -504,14 +506,12 @@ void LED_Process(uint8_t override, CRGB SetColor)
oldSysStatus = globals.systemStatus;
}
uint32_t percentage = PersistenceData.tankRemain_µl / (LubeConfig.tankCapacity_ml * 1000);
switch (LED_Status)
{
case LED_Startup:
FastLED.setBrightness(255);
if (percentage < LubeConfig.TankRemindAtPercentage)
if (globals.TankPercentage < LubeConfig.TankRemindAtPercentage)
leds[0] = CRGB::OrangeRed;
else
leds[0] = CRGB::White;

View File

@ -7,6 +7,13 @@
#if PCB_REV < 1 || PCB_REV > 4
#error "Unsupported PCB-Revision"
#endif
#if PCB_REV < 4 && defined(FEATURE_ENABLE_CAN)
#error "CAN-Feature unsupported with this PCB-Rev"
#endif
#if PCB_REV < 4 && defined(DFEATURE_ENABLE_GPS)
#error "CAN-Feature unsupported with this PCB-Rev"
#endif
#endif
#ifndef ADMIN_PASSWORD

View File

@ -16,11 +16,16 @@ void initWebUI()
if (!LittleFS.begin())
{
Serial.println("An Error has occurred while mounting LittleFS");
MaintainDTC(DTC_FLASHFS_ERROR, true);
MaintainDTC(DTC_FLASHFS_ERROR, DTC_CRITICAL, true);
return;
}
globals.FlashVersion = GetFlashVersion();
GetFlashVersion(globals.FlashVersion, sizeof(globals.FlashVersion));
if (!strcmp(globals.FlashVersion, QUOTE(FLASH_FS_VERSION))
{
MaintainDTC(DTC_FLASHFS_VERSION_ERROR, DTC_WARN, true);
}
MDNS.begin(globals.DeviceName);
MDNS.addService("telnet", "tcp", 23);
@ -117,7 +122,7 @@ String processor(const String &var)
return "hidden";
#endif
if (var == "SHOW_DTC_TABLE")
return globals.systemStatus == sysStat_Error ? "" : "hidden";
return globals.hasDTC ? "" : "hidden";
if (var == "DTC_TABLE")
{
@ -137,6 +142,20 @@ String processor(const String &var)
temp = temp + "<tr><td>" + String(buff_timestamp);
temp = temp + "</td><td>" + String(DTCStorage[i].Number) + "</td><td>";
temp = temp + "<img src=static/img/";
switch (DTCStorage[i].severity)
{
case DTC_CRITICAL:
temp = temp + "critical";
break;
case DTC_WARN:
temp = temp + "warn";
break;
case DTC_INFO:
temp = temp + "info";
break;
}
temp = temp + "_black.png></td><td>";
if (DTCStorage[i].active == DTC_ACTIVE)
temp = temp + "active";
@ -289,6 +308,15 @@ void WebserverPOST_Callback(AsyncWebServerRequest *request)
PersistenceData.tankRemain_µl = LubeConfig.tankCapacity_ml * 1000;
globals.requestEEAction = EE_PDS_SAVE;
}
if (p->name() == "reset_ee_cfg")
{
globals.requestEEAction = EE_CFG_FORMAT;
}
if (p->name() == "reset_ee_pds")
{
globals.requestEEAction = EE_PDS_FORMAT;
}
// end: POST Form Maintenance
}
}
@ -298,20 +326,21 @@ void WebserverNotFound_Callback(AsyncWebServerRequest *request)
request->send(404, "text/html", "Not found");
}
uint32_t GetFlashVersion()
void GetFlashVersion(char *buff, size_t buff_size)
{
char buffer[20];
File this_file = LittleFS.open("version", "r");
if (!this_file)
{ // failed to open the file, retrn empty result
return 0;
buff[0] = '\0';
return;
}
if (this_file.available())
{
this_file.readBytesUntil('\r', buffer, sizeof(buffer));
int bytes_read;
bytes_read = this_file.readBytesUntil('\r', buff, buff_size-1);
buff[bytes_read] = '\0';
}
this_file.close();
return atoi(buffer);
}
void WebserverFirmwareUpdate_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final)