Users are confused about FATAL error and reboot #4073

This commit is contained in:
rusefillc 2022-04-16 17:53:11 -04:00
parent be772a6a1a
commit b535d47600
4 changed files with 22 additions and 5 deletions

View File

@ -34,6 +34,7 @@ All notable user-facing or behavior-altering changes will be documented in this
- Toyota 4-1 VVT trigger
- use extra RAM for lua if your microRusEFI unit has stm32f42x microcontroller
- VVT activation delay #3443
- ECU uptime into critical error message
## March 2022 Release - "Day 22"

View File

@ -433,7 +433,11 @@ static void handleTestCommand(TsChannelBase* tsChannel) {
tsChannel->write((const uint8_t*)testOutputBuffer, strlen(testOutputBuffer));
if (hasFirmwareError()) {
const char* error = getCriticalErrorMessage();
char* error = getCriticalErrorMessage();
extern int firmwareErrorUptimePosition;
if (firmwareErrorUptimePosition > 0) {
itoa10(error + firmwareErrorUptimePosition, getTimeNowSeconds());
}
chsnprintf(testOutputBuffer, sizeof(testOutputBuffer), "error=%s\r\n", error);
tsChannel->write((const uint8_t*)testOutputBuffer, strlen(testOutputBuffer));
}

View File

@ -22,7 +22,12 @@ bool hasFirmwareErrorFlag = false;
const char *dbg_panic_file;
int dbg_panic_line;
const char* getCriticalErrorMessage(void) {
/**
* position at which we would be dynamically appending uptime
*/
int firmwareErrorUptimePosition = -1;
char* getCriticalErrorMessage(void) {
return criticalErrorMessageBuffer;
}
@ -220,10 +225,17 @@ void firmwareError(obd_code_e code, const char *fmt, ...) {
int errorMessageSize = strlen((char*)criticalErrorMessageBuffer);
static char versionBuffer[32];
chsnprintf(versionBuffer, sizeof(versionBuffer), " %d@%s", getRusEfiVersion(), FIRMWARE_ID);
chsnprintf(versionBuffer, sizeof(versionBuffer), "\n%d@%s\nup=",
getRusEfiVersion(),
FIRMWARE_ID);
if (errorMessageSize + strlen(versionBuffer) < sizeof(criticalErrorMessageBuffer)) {
#define MAX_UPTIME_LEN 9
int versionBufferLength = strlen(versionBuffer);
if (errorMessageSize + versionBufferLength + MAX_UPTIME_LEN < sizeof(criticalErrorMessageBuffer)) {
strcpy((char*)(criticalErrorMessageBuffer) + errorMessageSize, versionBuffer);
firmwareErrorUptimePosition = errorMessageSize + versionBufferLength;
} else {
firmwareErrorUptimePosition = -1;
}
#else

View File

@ -37,7 +37,7 @@ extern bool hasFirmwareErrorFlag;
#define hasFirmwareError() hasFirmwareErrorFlag
const char* getCriticalErrorMessage(void);
char* getCriticalErrorMessage(void);
const char* getWarningMessage(void);
// todo: better place for this shared declaration?