ErrorLib 1.0.8-master SHA: 810228da25
Error.h File Reference

Error and Warnings Plugin for Hermes PC-Tool. More...

#include <stdint.h>
#include "timestamp.h"

Go to the source code of this file.

Data Structures

struct  tOnErrorReaction
 The error reaction is called on occurence of the error. More...
 
struct  tOnErrorResetReaction
 The error reset reaction is called on reset of the error. More...
 
struct  tError
 Main error structure. More...
 
struct  tErrorSource
 Structure used in tError holding source-code file an line. More...
 
struct  tErrorListItem
 Structure used in the error stack. More...
 

Macros

#define static_assert   _Static_assert
 
#define MAX_NUMBER_OF_ERRORS   30
 Size of the error stack. More...
 
#define MIN_ERR_REACTION_NAME_LENTH   10
 Minimum lenght of error-reaction description string. More...
 
#define MIN_DESCRIPTION_LENTH   10
 Minimum lenght of description-string. More...
 
#define MIN_HELP_LENTH   20
 Minimum lenght of help-string. More...
 
#define ERROR_STACK_OVERFLOW   0x80000000
 Flag used in g_u32ErrorPending to indicate an error stack overflow. More...
 
#define ERROR_SYSTEM_VERSION   2
 Version of this error-library. More...
 
#define ERR_VAR_NAME_SRT(x, y)   x ## y
 Helper Macro to add a variable name to help-text. More...
 
#define ERR_VAR_NAME(x, y)   ERR_VAR_NAME_SRT(x, y)
 Helper Macro to add a variable name to help-text. More...
 
#define xstr(s)   str(s)
 Helper Macro to convert to string. More...
 
#define str(s)   #s
 Helper Macro to convert to string. More...
 
#define ASSERT_REACTION_NAME(NAME)
 Test if strings are too short. More...
 
#define ASSERT_DESCRIPTION(DESCRIPTION)
 Test if strings are too short. More...
 
#define ASSERT_HELP(HELP)
 Test if strings are too short. More...
 
#define DefineError(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP)
 Define an error without data globally. More...
 
#define DefineErrorData(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA_COUNT)
 Define an error with data globally. More...
 
#define DeclareError(ID)   const tError g_t##ID
 Use to declare an Error as external. More...
 
#define SetError(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP)
 Set an error without data. More...
 
#define SetErrorSource(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, SOURCE)
 Set an error without data but with an external tErrorSource structure The data of the error is directly added to this function, therefore this error can only be triggered by this single codeline. More...
 
#define SetErrorData1(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1)
 Set an error with one data-field. More...
 
#define SetErrorData1Compare(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, COMPARE1)
 Use to set an error with one data-field and compare function. More...
 
#define SetErrorData2(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, DATA2)
 Set an error with two data-fields. More...
 
#define SetErrorData2Compare(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, COMPARE1, DATA2, COMPARE2)
 Use to set an error with two data-fielda and compare functiona. More...
 
#define SetErrorData3(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, DATA2, DATA3)
 Set an error with three data-fields. More...
 
#define SetErrorData4(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, DATA2, DATA3, DATA4)
 Set an error with four data-fields. More...
 
#define SetErrorId(ID)
 Set an error which is previously defined by "DefineError". More...
 
#define SetErrorIdData1(ID, DATA1)
 Set an error which is previously defined by "DefineError". More...
 
#define SetErrorIdData2(ID, DATA1, DATA2)
 Set an error which is previously defined by "DefineError". More...
 
#define SetErrorIdData3(ID, DATA1, DATA2, DATA3)
 Set an error which is previously defined by "DefineError". More...
 
#define SetErrorIdData4(ID, DATA1, DATA2, DATA3, DATA4)
 Set an error which is previously defined by "DefineError". More...
 
#define DefineOnErrorReaction(ERROR_REACTION, NAME, HELP)
 Define an error reaction. More...
 
#define DeclareOnErrorReaction(ERROR_REACTION)
 Use to declare an ErrorReaction as external. More...
 
#define DefineOnErrorResetReaction(ERROR_REACTION, NAME, HELP)
 Define an error reset reaction. More...
 
#define DeclareOnErrorResetReaction(ERROR_REACTION)
 Use to declare an ErrorResetReaction as external. More...
 

Typedefs

