Compare commits

..

No commits in common. "fbe5f0b2022dd6a7c1a67a39df7a393aaae30ccb" and "ac8be93fafce9a570e63d8c38fa618b972726645" have entirely different histories.

3 changed files with 36 additions and 50 deletions

View File

@ -145,14 +145,19 @@ void GetConfig_EEPROM()
uint32_t checksum = LubeConfig.checksum;
LubeConfig.checksum = 0;
MaintainDTC(DTC_EEPROM_CFG_BAD, (Checksum_EEPROM((uint8_t *)&LubeConfig, sizeof(LubeConfig)) != checksum));
if (Checksum_EEPROM((uint8_t *)&LubeConfig, sizeof(LubeConfig)) != checksum)
{
MaintainDTC(DTC_EEPROM_CFG_BAD, true);
}
LubeConfig.checksum = checksum;
uint32_t ConfigSanityCheckResult = ConfigSanityCheck(false);
MaintainDTC(DTC_EEPROM_CFG_SANITY, (ConfigSanityCheckResult > 0), ConfigSanityCheckResult);
if (ConfigSanityCheckResult > 0)
{
MaintainDTC(DTC_EEPROM_CFG_SANITY, true, ConfigSanityCheckResult);
}
}
/**
@ -205,8 +210,10 @@ void GetPersistence_EEPROM()
uint32_t checksum = PersistenceData.checksum;
PersistenceData.checksum = 0;
MaintainDTC(DTC_EEPROM_PDS_BAD, (Checksum_EEPROM((uint8_t *)&PersistenceData, sizeof(PersistenceData)) != checksum));
if (Checksum_EEPROM((uint8_t *)&PersistenceData, sizeof(PersistenceData)) != checksum)
{
MaintainDTC(DTC_EEPROM_PDS_BAD, true);
}
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(bool autocorrect);
void Debug_CheckEEPOM();
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,9 +236,7 @@ void processCmdDebug(String command)
else if (command == "formatPDS")
Debug_formatPersistence();
else if (command == "checkEE")
Debug_CheckEEPOM(false);
else if (command == "checkEEfix")
Debug_CheckEEPOM(true);
Debug_CheckEEPOM();
else if (command == "dumpEE1k")
dumpEEPROM(0, 1024);
else if (command == "dumpEE")
@ -379,14 +377,14 @@ void Debug_dumpPersistance()
*/
void Debug_printWifiInfo()
{
Debug_pushMessage("IP Adress: %s\n", WiFi.localIP().toString().c_str());
// Add relevant code here if needed
}
/**
* @brief Checks the EEPROM data integrity by calculating and comparing checksums.
* Prints the result to the debug output.
*/
void Debug_CheckEEPOM(bool autocorrect)
void Debug_CheckEEPOM()
{
// Check PersistenceData EEPROM checksum
uint32_t checksum = PersistenceData.checksum;
@ -416,17 +414,6 @@ void Debug_CheckEEPOM(bool autocorrect)
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));
}
}
/**
@ -487,29 +474,3 @@ 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,6 +266,24 @@ 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.