Up to four data fields can be appended to an error and are written to the error-log. This is useful for example to store the actual current in case of an overcurrent error. Data can be appended to predefined errors and to direct called errors (see page Definition and raise of errors in source code).
To raise an error with data directly, the functions SetErrorData1 to SetErrorData4 can be used (for one to four data fields). The data is appended as parameter to these macros.
Example:
uint32_t ADC_Number = 3;
"Test Error 3 Data: %u",
"DOC_E ADC %u peripheral internal error (problem of clocking, enable/disable, erroneous state).",
ADC_Number);
void NoOnErrorReaction(void)
This function is called if no Reaction is required after an error.
Definition: Error.c:332
bool NoOnErrorResetReaction(void)
This function is called if no Reaction is required after an error reset.
Definition: Error.c:341
#define SetErrorData1(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1)
Set an error with one data-field.
Definition: Error.h:296
@ PLC_RESET
Can be reset by the PLC.
Definition: Error.h:58
@ DEVELOPER_RESET
Can be reset by user with Developer access level.
Definition: Error.h:57
@ PROFESSIONAL_RESET
Can be reset by user with Professional access level.
Definition: Error.h:56
@ USER_RESET
Can be reset by user with User access level.
Definition: Error.h:55
#define SampleErrorID_3
Definition: Sample_Errors.h:18
The appended data ADC_Number is shown in the error-text in the errorlist or/and in the helptext of the error. It is included into these texts with a printf syntax known from the programming language c.
Helptext tof this error:
Errors with compare function to update the data attached to the error
In some cases an error can be raised several times, for example if a value is checked regularly against a limit. In this case it can be useful to store the maximum or minimum of a data value. In the following example an overvoltage is checked in control task. The maximum voltage is stored in the error data.
float fVoltage5V = 5.1f;
for (int i=0; i<10; i++)
{
if (fVoltage5V <= 5.5f) {fVoltage5V+=0.1f;}
"Test Error 4",
"DOC_D Die 5V Versorgungsspannung war zu hoch. Zulässig sind +5%.<br>gemessener Maximalwert: %.2fV"\
"DOC_E The 5V Supply Voltage was to high. Allowed are +5%.<br>measured Maximum value: %.2fV",\
}
void MaxFloat(void *DataOld, float DataNew)
Update the atached data if new value is higher.
Definition: Error.c:668
#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.
Definition: Error.h:345
#define SampleErrorID_4
Definition: Sample_Errors.h:19
In this example the measured value is only displayed in helptext. Error-log:
The number of errors and first and last timestamp are also displayed.
The compare-function can be one of the following predefined functions:
- MaxFloat - Maximum of a floating point variable
- MinFloat - Minimum of a floating point variable
- MaxAbsFloat - Absolute maximum of a floating point variable
- MaxInt - Maximum of an integer variable
- MinInt - Minimum of an integer variable
- MaxUInt - Maximum of an unsigned integer variable
- MinUInt - Minimum of an unsigned integer variable
- NoDataUpdate - No update will be performed, the first value is stored. This is useful if mor than one variable is stored, and not every variable has to be updated.