typedef void(* fpOnErrorX) (void)
 Structure used in tError to describe a function to be called on error set. More...
 
typedef bool(* fpOnErrorResetX) (void)
 Structure used in tError to describe a function to be called on error reset. More...
 

Enumerations

enum  ERROR_FLAGS {
  VIEWER_RESET = 1 , USER_RESET = 2 , PROFESSIONAL_RESET = 4 , DEVELOPER_RESET = 8 ,
  PLC_RESET = 16 , CODE_RESET = 32 , NV_STORED = 64
}
 Flags used for errors. More...
 

Functions

void NoOnErrorReaction (void)
 This function is called if no Reaction is required after an error. More...
 
bool NoOnErrorResetReaction (void)
 This function is called if no Reaction is required after an error reset. More...
 
void ErrorInit (void)
 Inits the Error Stack with 0. More...
 
tErrorListItem_SetErrorX (const tError *ptError, const tErrorSource *ptErrorSource,...)
 This function adds a error to the stack. More...
 
void ErrorResetX (uint8_t ui8AccessLevel)
 Resets all pending errors if access level is sufficient. More...
 
void ResetErrorIdRange (uint16_t ui16ErrorIdStart, uint16_t ui16ErrorIdEnd, uint8_t ui8AccessLevel)
 Resets all pending errors in a range of error IDs if access level is sufficient. More...
 
void ErrorClear (uint8_t ui8AccessLevel)
 Removes all errors from stack if access level is sufficient, might be called after Init. More...
 
bool ErrorsPending (void)
 Check if errors are pending. More...
 
void MaxFloat (void *DataOld, float DataNew)
 Update the atached data if new value is higher. More...
 
void MinFloat (void *DataOld, float DataNew)
 Update the atatched data if new value is lower. More...
 
void MaxAbsFloat (void *DataOld, float DataNew)
 Update the atatched data if new value abs is higher. More...
 
void MaxInt (void *DataOld, int32_t DataNew)
 Update the atatched data if new value is higher. More...
 
void MinInt (void *DataOld, int32_t DataNew)
 Update the atatched data if new value is lower. More...
 
void MaxUInt (void *DataOld, uint32_t DataNew)
 Update the atatched data if new value is higher. More...
 
void MinUInt (void *DataOld, uint32_t DataNew)
 Update the atatched data if new value is lower. More...
 
void NoDataUpdate (void *DataOld,...)
 Dummy Function for no Data-updates. More...
 
bool IsErrorPending (uint32_t position)
 Check if the requestes Error-Position is pending. More...
 
uint16_t GetErrorId (uint32_t position)
 Get Error ID of the Error on a specified Position. More...
 
uint32_t PendingErrosSortedByTime (tErrorListItem *pptPendingErrorList[])
 Get an array of the pending Errors sorted by tTimestampFirst. More...
 

Variables

uint32_t g_u32ErrorPending
 An error that has not been reset is marked with a high bit, bit 0 corresponds to g_ptErrorList[0] etc. More...
 
const tOnErrorReaction g_tNoOnErrorReaction
 
const tOnErrorResetReaction g_tNoOnErrorResetReaction
 
static const char g_sFileName [] = __BASE_FILE__
 The filename for all Errors within a module. More...
 
tErrorListItem g_ptErrorList [30]
 This array contains the error stack. More...
 

Detailed Description

Error and Warnings Plugin for Hermes PC-Tool.


© Copyright 2017-2022 Copyright: Retostronik GmbH Stütingstraße 30 58285 Gevelsberg

Macro Definition Documentation

◆ ASSERT_DESCRIPTION

#define ASSERT_DESCRIPTION (   DESCRIPTION)
Value:
static_assert(sizeof(DESCRIPTION) > MIN_DESCRIPTION_LENTH, \
"Error description text to short must be at least "xstr(MIN_DESCRIPTION_LENTH)" characters long!") \
#define MIN_DESCRIPTION_LENTH
Minimum lenght of description-string.
Definition: Error.h:38
#define xstr(s)
Helper Macro to convert to string.
Definition: Error.h:134

Test if strings are too short.

◆ ASSERT_HELP

#define ASSERT_HELP (   HELP)
Value:
static_assert(sizeof(HELP) > MIN_HELP_LENTH, \
"Error help text to short must be at least "xstr(MIN_HELP_LENTH)" characters long!") \
#define MIN_HELP_LENTH
Minimum lenght of help-string.
Definition: Error.h:40

