error_handling: add OBD error code to warning message

This commit is contained in:
Andrey Gusakov 2024-01-08 22:56:02 +03:00 committed by rusefillc
parent 1d15bc0997
commit 17e69a4021
1 changed files with 7 additions and 2 deletions

View File

@ -177,14 +177,19 @@ bool warning(ObdCode code, const char *fmt, ...) {
return true;
}
// print Pxxxx (for standard OBD) or Cxxxx (for custom) prefix
size_t size = snprintf(warningBuffer, sizeof(warningBuffer), "%s%04d: ",
code < ObdCode::CUSTOM_NAN_ENGINE_LOAD ? "P" : "C", (int) code);
va_list ap;
va_start(ap, fmt);
chvsnprintf(warningBuffer, sizeof(warningBuffer), fmt, ap);
chvsnprintf(warningBuffer + size, sizeof(warningBuffer) - size, fmt, ap);
va_end(ap);
if (engineConfiguration->showHumanReadableWarning) {
#if EFI_TUNER_STUDIO
memcpy(persistentState.persistentConfiguration.warning_message, warningBuffer, sizeof(warningBuffer));
// TODO: does this work? Fix or remove
memcpy(persistentState.persistentConfiguration.warning_message, warningBuffer, sizeof(warningBuffer));
#endif /* EFI_TUNER_STUDIO */
}