2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file error_handling.h
|
|
|
|
*
|
|
|
|
* @date Mar 6, 2014
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
2020-03-28 16:49:36 -07:00
|
|
|
#pragma once
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-11-13 05:42:16 -08:00
|
|
|
#include "obd_error_codes.h"
|
2023-12-19 12:25:14 -08:00
|
|
|
#include "generated_lookup_meta.h"
|
2022-07-07 12:14:31 -07:00
|
|
|
#include <cstdint>
|
2019-11-13 05:42:16 -08:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* Something is wrong, but we can live with it: some minor sensor is disconnected
|
|
|
|
* or something like that
|
|
|
|
*
|
2017-11-19 19:09:19 -08:00
|
|
|
* see also firmwareError()
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2023-04-11 16:32:47 -07:00
|
|
|
bool warning(ObdCode code, const char *fmt, ...);
|
2016-12-31 12:02:44 -08:00
|
|
|
|
2023-03-16 13:18:28 -07:00
|
|
|
using critical_msg_t = char[CRITICAL_BUFFER_SIZE];
|
2021-03-14 06:31:11 -07:00
|
|
|
|
2023-07-21 18:37:41 -07:00
|
|
|
#define criticalShutdown() \
|
|
|
|
TURN_FATAL_LED(); \
|
|
|
|
turnAllPinsOff();
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
2017-11-19 19:09:19 -08:00
|
|
|
* Something really bad had happened - firmware cannot function, we cannot run the engine
|
2020-04-19 20:55:27 -07:00
|
|
|
* We definitely use this critical error approach in case of invalid configuration. If user sets a self-contradicting
|
|
|
|
* configuration we have to just put a hard stop on this.
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
2017-11-19 19:09:19 -08:00
|
|
|
* see also warning()
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2023-04-11 16:32:47 -07:00
|
|
|
void firmwareError(ObdCode code, const char *fmt, ...);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-08-20 19:05:19 -07:00
|
|
|
#define criticalError(...) firmwareError(ObdCode::OBD_PCM_Processor_Fault, __VA_ARGS__)
|
|
|
|
|
2020-03-29 16:06:03 -07:00
|
|
|
extern bool hasFirmwareErrorFlag;
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#define hasFirmwareError() hasFirmwareErrorFlag
|
|
|
|
|
2022-04-16 14:35:59 -07:00
|
|
|
const char* getCriticalErrorMessage(void);
|
2021-03-14 06:31:11 -07:00
|
|
|
const char* getWarningMessage(void);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// todo: better place for this shared declaration?
|
|
|
|
int getRusEfiVersion(void);
|
|
|
|
|
|
|
|
#if EFI_ENABLE_ASSERTS
|
2018-07-25 20:30:00 -07:00
|
|
|
#define efiAssert(code, condition, message, result) { if (!(condition)) { firmwareError(code, message); return result; } }
|
2018-07-25 20:03:04 -07:00
|
|
|
#define efiAssertVoid(code, condition, message) { if (!(condition)) { firmwareError(code, message); return; } }
|
2015-07-10 06:01:56 -07:00
|
|
|
#else /* EFI_ENABLE_ASSERTS */
|
2018-07-25 20:30:00 -07:00
|
|
|
#define efiAssert(code, condition, message, result) { }
|
2023-11-02 07:39:05 -07:00
|
|
|
#define efiAssertVoid(code, condition, message) { UNUSED(condition);}
|
2015-07-10 06:01:56 -07:00
|
|
|
#endif /* EFI_ENABLE_ASSERTS */
|
|
|
|
|
2024-03-05 12:27:39 -08:00
|
|
|
#define criticalAssert(condition, message, result) efiAssert(ObdCode::OBD_PCM_Processor_Fault, condition, message, result)
|
2023-09-05 18:16:22 -07:00
|
|
|
#define criticalAssertVoid(condition, message) efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, condition, message)
|
|
|
|
|
2023-10-05 19:22:00 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2022-07-07 12:14:31 -07:00
|
|
|
#if EFI_PROD_CODE
|
|
|
|
|
|
|
|
// If there was an error on the last boot, print out information about it now and reset state.
|
|
|
|
void checkLastBootError();
|
|
|
|
#endif // EFI_PROD_CODE
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|