Test if strings are too short.

◆ ASSERT_REACTION_NAME

#define ASSERT_REACTION_NAME (   NAME)
Value:
static_assert(sizeof(NAME) > MIN_ERR_REACTION_NAME_LENTH, \
"Error reaction name to short must be at least "xstr(MIN_ERR_REACTION_NAME_LENTH)" characters long!") \
#define MIN_ERR_REACTION_NAME_LENTH
Minimum lenght of error-reaction description string.
Definition: Error.h:36

Test if strings are too short.

◆ DeclareError

#define DeclareError (   ID)    const tError g_t##ID

Use to declare an Error as external.

This macro is used in header-files to allow calling the defined error from several modules.

Parameters
IDIdentifier of the defined error.

◆ DeclareOnErrorReaction

#define DeclareOnErrorReaction (   ERROR_REACTION)
Value:
const tOnErrorReaction g_t##ERROR_REACTION; \
void ERROR_REACTION(void)
The error reaction is called on occurence of the error.
Definition: Error.h:70

Use to declare an ErrorReaction as external.

This macro is used in header-files to allow calling the defined error reaction from several modules.

Parameters
ERROR_REACTIONIdentifier of the defined error reaction.

◆ DeclareOnErrorResetReaction

#define DeclareOnErrorResetReaction (   ERROR_REACTION)
Value:
const tOnErrorResetReaction g_t##ERROR_REACTION; \
bool ERROR_REACTION(void)
The error reset reaction is called on reset of the error.
Definition: Error.h:86

Use to declare an ErrorResetReaction as external.

This macro is used in header-files to allow calling the defined error reset reaction from several modules.

Parameters
ERROR_REACTIONIdentifier of the defined error reset reaction.

◆ DefineError

#define DefineError (   ID,
  PERMISSION,
  ON_ERROR,
  ON_ERROR_RESET,
  DESCRIPTION,
  HELP 
)
Value:
ASSERT_DESCRIPTION(DESCRIPTION); \
ASSERT_HELP(HELP); \
static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
\
const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
ID, \
0, \
PERMISSION, \
g_s##ID##Description, \
sizeof(DESCRIPTION) - 1, \
g_s##ID##Help, \
sizeof(HELP) - 1, \
&g_t##ON_ERROR, \
&g_t##ON_ERROR_RESET, \
}
#define ASSERT_DESCRIPTION(DESCRIPTION)
Test if strings are too short.
Definition: Error.h:143
Main error structure.
Definition: Error.h:96

Define an error without data globally.

The error is not set. This error can be triggered on several code lines.

Parameters
IDIdentifier of the error. Must be unique and is therefore defined in the file ERROR_ID_Device.h
PERMISSIONOr-concatinated list of permission-levels which are allowed to reset this error.
ON_ERRORReaction which is called immediately after error set.
ON_ERROR_RESETReaction which is called after an error-reset.
DESCRIPTIONText which is displayed in the error list.
HELPText which is displayed in the help window for this error.

◆ DefineErrorData

#define DefineErrorData (   ID,
  PERMISSION,
  ON_ERROR,
  ON_ERROR_RESET,
  DESCRIPTION,
  HELP,
  DATA_COUNT 
)
Value:
ASSERT_DESCRIPTION(DESCRIPTION); \
ASSERT_HELP(HELP); \
static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
\
const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
ID, \
DATA_COUNT, \
PERMISSION, \
g_s##ID##Description, \
sizeof(DESCRIPTION) - 1, \
g_s##ID##Help, \
sizeof(HELP) - 1, \
&g_t##ON_ERROR, \
&g_t##ON_ERROR_RESET, \
}

Define an error with data globally.

The error is not set. This error can be triggered on several code lines.

Parameters
IDIdentifier of the error. Must be unique and is therefore defined in the file ERROR_ID_Device.h
PERMISSIONOr-concatinated list of permission-levels which are allowed to reset this error.
ON_ERRORReaction which is called immediately after error set.
ON_ERROR_RESETReaction which is called after an error-reset.
DESCRIPTIONText which is displayed in the error list.
HELPText which is displayed in the help window for this error.
DATA_COUNTNumber of data-fileds which are appended to the error. See Details on Page Data appended to errors.

