Compare commits
3 Commits
0b2245d7f6
...
956cc49e6f
Author | SHA1 | Date | |
---|---|---|---|
956cc49e6f | |||
b1da9449ad | |||
e54cadcc7c |
@ -82,7 +82,7 @@ const configData_t ConfigData_defaults = {
|
|||||||
"FACTION 1", // Faction_1_Name
|
"FACTION 1", // Faction_1_Name
|
||||||
"FACTION 2", // Faction_2_Name
|
"FACTION 2", // Faction_2_Name
|
||||||
"FACTION 3", // Faction_3_Name
|
"FACTION 3", // Faction_3_Name
|
||||||
"ArisoftTimer",
|
HOST_NAME,
|
||||||
QUOTE(WIFI_AP_PASSWORD),
|
QUOTE(WIFI_AP_PASSWORD),
|
||||||
QUOTE(WIFI_SSID_CLIENT),
|
QUOTE(WIFI_SSID_CLIENT),
|
||||||
QUOTE(WIFI_PASSWORD_CLIENT),
|
QUOTE(WIFI_PASSWORD_CLIENT),
|
||||||
|
@ -15,7 +15,17 @@
|
|||||||
|
|
||||||
DebugStatus_t DebuggerStatus[dbg_cntElements];
|
DebugStatus_t DebuggerStatus[dbg_cntElements];
|
||||||
|
|
||||||
void processCmdDebug(String command);
|
// Funktionszeiger
|
||||||
|
typedef void (*CommandFunction)();
|
||||||
|
|
||||||
|
// Struktur zur Zuordnung von Commands zu Funktionen
|
||||||
|
struct CommandMapping
|
||||||
|
{
|
||||||
|
const char *command;
|
||||||
|
CommandFunction function;
|
||||||
|
};
|
||||||
|
|
||||||
|
void processCmdDebug(const char *command);
|
||||||
void Debug_formatCFG();
|
void Debug_formatCFG();
|
||||||
void Debug_formatPersistence();
|
void Debug_formatPersistence();
|
||||||
void Debug_printSystemInfo();
|
void Debug_printSystemInfo();
|
||||||
@ -26,8 +36,97 @@ void Debug_dumpPersistance();
|
|||||||
void Debug_ShowDTCs();
|
void Debug_ShowDTCs();
|
||||||
void Debug_dumpGlobals();
|
void Debug_dumpGlobals();
|
||||||
void Debug_printHelp();
|
void Debug_printHelp();
|
||||||
|
void Debug_Reboot();
|
||||||
const char *uint32_to_binary_string(uint32_t num);
|
const char *uint32_to_binary_string(uint32_t num);
|
||||||
|
|
||||||
|
// Adapter-Functions for Debug-Commands
|
||||||
|
void adapterCheckEEPOM() { Debug_CheckEEPOM(false); }
|
||||||
|
void adapterCheckEEPOMFix() { Debug_CheckEEPOM(true); }
|
||||||
|
void adapterDumpEEPROM1k() { dumpEEPROM(0, 1024); }
|
||||||
|
void adapterDumpEEPROMAll() { dumpEEPROM(0, EEPROM_SIZE_BYTES); }
|
||||||
|
void adapterKillEEPROM() { writeSequentialToEEPROM(0, 1024); }
|
||||||
|
void adapterZeroEEPROM() { writeZeroToEEPROM(0, 1024); }
|
||||||
|
void adapterResetPageEEPROM() { MovePersistencePage_EEPROM(true); }
|
||||||
|
void adapterSaveEEPROM() { globals.requestEEAction = EE_ALL_SAVE; }
|
||||||
|
void adapterSetDebugPort() { SetDebugportStatus(dbg_Serial, enabled); }
|
||||||
|
void adapterCritDTC() { MaintainDTC(DTC_FAKE_DTC_CRIT, true, millis()); }
|
||||||
|
void adapterWarnDTC() { MaintainDTC(DTC_FAKE_DTC_WARN, true, millis()); }
|
||||||
|
void adapterInfoDTC() { MaintainDTC(DTC_FAKE_DTC_INFO, true, millis()); }
|
||||||
|
void adapterNotifyError() { Websocket_PushNotification("Debug Error Notification", error); }
|
||||||
|
void adapterNotifyWarning() { Websocket_PushNotification("Debug Warning Notification", warning); }
|
||||||
|
void adapterNotifySuccess() { Websocket_PushNotification("Debug Success Notification", success); }
|
||||||
|
void adapterNotifyInfo() { Websocket_PushNotification("Debug Info Notification", info); }
|
||||||
|
|
||||||
|
// Definition der Command-Mapping-Tabelle
|
||||||
|
const CommandMapping commandMappings[] = {
|
||||||
|
{"help", Debug_printHelp},
|
||||||
|
{"reboot", Debug_Reboot},
|
||||||
|
{"sysinfo", Debug_printSystemInfo},
|
||||||
|
{"netinfo", Debug_printWifiInfo},
|
||||||
|
{"formatCFG", Debug_formatCFG},
|
||||||
|
{"formatPDS", Debug_formatPersistence},
|
||||||
|
{"checkEE", adapterCheckEEPOM},
|
||||||
|
{"checkEEfix", adapterCheckEEPOMFix},
|
||||||
|
{"dumpEE1k", adapterDumpEEPROM1k},
|
||||||
|
{"dumpEE", adapterDumpEEPROMAll},
|
||||||
|
{"killEE", adapterKillEEPROM},
|
||||||
|
{"zeroEE", adapterZeroEEPROM},
|
||||||
|
{"resetPageEE", adapterResetPageEEPROM},
|
||||||
|
{"dumpCFG", Debug_dumpConfig},
|
||||||
|
{"dumpPDS", Debug_dumpPersistance},
|
||||||
|
{"saveEE", adapterSaveEEPROM},
|
||||||
|
{"dumpGlobals", Debug_dumpGlobals},
|
||||||
|
{"sdbg", adapterSetDebugPort},
|
||||||
|
{"dtc_show", Debug_ShowDTCs},
|
||||||
|
{"dtc_clear", ClearAllDTC},
|
||||||
|
{"dtc_crit", adapterCritDTC},
|
||||||
|
{"dtc_warn", adapterWarnDTC},
|
||||||
|
{"dtc_info", adapterInfoDTC},
|
||||||
|
{"notify_error", adapterNotifyError},
|
||||||
|
{"notify_warning", adapterNotifyWarning},
|
||||||
|
{"notify_success", adapterNotifySuccess},
|
||||||
|
{"notify_info", adapterNotifyInfo},
|
||||||
|
};
|
||||||
|
|
||||||
|
const size_t NUM_COMMANDS = sizeof(commandMappings) / sizeof(commandMappings[0]);
|
||||||
|
|
||||||
|
const char helpText[][64] PROGMEM = {
|
||||||
|
"help - Print this help text",
|
||||||
|
"sysinfo - System Info",
|
||||||
|
"reboot - System Reboot",
|
||||||
|
"netinfo - WiFi Info",
|
||||||
|
"formatPDS - Format Persistence EEPROM Data",
|
||||||
|
"formatCFG - Format Configuration EEPROM Data",
|
||||||
|
"checkEE - Check EEPROM with checksum",
|
||||||
|
"checkEEfix - Check and fix EEPROM with checksum",
|
||||||
|
"dumpEE1k - Dump the first 1kb of EEPROM to Serial",
|
||||||
|
"dumpEE - Dump the whole EEPROM to Serial",
|
||||||
|
"killEE - Kill the first 1024 bytes of EEPROM",
|
||||||
|
"zeroEE - Zero the first 1024 bytes of EEPROM",
|
||||||
|
"resetPageEE - Reset the PersistenceData Page",
|
||||||
|
"dumpCFG - Print Config struct",
|
||||||
|
"dumpPDS - Print PersistenceStruct",
|
||||||
|
"saveEE - Save EE-Data",
|
||||||
|
"dumpGlobals - Print globals",
|
||||||
|
"sdbg - Set debug port status",
|
||||||
|
"dtc_show - Show all DTCs",
|
||||||
|
"dtc_clear - Clear all DTCs",
|
||||||
|
"dtc_crit - Maintain critical DTC",
|
||||||
|
"dtc_warn - Maintain warning DTC",
|
||||||
|
"dtc_info - Maintain info DTC",
|
||||||
|
"notify_error - Send error notification",
|
||||||
|
"notify_warning - Send warning notification",
|
||||||
|
"notify_success - Send success notification",
|
||||||
|
"notify_info - Send info notification"
|
||||||
|
};
|
||||||
|
|
||||||
|
const size_t NUM_HELP_LINES = sizeof(helpText) / sizeof(helpText[0]);
|
||||||
|
|
||||||
|
// Überprüfen, ob die Anzahl der Commands und Hilfetext-Zeilen übereinstimmen
|
||||||
|
static_assert(NUM_COMMANDS == NUM_HELP_LINES, "Number of commands and help text lines do not match!");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the debugger by setting the initial status for different debug ports.
|
* @brief Initializes the debugger by setting the initial status for different debug ports.
|
||||||
* Serial debug output is turned off.
|
* Serial debug output is turned off.
|
||||||
@ -109,7 +208,7 @@ void Debug_Process()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_COMPLETE:
|
case CMD_COMPLETE:
|
||||||
processCmdDebug(String(inputBuffer));
|
processCmdDebug(inputBuffer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_OVERFLOW:
|
case CMD_OVERFLOW:
|
||||||
@ -184,65 +283,22 @@ void Debug_pushMessage(const char *format, ...)
|
|||||||
*
|
*
|
||||||
* @param command The debug command to be processed.
|
* @param command The debug command to be processed.
|
||||||
*/
|
*/
|
||||||
void processCmdDebug(String command)
|
void processCmdDebug(const char *command)
|
||||||
{
|
{
|
||||||
// Check the received command and execute corresponding actions
|
bool commandFound = false;
|
||||||
if (command == "help")
|
for (size_t i = 0; i < NUM_COMMANDS; ++i)
|
||||||
Debug_printHelp();
|
{
|
||||||
else if (command == "reboot")
|
if (strcmp(command, commandMappings[i].command) == 0)
|
||||||
globals.systemStatus = sysStat_Shutdown;
|
{
|
||||||
else if (command == "sysinfo")
|
commandMappings[i].function();
|
||||||
Debug_printSystemInfo();
|
commandFound = true;
|
||||||
else if (command == "netinfo")
|
break;
|
||||||
Debug_printWifiInfo();
|
}
|
||||||
else if (command == "formatCFG")
|
}
|
||||||
Debug_formatCFG();
|
if (!commandFound)
|
||||||
else if (command == "formatPDS")
|
{
|
||||||
Debug_formatPersistence();
|
|
||||||
else if (command == "checkEE")
|
|
||||||
Debug_CheckEEPOM(false);
|
|
||||||
else if (command == "checkEEfix")
|
|
||||||
Debug_CheckEEPOM(true);
|
|
||||||
else if (command == "dumpEE1k")
|
|
||||||
dumpEEPROM(0, 1024);
|
|
||||||
else if (command == "dumpEE")
|
|
||||||
dumpEEPROM(0, EEPROM_SIZE_BYTES);
|
|
||||||
else if (command == "killEE")
|
|
||||||
writeSequentialToEEPROM(0, 1024);
|
|
||||||
else if (command == "zeroEE")
|
|
||||||
writeZeroToEEPROM(0, 1024);
|
|
||||||
else if (command == "resetPageEE")
|
|
||||||
MovePersistencePage_EEPROM(true);
|
|
||||||
else if (command == "dumpCFG")
|
|
||||||
Debug_dumpConfig();
|
|
||||||
else if (command == "dumpPDS")
|
|
||||||
Debug_dumpPersistance();
|
|
||||||
else if (command == "saveEE")
|
|
||||||
globals.requestEEAction = EE_ALL_SAVE;
|
|
||||||
else if (command == "dumpGlobals")
|
|
||||||
Debug_dumpGlobals();
|
|
||||||
else if (command == "sdbg")
|
|
||||||
SetDebugportStatus(dbg_Serial, enabled);
|
|
||||||
else if (command == "dtc_show")
|
|
||||||
Debug_ShowDTCs();
|
|
||||||
else if (command == "dtc_clear")
|
|
||||||
ClearAllDTC();
|
|
||||||
else if (command == "dtc_crit")
|
|
||||||
MaintainDTC(DTC_FAKE_DTC_CRIT, true, millis());
|
|
||||||
else if (command == "dtc_warn")
|
|
||||||
MaintainDTC(DTC_FAKE_DTC_WARN, true, millis());
|
|
||||||
else if (command == "dtc_info")
|
|
||||||
MaintainDTC(DTC_FAKE_DTC_INFO, true, millis());
|
|
||||||
else if (command == "notify_error")
|
|
||||||
Websocket_PushNotification("Debug Error Notification", error);
|
|
||||||
else if (command == "notify_warning")
|
|
||||||
Websocket_PushNotification("Debug Warning Notification", warning);
|
|
||||||
else if (command == "notify_success")
|
|
||||||
Websocket_PushNotification("Debug Success Notification", success);
|
|
||||||
else if (command == "notify_info")
|
|
||||||
Websocket_PushNotification("Debug Info Notification", info);
|
|
||||||
else
|
|
||||||
Debug_pushMessage("unknown Command\n");
|
Debug_pushMessage("unknown Command\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -415,7 +471,7 @@ void Debug_ShowDTCs()
|
|||||||
char buff_active[9];
|
char buff_active[9];
|
||||||
|
|
||||||
// Header for the DTC display
|
// Header for the DTC display
|
||||||
Debug_pushMessage("\n timestamp | DTC-Nr. | status | severity\n");
|
Debug_pushMessage("\n timestamp | DTC-Nr. | status | debugval\n");
|
||||||
|
|
||||||
// Iterate through DTCStorage and display each entry
|
// Iterate through DTCStorage and display each entry
|
||||||
for (uint32_t i = 0; i < MAX_DTC_STORAGE; i++)
|
for (uint32_t i = 0; i < MAX_DTC_STORAGE; i++)
|
||||||
@ -439,31 +495,37 @@ void Debug_ShowDTCs()
|
|||||||
strcpy(buff_active, "none");
|
strcpy(buff_active, "none");
|
||||||
|
|
||||||
// Display DTC information
|
// Display DTC information
|
||||||
Debug_pushMessage("%s %7d %8s %8d\n", buff_timestamp, DTCStorage[i].Number, buff_active);
|
Debug_pushMessage("%s %7d %8s %8d\n", buff_timestamp, DTCStorage[i].Number, buff_active, DTCStorage[i].debugVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Displays the help commands for debugging through Serial or WebUI.
|
* @brief Prints the help information stored in PROGMEM.
|
||||||
* Each command is printed individually in a formatted manner.
|
|
||||||
*/
|
*/
|
||||||
void Debug_printHelp()
|
void Debug_printHelp()
|
||||||
{
|
{
|
||||||
char buff[64];
|
char buffer[64];
|
||||||
|
for (size_t i = 0; i < NUM_HELP_LINES; ++i)
|
||||||
// Iterate through helpCmd and display each command
|
|
||||||
for (unsigned int i = 0; i < sizeof(helpCmd) / 63; i++)
|
|
||||||
{
|
{
|
||||||
// Copy a portion of helpCmd to buff for display
|
strcpy_P(buffer, (PGM_P)pgm_read_word(&(helpText[i])));
|
||||||
memcpy_P(buff, (helpCmd + (i * 63)), 63);
|
|
||||||
buff[63] = 0;
|
|
||||||
|
|
||||||
// Display the help command
|
// Display the help command
|
||||||
Debug_pushMessage(buff);
|
Debug_pushMessage(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initiates a system reboot by setting the system status to shutdown.
|
||||||
|
*
|
||||||
|
* This function sets the global system status to `sysStat_Shutdown`,
|
||||||
|
* which will trigger a system reboot sequence.
|
||||||
|
*/
|
||||||
|
void Debug_Reboot()
|
||||||
|
{
|
||||||
|
globals.systemStatus = sysStat_Shutdown;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Convert a uint32_t value to a binary string with nibbles separated by a space.
|
* @brief Convert a uint32_t value to a binary string with nibbles separated by a space.
|
||||||
*
|
*
|
||||||
|
@ -157,7 +157,7 @@ void GetConfig_EEPROM()
|
|||||||
|
|
||||||
ConfigData.checksum = checksum;
|
ConfigData.checksum = checksum;
|
||||||
|
|
||||||
uint32_t ConfigSanityCheckResult = ConfigSanityCheck(false);
|
uint32_t ConfigSanityCheckResult = ConfigSanityCheck(true);
|
||||||
|
|
||||||
MaintainDTC(DTC_EEPROM_CFG_SANITY, (ConfigSanityCheckResult > 0), ConfigSanityCheckResult);
|
MaintainDTC(DTC_EEPROM_CFG_SANITY, (ConfigSanityCheckResult > 0), ConfigSanityCheckResult);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user