Compare commits

...

2 Commits

Author SHA1 Message Date
fbe5f0b202 added debug-Function for EE-Sanity-Check 2024-02-12 00:46:26 +01:00
f92f6a23c7 reworked some DTC-Handling 2024-02-12 00:45:34 +01:00
3 changed files with 50 additions and 36 deletions

View File

@ -145,19 +145,14 @@ void GetConfig_EEPROM()
uint32_t checksum = LubeConfig.checksum;
LubeConfig.checksum = 0;
if (Checksum_EEPROM((uint8_t *)&LubeConfig, sizeof(LubeConfig)) != checksum)
{
MaintainDTC(DTC_EEPROM_CFG_BAD, true);
}
MaintainDTC(DTC_EEPROM_CFG_BAD, (Checksum_EEPROM((uint8_t *)&LubeConfig, sizeof(LubeConfig)) != checksum));
LubeConfig.checksum = checksum;
uint32_t ConfigSanityCheckResult = ConfigSanityCheck(false);
if (ConfigSanityCheckResult > 0)
{
MaintainDTC(DTC_EEPROM_CFG_SANITY, true, ConfigSanityCheckResult);
}
MaintainDTC(DTC_EEPROM_CFG_SANITY, (ConfigSanityCheckResult > 0), ConfigSanityCheckResult);
}
/**
@ -210,10 +205,8 @@ void GetPersistence_EEPROM()
uint32_t checksum = PersistenceData.checksum;
PersistenceData.checksum = 0;
if (Checksum_EEPROM((uint8_t *)&PersistenceData, sizeof(PersistenceData)) != checksum)
{
MaintainDTC(DTC_EEPROM_PDS_BAD, true);
}
MaintainDTC(DTC_EEPROM_PDS_BAD, (Checksum_EEPROM((uint8_t *)&PersistenceData, sizeof(PersistenceData)) != checksum));
PersistenceData.checksum = checksum;
}
}

View File

@ -15,18 +15,18 @@
DebugStatus_t DebuggerStatus[dbg_cntElements];
String IpAddress2String(const IPAddress &ipAddress);
void processCmdDebug(String command);
void Debug_formatCFG();
void Debug_formatPersistence();
void Debug_printSystemInfo();
void Debug_printWifiInfo();
void Debug_CheckEEPOM();
void Debug_CheckEEPOM(bool autocorrect);
void Debug_dumpConfig();
void Debug_dumpPersistance();
void Debug_ShowDTCs();
void Debug_dumpGlobals();
void Debug_printHelp();
const char *uint32_to_binary_string(uint32_t num);
/**
* @brief Initializes the debugger by setting the initial status for different debug ports.
@ -119,7 +119,7 @@ void Debug_Process()
default:
break;
}
if (InputProcessed != IDLE)
Serial.print(">");
@ -236,7 +236,9 @@ void processCmdDebug(String command)
else if (command == "formatPDS")
Debug_formatPersistence();
else if (command == "checkEE")
Debug_CheckEEPOM();
Debug_CheckEEPOM(false);
else if (command == "checkEEfix")
Debug_CheckEEPOM(true);
else if (command == "dumpEE1k")
dumpEEPROM(0, 1024);
else if (command == "dumpEE")
@ -377,14 +379,14 @@ void Debug_dumpPersistance()
*/
void Debug_printWifiInfo()
{
// Add relevant code here if needed
Debug_pushMessage("IP Adress: %s\n", WiFi.localIP().toString().c_str());
}
/**
* @brief Checks the EEPROM data integrity by calculating and comparing checksums.
* Prints the result to the debug output.
*/
void Debug_CheckEEPOM()
void Debug_CheckEEPOM(bool autocorrect)
{
// Check PersistenceData EEPROM checksum
uint32_t checksum = PersistenceData.checksum;
@ -414,6 +416,17 @@ void Debug_CheckEEPOM()
Debug_pushMessage("LubeConfig EEPROM Checksum BAD\n");
}
LubeConfig.checksum = checksum;
uint32_t sanitycheck = ConfigSanityCheck(autocorrect);
if (sanitycheck == 0)
{
Debug_pushMessage("LubeConfig Sanity Check OK\n");
}
else
{
Debug_pushMessage("LubeConfig Sanity Check BAD: %s\n", uint32_to_binary_string(sanitycheck));
}
}
/**
@ -474,3 +487,29 @@ void Debug_printHelp()
Debug_pushMessage(buff);
}
}
/**
* @brief Convert a uint32_t value to a binary string with nibbles separated by a space.
*
* This function takes a uint32_t value and converts it to a binary string
* representation. The binary string is stored in a static buffer and returned
* as a const char pointer. Each nibble (4 bits) in the binary representation
* is separated by a space. The buffer is overwritten on subsequent calls to
* this function.
*
* @param num The uint32_t value to convert.
* @return A pointer to a const char string containing the binary representation
* of the input number with nibbles separated by a space.
*/
const char* uint32_to_binary_string(uint32_t num) {
static char binary_str[65]; // 32 bits + 31 spaces + null terminator
int i, j;
for (i = 31, j = 0; i >= 0; i--, j++) {
binary_str[j] = ((num >> i) & 1) ? '1' : '0';
if (i % 4 == 0 && i != 0) {
binary_str[++j] = ' '; // Insert space after every nibble
}
}
binary_str[j] = '\0'; // Null terminator
return binary_str;
}

View File

@ -266,24 +266,6 @@ void loop()
yield();
}
/**
* @brief Converts an IPAddress object to a String representation.
*
* This function takes an IPAddress object and converts it into a String representing
* the IPv4 address. Each octet of the address is separated by a dot.
*
* @param ipAddress The IPAddress object to be converted.
* @return A String representing the IPv4 address.
*/
String IpAddress2String(const IPAddress &ipAddress)
{
// Concatenate each octet of the IPAddress with dots in between
return String(ipAddress[0]) + String(".") +
String(ipAddress[1]) + String(".") +
String(ipAddress[2]) + String(".") +
String(ipAddress[3]);
}
#ifdef FEATURE_ENABLE_WIFI_CLIENT
/**
* @brief Callback function for maintaining WiFi connection and handling connection failures.