◆ DefineOnErrorReaction

#define DefineOnErrorReaction (   ERROR_REACTION,
  NAME,
  HELP 
)
Value:
ASSERT_HELP(HELP); \
static const char ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__)[] __attribute__((section("error_strings"), used)) = NAME; \
static const char ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__)[] __attribute__((section("error_strings"), used)) = HELP; \
const tOnErrorReaction g_t##ERROR_REACTION __attribute__((section("error_reactions"), used)) = { \
&ERROR_REACTION, \
ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__), \
sizeof(ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__)) - 1, \
ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__), \
sizeof(ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__)) - 1 \
};
#define ASSERT_REACTION_NAME(NAME)
Test if strings are too short.
Definition: Error.h:139
#define ERR_VAR_NAME(x, y)
Helper Macro to add a variable name to help-text.
Definition: Error.h:131

Define an error reaction.

See page Actions on Error set and reset for details.

Parameters
ERROR_REACTIONName of the error reaction. The name equates the function name which is called.
NAMEText which is displayed in the error list.
HELPText which is displayed in the help window for this error.

◆ DefineOnErrorResetReaction

#define DefineOnErrorResetReaction (   ERROR_REACTION,
  NAME,
  HELP 
)
Value:
ASSERT_HELP(HELP); \
static const char ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__)[] __attribute__((section("error_strings"), used)) = NAME; \
static const char ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__)[] __attribute__((section("error_strings"), used)) = HELP; \
const tOnErrorResetReaction g_t##ERROR_REACTION __attribute__((section("error_reactions"), used)) = { \
&ERROR_REACTION, \
ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__), \
sizeof(ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__)) - 1, \
ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__), \
sizeof(ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__)) - 1 \
};

Define an error reset reaction.

See page Actions on Error set and reset for details.

Parameters
ERROR_REACTIONName of the error reset reaction. The name equates the function name which is called.
NAMEText which is displayed in the error list.
HELPText which is displayed in the help window for this error.

◆ ERR_VAR_NAME

#define ERR_VAR_NAME (   x,
 
)    ERR_VAR_NAME_SRT(x, y)

Helper Macro to add a variable name to help-text.

◆ ERR_VAR_NAME_SRT

#define ERR_VAR_NAME_SRT (   x,
 
)    x ## y

Helper Macro to add a variable name to help-text.

◆ ERROR_STACK_OVERFLOW

#define ERROR_STACK_OVERFLOW   0x80000000

Flag used in g_u32ErrorPending to indicate an error stack overflow.

◆ ERROR_SYSTEM_VERSION

#define ERROR_SYSTEM_VERSION   2

Version of this error-library.

◆ MAX_NUMBER_OF_ERRORS

#define MAX_NUMBER_OF_ERRORS   30

Size of the error stack.

Maximum value is 31

◆ MIN_DESCRIPTION_LENTH

#define MIN_DESCRIPTION_LENTH   10

Minimum lenght of description-string.

◆ MIN_ERR_REACTION_NAME_LENTH

#define MIN_ERR_REACTION_NAME_LENTH   10

Minimum lenght of error-reaction description string.

◆ MIN_HELP_LENTH

#define MIN_HELP_LENTH   20

Minimum lenght of help-string.

◆ SetError

#define SetError (   ID,
  PERMISSION,
  ON_ERROR,
  ON_ERROR_RESET,
  DESCRIPTION,
  HELP 
)
Value:
do \
{ \
ASSERT_DESCRIPTION(DESCRIPTION); \
ASSERT_HELP(HELP); \
static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
__LINE__, \
g_sFileName, \
sizeof(g_sFileName) - 1 \
}; \
\
static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
ID, \
0, \
PERMISSION, \
g_s##ID##Description, \
sizeof(DESCRIPTION) - 1, \
g_s##ID##Help, \
sizeof(HELP) - 1, \
&g_t##ON_ERROR, \
&g_t##ON_ERROR_RESET, \
}; \
_SetErrorX(&g_t##ID, &g_t##ID##Source); \
}while(0)
static const char g_sFileName[]
The filename for all Errors within a module.
Definition: Error.h:929
Structure used in tError holding source-code file an line.
Definition: Error.h:110

Set an error without data.

The data of the error is directly added to this function, therefore this error can only be triggered by this single codeline.

