rusefi-1/firmware/controllers/algo/error_handling.h

80 lines
2.0 KiB
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/**
* @file error_handling.h
*
* @date Mar 6, 2014
2015-12-31 13:02:30 -08:00
* @author Andrey Belomutskiy, (c) 2012-2016
2015-07-10 06:01:56 -07:00
*/
#ifndef ERROR_HANDLING_H_
#define ERROR_HANDLING_H_
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
int getVtSizeEstimate(void);
#include "obd_error_codes.h"
#include "efifeatures.h"
#include "stdbool.h"
2016-07-14 20:02:55 -07:00
#include "rusefi_types.h"
2015-07-10 06:01:56 -07:00
void assertVtList(void);
2016-11-23 14:01:59 -08:00
void addWarningCode(obd_code_e code);
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
*
*/
2016-10-10 12:02:10 -07:00
bool warning(obd_code_e code, const char *fmt, ...);
2016-10-09 16:03:51 -07:00
bool isWarningNow(efitimesec_t now, bool forIndicator);
2015-07-10 06:01:56 -07:00
/**
* Something really bad had happened - firmware cannot function
*
* todo: better method name?
*/
2016-10-10 11:02:17 -07:00
void firmwareError(obd_code_e code, const char *fmt, ...);
2015-07-10 06:01:56 -07:00
#define hasFirmwareError() hasFirmwareErrorFlag
char *getFirmwareError(void);
/**
* declared as a macro so that this code does not use stack
* so that it would not crash the error handler in case of stack issues
*/
#if CH_DBG_SYSTEM_STATE_CHECK
#define hasFatalError() (dbg_panic_msg != NULL)
#else
#define hasFatalError() (FALSE)
#endif
void chDbgPanic3(const char *msg, const char * file, int line);
void initErrorHandling(void);
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
2016-10-10 11:02:17 -07:00
#define efiAssert(condition, message, result) { if (!(condition)) { firmwareError(OBD_PCM_Processor_Fault, message); return result; } }
#define efiAssertVoid(condition, message) { if (!(condition)) { firmwareError(OBD_PCM_Processor_Fault, message); return; } }
2015-07-10 06:01:56 -07:00
#else /* EFI_ENABLE_ASSERTS */
#define efiAssert(condition, message, result) { }
#define efiAssertVoid(condition, message) { }
#endif /* EFI_ENABLE_ASSERTS */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ERROR_HANDLING_H_ */