2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file error_handling.h
|
|
|
|
*
|
|
|
|
* @date Mar 6, 2014
|
2017-01-03 03:05:22 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2017
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ERROR_HANDLING_H_
|
|
|
|
#define ERROR_HANDLING_H_
|
|
|
|
|
2019-11-13 05:42:16 -08:00
|
|
|
#include "global.h"
|
|
|
|
#include "obd_error_codes.h"
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*/
|
2016-10-10 12:02:10 -07:00
|
|
|
bool warning(obd_code_e code, const char *fmt, ...);
|
2016-12-31 12:02:44 -08:00
|
|
|
|
|
|
|
typedef uint8_t fatal_msg_t[200];
|
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
|
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
|
|
|
*/
|
2019-11-13 05:42:16 -08:00
|
|
|
void firmwareError(obd_code_e code, const char *fmt, ...);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
#define hasFirmwareError() hasFirmwareErrorFlag
|
|
|
|
|
2017-11-19 19:09:19 -08:00
|
|
|
// todo: rename to getFatalErrorMessage
|
2015-07-10 06:01:56 -07:00
|
|
|
char *getFirmwareError(void);
|
|
|
|
|
2019-08-04 10:48:10 -07:00
|
|
|
void initErrorHandlingDataStructures(void);
|
2017-11-19 19:09:19 -08:00
|
|
|
// todo: rename to getWarningMessage?
|
2016-10-10 12:02:10 -07:00
|
|
|
char *getWarning(void);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// todo: better place for this shared declaration?
|
|
|
|
int getRusEfiVersion(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated Global panic is inconvenient because it's hard to deliver the error message while whole instance
|
|
|
|
* is stopped. Please use firmwareWarning() instead
|
|
|
|
*/
|
|
|
|
#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) { }
|
2018-07-25 20:03:04 -07:00
|
|
|
#define efiAssertVoid(code, condition, message) { }
|
2015-07-10 06:01:56 -07:00
|
|
|
#endif /* EFI_ENABLE_ASSERTS */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#endif /* ERROR_HANDLING_H_ */
|