Parameters
IDIdentifier of the error. Must be unique and is therefore defined in the file ERROR_ID_Device.h
PERMISSIONOr-concatinated list of permission-levels which are allowed to reset this error.
ON_ERRORReaction which is called immediately after error set.
ON_ERROR_RESETReaction which is called after an error-reset.
DESCRIPTIONText which is displayed in the error list.
HELPText which is displayed in the help window for this error.

◆ SetErrorData1

#define SetErrorData1 (   ID,
  PERMISSION,
  ON_ERROR,
  ON_ERROR_RESET,
  DESCRIPTION,
  HELP,
  DATA1 
)

Set an error with one data-field.

The data of the error is directly added to this function, therefore this error can only be triggered by this single codeline.

Parameters
IDIdentifier of the error. Must be unique and is therefore defined in the file ERROR_ID_Device.h
PERMISSIONOr-concatinated list of permission-levels which are allowed to reset this error.
ON_ERRORReaction which is called immediately after error set.
ON_ERROR_RESETReaction which is called after an error-reset.
DESCRIPTIONText which is displayed in the error list.
HELPText which is displayed in the help window for this error.
DATA1Data to be attached to this error. See Details on Page Data appended to errors.

◆ SetErrorData1Compare

#define SetErrorData1Compare (   ID,
  PERMISSION,
  ON_ERROR,
  ON_ERROR_RESET,
  DESCRIPTION,
  HELP,
  DATA1,
  COMPARE1 
)

Use to set an error with one data-field and compare function.

The data of the error is directly added to this function, therefore this error can only be triggered by this single codeline. If the error is called more than once, the compare-function is used to update the data attached to this error. See page Errors with compare function to update the data attached to the error for details about the compare function.

Parameters
IDIdentifier of the error. Must be unique and is therefore defined in the file ERROR_ID_Device.h
PERMISSIONOr-concatinated list of permission-levels which are allowed to reset this error.
ON_ERRORReaction which is called immediately after error set.
ON_ERROR_RESETReaction which is called after an error-reset.
DESCRIPTIONText which is displayed in the error list.
HELPText which is displayed in the help window for this error.
DATA1Data to be attached to this error. See Details on Page Data appended to errors.
COMPARE1Compare function to update the attached data. See Details on Page Errors with compare function to update the data attached to the error.

◆ SetErrorData2

#define SetErrorData2 (   ID,
  PERMISSION,
  ON_ERROR,
  ON_ERROR_RESET,
  DESCRIPTION,
  HELP,
  DATA1,
  DATA2 
)

Set an error with two data-fields.

The data of the error is directly added to this function, therefore this error can only be triggered by this single codeline.

Parameters
IDIdentifier of the error. Must be unique and is therefore defined in the file ERROR_ID_Device.h
PERMISSIONOr-concatinated list of permission-levels which are allowed to reset this error.
ON_ERRORReaction which is called immediately after error set.
ON_ERROR_RESETReaction which is called after an error-reset.
DESCRIPTIONText which is displayed in the error list.
HELPText which is displayed in the help window for this error.
DATA1Data to be attached to this error. See Details on Page Data appended to errors.
DATA2Data to be attached to this error. See Details on Page Data appended to errors.

◆ SetErrorData2Compare

#define SetErrorData2Compare (   ID,
  PERMISSION,
  ON_ERROR,
  ON_ERROR_RESET,
  DESCRIPTION,
  HELP,
  DATA1,
  COMPARE1,
  DATA2,
  COMPARE2 
)

Use to set an error with two data-fielda and compare functiona.

The data of the error is directly added to this function, therefore this error can only be triggered by this single codeline. If the error is called more than once, the compare-function is used to update the data attached to this error. See page Errors with compare function to update the data attached to the error for details about the compare function.

Parameters
IDIdentifier of the error. Must be unique and is therefore defined in the file ERROR_ID_Device.h
PERMISSIONOr-concatinated list of permission-levels which are allowed to reset this error.
ON_ERRORReaction which is called immediately after error set.
ON_ERROR_RESETReaction which is called after an error-reset.
DESCRIPTIONText which is displayed in the error list.
HELPText which is displayed in the help window for this error.
DATA1Data to be attached to this error. See Details on Page Data appended to errors.
COMPARE1Compare function to update the attached data. See Details on Page Errors with compare function to update the data attached to the error.
DATA2Data to be attached to this error. See Details on Page Data appended to errors.
COMPARE2Compare function to update the attached data. See Details on Page Errors with compare function to update the data attached to the error.

◆ SetErrorData3

#define SetErrorData3 (   ID,
  PERMISSION,
  ON_ERROR,
  ON_ERROR_RESET,
  DESCRIPTION,
  HELP,
  DATA1,
  DATA2,
  DATA3 
)

Set an error with three data-fields.

The data of the error is directly added to this function, therefore this error can only be triggered by this single codeline.

Parameters
IDIdentifier of the error. Must be unique and is therefore defined in the file ERROR_ID_Device.h
PERMISSIONOr-concatinated list of permission-levels which are allowed to reset this error.
ON_ERRORReaction which is called immediately after error set.
ON_ERROR_RESETReaction which is called after an error-reset.
DESCRIPTIONText which is displayed in the error list.
HELPText which is displayed in the help window for this error.
DATA1Data to be attached to this error. See Details on Page Data appended to errors.
DATA2Data to be attached to this error. See Details on Page Data appended to errors.
DATA3Data to be attached to this error. See Details on Page Data appended to errors.

◆ SetErrorData4

#define SetErrorData4 (   ID,
  PERMISSION,
  ON_ERROR,
  ON_ERROR_RESET,
  DESCRIPTION,
  HELP,
  DATA1,
  DATA2,
  DATA3,
  DATA4 
)

Set an error with four data-fields.

The data of the error is directly added to this function, therefore this error can only be triggered by this single codeline.

Parameters
IDIdentifier of the error. Must be unique and is therefore defined in the file ERROR_ID_Device.h
PERMISSIONOr-concatinated list of permission-levels which are allowed to reset this error.
ON_ERRORReaction which is called immediately after error set.
ON_ERROR_RESETReaction which is called after an error-reset.
DESCRIPTIONText which is displayed in the error list.
HELPText which is displayed in the help window for this error.
DATA1Data to be attached to this error. See Details on Page Data appended to errors.
DATA2Data to be attached to this error. See Details on Page Data appended to errors.
DATA3Data to be attached to this error. See Details on Page Data appended to errors.
DATA4Data to be attached to this error. See Details on Page Data appended to errors.

◆ SetErrorId

#define SetErrorId (   ID)
Value:
do \
{ \
static const tErrorSource ERR_VAR_NAME(g_t##ID##Source, __LINE__) __attribute__((section("error_sources"), used)) = { \
__LINE__, \
g_sFileName, \
sizeof(g_sFileName) - 1 \
}; \
_SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__)); \
}while(0)
tErrorListItem * _SetErrorX(const tError *ptError, const tErrorSource *ptErrorSource,...)
This function adds a error to the stack.
Definition: Error.c:352

Set an error which is previously defined by "DefineError".

Parameters
IDIdentifier of the predefined error.

◆ SetErrorIdData1

#define SetErrorIdData1 (   ID,
  DATA1 
)
Value:
do \
{ \
static const tErrorSource ERR_VAR_NAME(g_t##ID##Source, __LINE__) __attribute__((section("error_sources"), used)) = { \
__LINE__, \
g_sFileName, \
sizeof(g_sFileName) - 1 \
}; \
\
if(sizeof(DATA1) < 4) \
{ \
int32_t ERR_VAR_NAME(DataTemp, __LINE__) = DATA1; \
_SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__), ERR_VAR_NAME(DataTemp, __LINE__)); \
} \
else \
{ \
_SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__), DATA1); \
} \
}while(0)

Set an error which is previously defined by "DefineError".

Parameters
IDIdentifier of the predefined error.
DATA1Data to be attached to this error. See Details on Page Data appended to errors.

◆ SetErrorIdData2

#define SetErrorIdData2 (   ID,
  DATA1,
  DATA2 
)

Set an error which is previously defined by "DefineError".

Parameters
IDIdentifier of the predefined error.
DATA1Data to be attached to this error. See Details on Page Data appended to errors.
DATA2Data to be attached to this error. See Details on Page Data appended to errors.

◆ SetErrorIdData3

#define SetErrorIdData3 (   ID,
  DATA1,
  DATA2,
  DATA3 
)

Set an error which is previously defined by "DefineError".

Parameters
IDIdentifier of the predefined error.
DATA1Data to be attached to this error. See Details on Page Data appended to errors.
DATA2Data to be attached to this error. See Details on Page Data appended to errors.
DATA3Data to be attached to this error. See Details on Page Data appended to errors.

◆ SetErrorIdData4

#define SetErrorIdData4 (   ID,
  DATA1,
  DATA2,
  DATA3,
  DATA4 
)

Set an error which is previously defined by "DefineError".

Parameters
IDIdentifier of the predefined error.
DATA1Data to be attached to this error. See Details on Page Data appended to errors.
DATA2Data to be attached to this error. See Details on Page Data appended to errors.
DATA3Data to be attached to this error. See Details on Page Data appended to errors.
DATA4Data to be attached to this error. See Details on Page Data appended to errors.

◆ SetErrorSource

#define SetErrorSource (   ID,
  PERMISSION,
  ON_ERROR,
  ON_ERROR_RESET,
  DESCRIPTION,
  HELP,
  SOURCE 
)
Value:
do \
{ \
ASSERT_DESCRIPTION(DESCRIPTION); \
ASSERT_HELP(HELP); \
static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
\
static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
ID, \
0, \
PERMISSION, \
g_s##ID##Description, \
sizeof(DESCRIPTION) - 1, \
g_s##ID##Help, \
sizeof(HELP) - 1, \
&g_t##ON_ERROR, \
&g_t##ON_ERROR_RESET, \
}; \
_SetErrorX(&g_t##ID, SOURCE); \
}while(0)

Set an error without data but with an external tErrorSource structure The data of the error is directly added to this function, therefore this error can only be triggered by this single codeline.

Parameters
IDIdentifier of the error. Must be unique and is therefore defined in the file ERROR_ID_Device.h
PERMISSIONOr-concatinated list of permission-levels which are allowed to reset this error.
ON_ERRORReaction which is called immediately after error set.
ON_ERROR_RESETReaction which is called after an error-reset.
DESCRIPTIONText which is displayed in the error list.
HELPText which is displayed in the help window for this error.
SOURCEA pointer to a tErrorSource structure.

◆ static_assert

#define static_assert   _Static_assert

◆ str

#define str (   s)    #s

Helper Macro to convert to string.

◆ xstr

#define xstr (   s)    str(s)

Helper Macro to convert to string.

Typedef Documentation

◆ fpOnErrorResetX

typedef bool(* fpOnErrorResetX) (void)

Structure used in tError to describe a function to be called on error reset.

The function must return true in case the error is allowed to reset.

◆ fpOnErrorX

typedef void(* fpOnErrorX) (void)

Structure used in tError to describe a function to be called on error set.

Enumeration Type Documentation

◆ ERROR_FLAGS

Flags used for errors.

must macht the enum ACCESS_LEVEL in PARA_Lib.h

Enumerator
VIEWER_RESET 

Can be reset by user with Viewer access level.

USER_RESET 

Can be reset by user with User access level.

PROFESSIONAL_RESET 

Can be reset by user with Professional access level.

DEVELOPER_RESET 

Can be reset by user with Developer access level.

PLC_RESET 

Can be reset by the PLC.

CODE_RESET 

Can be reset by the program it-selve e.g. after Init.

NV_STORED 

Stored in Non-Volatile RAM.

Function Documentation

◆ _SetErrorX()

tErrorListItem * _SetErrorX ( const tError ptError,
const tErrorSource ptErrorSource,
  ... 
)

This function adds a error to the stack.

Parameters
ptErrorError to be added
ptErrorSourceSource of this error.
...additional Pointers to Data. Each Pointer can be any datatype up to 32 Bit length.

◆ ErrorClear()

void ErrorClear ( uint8_t  ui8AccessLevel)

Removes all errors from stack if access level is sufficient, might be called after Init.

Parameters
ui8AccessLevelaccess level of requesting user as defined in ACCESS_LEVEL

◆ ErrorInit()

void ErrorInit ( void  )

Inits the Error Stack with 0.

◆ ErrorResetX()

void ErrorResetX ( uint8_t  ui8AccessLevel)

Resets all pending errors if access level is sufficient.

Parameters
ui8AccessLevelaccess level of requesting user as defined in ACCESS_LEVEL

◆ ErrorsPending()

bool ErrorsPending ( void  )

Check if errors are pending.

Return values
Trueif there are errors that not have been reseted

◆ GetErrorId()

uint16_t GetErrorId ( uint32_t  position)

Get Error ID of the Error on a specified Position.

Return values
ErrorList Item on the specified Position

◆ IsErrorPending()

bool IsErrorPending ( uint32_t  position)

Check if the requestes Error-Position is pending.

Return values
Trueif the requested Error-Entry pending

◆ MaxAbsFloat()

void MaxAbsFloat ( void *  DataOld,
float  DataNew 
)

Update the atatched data if new value abs is higher.

Parameters
DataOldPointer to old data to be updated.
DataNewNew data

◆ MaxFloat()

void MaxFloat ( void *  DataOld,
float  DataNew 
)

Update the atached data if new value is higher.

Parameters
DataOldPointer to old data to be updated.
DataNewNew data

◆ MaxInt()

void MaxInt ( void *  DataOld,
int32_t  DataNew 
)

Update the atatched data if new value is higher.

Parameters
DataOldPointer to old data to be updated.
DataNewNew data

◆ MaxUInt()

void MaxUInt ( void *  DataOld,
uint32_t  DataNew 
)

Update the atatched data if new value is higher.

Parameters
DataOldPointer to old data to be updated.
DataNewNew data

◆ MinFloat()

void MinFloat ( void *  DataOld,
float  DataNew 
)

Update the atatched data if new value is lower.

Parameters
DataOldPointer to old data to be updated.
DataNewNew data

◆ MinInt()

void MinInt ( void *  DataOld,
int32_t  DataNew 
)

Update the atatched data if new value is lower.

Parameters
DataOldPointer to old data to be updated.
DataNewNew data

◆ MinUInt()

void MinUInt ( void *  DataOld,
uint32_t  DataNew 
)

Update the atatched data if new value is lower.

Parameters
DataOldPointer to old data to be updated.
DataNewNew data

◆ NoDataUpdate()

void NoDataUpdate ( void *  fDataOld,
  ... 
)

Dummy Function for no Data-updates.

Do nothing.

Parameters
fDataOld- Ignored
...additional Pointers to Data. Each Pointer can be any datatype up to 32 Bit length.

◆ NoOnErrorReaction()

void NoOnErrorReaction ( void  )

This function is called if no Reaction is required after an error.

This function does nothing.

◆ NoOnErrorResetReaction()

bool NoOnErrorResetReaction ( void  )

This function is called if no Reaction is required after an error reset.

This function does nothing.

Return values
truealways.

◆ PendingErrosSortedByTime()

uint32_t PendingErrosSortedByTime ( tErrorListItem pptPendingErrorList[])

Get an array of the pending Errors sorted by tTimestampFirst.

Parameters
pptPendingErrorListAn array of pointers to errors. MUST be at least MAX_NUMBER_OF_ERRORS in size. will contain the pending errors in ascending time order. Index’s higher than the number of pending errors will be unchanged.
Return values
Numberof pending errors

◆ ResetErrorIdRange()

void ResetErrorIdRange ( uint16_t  ui16ErrorIdStart,
uint16_t  ui16ErrorIdEnd,
uint8_t  ui8AccessLevel 
)

Resets all pending errors in a range of error IDs if access level is sufficient.

It is used for Fault Ride Through

Parameters
ui16ErrorIdStartStart of Error-ID range
ui16ErrorIdEndEnd of Error-ID range
ui8AccessLevelaccess level of requesting user as defined in ACCESS_LEVEL

Variable Documentation

◆ g_ptErrorList

tErrorListItem g_ptErrorList[30]
extern

This array contains the error stack.

◆ g_sFileName

const char g_sFileName[] = __BASE_FILE__
static

The filename for all Errors within a module.

This string is defined in all modules which includes the file Error.h. It is defined here, to avoid multiple exisence of the same text in flash, if more than one error is defined in one module.

◆ g_tNoOnErrorReaction

const tOnErrorReaction g_tNoOnErrorReaction
extern

◆ g_tNoOnErrorResetReaction

const tOnErrorResetReaction g_tNoOnErrorResetReaction
extern

◆ g_u32ErrorPending

uint32_t g_u32ErrorPending
extern

An error that has not been reset is marked with a high bit, bit 0 corresponds to g_ptErrorList[0] etc.