26#if __STDC_VERSION__ >= 201112L && ! defined __cplusplus
29 #define static_assert _Static_assert
33#define MAX_NUMBER_OF_ERRORS 30
36#define MIN_ERR_REACTION_NAME_LENTH 10
38#define MIN_DESCRIPTION_LENTH 10
40#define MIN_HELP_LENTH 20
43#define ERROR_STACK_OVERFLOW 0x80000000
46#define ERROR_SYSTEM_VERSION 2
129#define ERR_VAR_NAME_SRT(x, y) x ## y
131#define ERR_VAR_NAME(x, y) ERR_VAR_NAME_SRT(x, y)
134#define xstr(s) str(s)
139#define ASSERT_REACTION_NAME(NAME) static_assert(sizeof(NAME) > MIN_ERR_REACTION_NAME_LENTH, \
140"Error reaction name to short must be at least "xstr(MIN_ERR_REACTION_NAME_LENTH)" characters long!") \
143#define ASSERT_DESCRIPTION(DESCRIPTION) static_assert(sizeof(DESCRIPTION) > MIN_DESCRIPTION_LENTH, \
144"Error description text to short must be at least "xstr(MIN_DESCRIPTION_LENTH)" characters long!") \
147#define ASSERT_HELP(HELP) static_assert(sizeof(HELP) > MIN_HELP_LENTH, \
148"Error help text to short must be at least "xstr(MIN_HELP_LENTH)" characters long!") \
161#define DefineError(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP) \
162 ASSERT_DESCRIPTION(DESCRIPTION); \
164 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
165 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
167 const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
171 g_s##ID##Description, \
172 sizeof(DESCRIPTION) - 1, \
176 &g_t##ON_ERROR_RESET, \
190#define DefineErrorData(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA_COUNT) \
191 ASSERT_DESCRIPTION(DESCRIPTION); \
193 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
194 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
196 const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
200 g_s##ID##Description, \
201 sizeof(DESCRIPTION) - 1, \
205 &g_t##ON_ERROR_RESET, \
213#define DeclareError(ID) const tError g_t##ID
225#define SetError(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP) \
228 ASSERT_DESCRIPTION(DESCRIPTION); \
230 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
231 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
232 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
235 sizeof(g_sFileName) - 1 \
238 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
242 g_s##ID##Description, \
243 sizeof(DESCRIPTION) - 1, \
247 &g_t##ON_ERROR_RESET, \
249 _SetErrorX(&g_t##ID, &g_t##ID##Source); \
263#define SetErrorSource(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, SOURCE) \
266 ASSERT_DESCRIPTION(DESCRIPTION); \
268 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
269 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
271 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
275 g_s##ID##Description, \
276 sizeof(DESCRIPTION) - 1, \
280 &g_t##ON_ERROR_RESET, \
282 _SetErrorX(&g_t##ID, SOURCE); \
296#define SetErrorData1(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1) \
299 ASSERT_DESCRIPTION(DESCRIPTION); \
301 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
302 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
303 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
306 sizeof(g_sFileName) - 1 \
309 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
313 g_s##ID##Description, \
314 sizeof(DESCRIPTION) - 1, \
318 &g_t##ON_ERROR_RESET, \
320 if(sizeof(DATA1) < 4) \
322 int32_t ERR_VAR_NAME(DataTemp, __LINE__) = DATA1; \
323 _SetErrorX(&g_t##ID, &g_t##ID##Source, ERR_VAR_NAME(DataTemp, __LINE__)); \
327 _SetErrorX(&g_t##ID, &g_t##ID##Source, *(uint32_t*)&DATA1); \
345#define SetErrorData1Compare(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, COMPARE1) \
348 ASSERT_DESCRIPTION(DESCRIPTION); \
350 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
351 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
352 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
355 sizeof(g_sFileName) - 1 \
358 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
362 g_s##ID##Description, \
363 sizeof(DESCRIPTION) - 1, \
367 &g_t##ON_ERROR_RESET, \
370 tErrorListItem* ERR_VAR_NAME(ptError, __LINE__); \
371 if(sizeof(DATA1) < 4) \
373 int32_t ERR_VAR_NAME(DataTemp, __LINE__) = DATA1; \
374 ERR_VAR_NAME(ptError, __LINE__) = _SetErrorX(&g_t##ID, &g_t##ID##Source, ERR_VAR_NAME(DataTemp, __LINE__)); \
378 ERR_VAR_NAME(ptError, __LINE__) = _SetErrorX(&g_t##ID, &g_t##ID##Source, *(uint32_t*)&DATA1); \
380 COMPARE1(ERR_VAR_NAME(ptError, __LINE__)->Data, DATA1); \
395#define SetErrorData2(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, DATA2) \
398 ASSERT_DESCRIPTION(DESCRIPTION); \
400 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
401 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
402 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
405 sizeof(g_sFileName) - 1 \
408 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
412 g_s##ID##Description, \
413 sizeof(DESCRIPTION) - 1, \
417 &g_t##ON_ERROR_RESET, \
420 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
421 if(sizeof(DATA1) < 4) \
423 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
424 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
428 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
430 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
431 if(sizeof(DATA2) < 4) \
433 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
434 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
438 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
440 _SetErrorX(&g_t##ID, &g_t##ID##Source, *ERR_VAR_NAME(pDataTemp1, __LINE__), *ERR_VAR_NAME(pDataTemp2, __LINE__)); \
459#define SetErrorData2Compare(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, COMPARE1, DATA2, COMPARE2) \
462 ASSERT_DESCRIPTION(DESCRIPTION); \
464 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
465 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
466 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
469 sizeof(g_sFileName) - 1 \
472 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
476 g_s##ID##Description, \
477 sizeof(DESCRIPTION) - 1, \
481 &g_t##ON_ERROR_RESET, \
484 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
485 if(sizeof(DATA1) < 4) \
487 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
488 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
492 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
494 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
495 if(sizeof(DATA2) < 4) \
497 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
498 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
502 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
504 tErrorListItem* ERR_VAR_NAME(ptError, __LINE__) = _SetErrorX(&g_t##ID, &g_t##ID##Source, *ERR_VAR_NAME(pDataTemp1, __LINE__), \
505 *ERR_VAR_NAME(pDataTemp2, __LINE__)); \
506 if((ERR_VAR_NAME(ptError, __LINE__) != 0) && (ERR_VAR_NAME(ptError, __LINE__)->Data != 0)) \
508 COMPARE1(ERR_VAR_NAME(ptError, __LINE__)->Data, DATA1); \
509 COMPARE2(ERR_VAR_NAME(ptError, __LINE__)->Data + 4, DATA2); \
526#define SetErrorData3(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, DATA2, DATA3) \
529 ASSERT_DESCRIPTION(DESCRIPTION); \
531 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
532 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
533 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
536 sizeof(g_sFileName) - 1 \
539 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
543 g_s##ID##Description, \
544 sizeof(DESCRIPTION) - 1, \
548 &g_t##ON_ERROR_RESET, \
551 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
552 if(sizeof(DATA1) < 4) \
554 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
555 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
559 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
561 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
562 if(sizeof(DATA2) < 4) \
564 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
565 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
569 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
571 int32_t* ERR_VAR_NAME(pDataTemp3, __LINE__); \
572 if(sizeof(DATA3) < 4) \
574 int32_t ERR_VAR_NAME(DataTemp3, __LINE__) = DATA3; \
575 ERR_VAR_NAME(pDataTemp3, __LINE__) = &ERR_VAR_NAME(DataTemp3, __LINE__); \
579 ERR_VAR_NAME(pDataTemp3, __LINE__) = (int32_t*)&(DATA3); \
581 _SetErrorX(&g_t##ID, &g_t##ID##Source, *ERR_VAR_NAME(pDataTemp1, __LINE__), *ERR_VAR_NAME(pDataTemp2, __LINE__), \
582 *ERR_VAR_NAME(pDataTemp3, __LINE__)); \
599#define SetErrorData4(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, DATA2, DATA3, DATA4) \
602 ASSERT_DESCRIPTION(DESCRIPTION); \
604 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
605 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
606 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
609 sizeof(g_sFileName) - 1 \
612 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
616 g_s##ID##Description, \
617 sizeof(DESCRIPTION) - 1, \
621 &g_t##ON_ERROR_RESET, \
624 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
625 if(sizeof(DATA1) < 4) \
627 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
628 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
632 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
634 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
635 if(sizeof(DATA2) < 4) \
637 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
638 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
642 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
644 int32_t* ERR_VAR_NAME(pDataTemp3, __LINE__); \
645 if(sizeof(DATA3) < 4) \
647 int32_t ERR_VAR_NAME(DataTemp3, __LINE__) = DATA3; \
648 ERR_VAR_NAME(pDataTemp3, __LINE__) = &ERR_VAR_NAME(DataTemp3, __LINE__); \
652 ERR_VAR_NAME(pDataTemp3, __LINE__) = (int32_t*)&(DATA3); \
654 int32_t* ERR_VAR_NAME(pDataTemp4, __LINE__); \
655 if(sizeof(DATA4) < 4) \
657 int32_t ERR_VAR_NAME(DataTemp4, __LINE__) = DATA4; \
658 ERR_VAR_NAME(pDataTemp4, __LINE__) = &ERR_VAR_NAME(DataTemp4, __LINE__); \
662 ERR_VAR_NAME(pDataTemp4, __LINE__) = (int32_t*)&(DATA4); \
664 _SetErrorX(&g_t##ID, &g_t##ID##Source, *ERR_VAR_NAME(pDataTemp1, __LINE__), *ERR_VAR_NAME(pDataTemp2, __LINE__), \
665 *ERR_VAR_NAME(pDataTemp3, __LINE__), *ERR_VAR_NAME(pDataTemp4, __LINE__)); \
672#define SetErrorId(ID) \
675 static const tErrorSource ERR_VAR_NAME(g_t##ID##Source, __LINE__) __attribute__((section("error_sources"), used)) = { \
678 sizeof(g_sFileName) - 1 \
681 _SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__)); \
689#define SetErrorIdData1(ID, DATA1) \
692 static const tErrorSource ERR_VAR_NAME(g_t##ID##Source, __LINE__) __attribute__((section("error_sources"), used)) = { \
695 sizeof(g_sFileName) - 1 \
698 if(sizeof(DATA1) < 4) \
700 int32_t ERR_VAR_NAME(DataTemp, __LINE__) = DATA1; \
701 _SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__), ERR_VAR_NAME(DataTemp, __LINE__)); \
705 _SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__), DATA1); \
715#define SetErrorIdData2(ID, DATA1, DATA2) \
718 static const tErrorSource ERR_VAR_NAME(g_t##ID##Source, __LINE__) __attribute__((section("error_sources"), used)) = { \
721 sizeof(g_sFileName) - 1 \
724 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
725 if(sizeof(DATA1) < 4) \
727 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
728 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
732 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
734 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
735 if(sizeof(DATA2) < 4) \
737 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
738 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
742 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
744 _SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__), *ERR_VAR_NAME(pDataTemp1, __LINE__), \
745 *ERR_VAR_NAME(pDataTemp2, __LINE__)); \
755#define SetErrorIdData3(ID, DATA1, DATA2, DATA3) \
758 static const tErrorSource ERR_VAR_NAME(g_t##ID##Source, __LINE__) __attribute__((section("error_sources"), used)) = { \
761 sizeof(g_sFileName) - 1 \
764 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
765 if(sizeof(DATA1) < 4) \
767 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
768 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
772 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
774 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
775 if(sizeof(DATA2) < 4) \
777 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
778 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
782 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
784 int32_t* ERR_VAR_NAME(pDataTemp3, __LINE__); \
785 if(sizeof(DATA3) < 4) \
787 int32_t ERR_VAR_NAME(DataTemp3, __LINE__) = DATA3; \
788 ERR_VAR_NAME(pDataTemp3, __LINE__) = &ERR_VAR_NAME(DataTemp3, __LINE__); \
792 ERR_VAR_NAME(pDataTemp3, __LINE__) = (int32_t*)&(DATA3); \
794 _SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__), *ERR_VAR_NAME(pDataTemp1, __LINE__), \
795 *ERR_VAR_NAME(pDataTemp2, __LINE__), \
796 *ERR_VAR_NAME(pDataTemp3, __LINE__)); \
807#define SetErrorIdData4(ID, DATA1, DATA2, DATA3, DATA4) \
810 static const tErrorSource ERR_VAR_NAME(g_t##ID##Source, __LINE__) __attribute__((section("error_sources"), used)) = { \
813 sizeof(g_sFileName) - 1 \
816 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
817 if(sizeof(DATA1) < 4) \
819 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
820 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
824 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
826 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
827 if(sizeof(DATA2) < 4) \
829 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
830 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
834 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
836 int32_t* ERR_VAR_NAME(pDataTemp3, __LINE__); \
837 if(sizeof(DATA3) < 4) \
839 int32_t ERR_VAR_NAME(DataTemp3, __LINE__) = DATA3; \
840 ERR_VAR_NAME(pDataTemp3, __LINE__) = &ERR_VAR_NAME(DataTemp3, __LINE__); \
844 ERR_VAR_NAME(pDataTemp3, __LINE__) = (int32_t*)&(DATA3); \
846 int32_t* ERR_VAR_NAME(pDataTemp4, __LINE__); \
847 if(sizeof(DATA4) < 4) \
849 int32_t ERR_VAR_NAME(DataTemp4, __LINE__) = DATA4; \
850 ERR_VAR_NAME(pDataTemp4, __LINE__) = &ERR_VAR_NAME(DataTemp4, __LINE__); \
854 ERR_VAR_NAME(pDataTemp4, __LINE__) = (int32_t*)&(DATA4); \
856 _SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__), *ERR_VAR_NAME(pDataTemp1, __LINE__), \
857 *ERR_VAR_NAME(pDataTemp2, __LINE__), \
858 *ERR_VAR_NAME(pDataTemp3, __LINE__), \
859 *ERR_VAR_NAME(pDataTemp4, __LINE__)); \
869#define DefineOnErrorReaction(ERROR_REACTION, NAME, HELP) \
870ASSERT_REACTION_NAME(NAME); \
872static const char ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__)[] __attribute__((section("error_strings"), used)) = NAME; \
873static const char ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__)[] __attribute__((section("error_strings"), used)) = HELP; \
874const tOnErrorReaction g_t##ERROR_REACTION __attribute__((section("error_reactions"), used)) = { \
876 ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__), \
877 sizeof(ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__)) - 1, \
878 ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__), \
879 sizeof(ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__)) - 1 \
887#define DeclareOnErrorReaction(ERROR_REACTION) \
888 const tOnErrorReaction g_t##ERROR_REACTION; \
889 void ERROR_REACTION(void)
898#define DefineOnErrorResetReaction(ERROR_REACTION, NAME, HELP) \
899ASSERT_REACTION_NAME(NAME); \
901static const char ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__)[] __attribute__((section("error_strings"), used)) = NAME; \
902static const char ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__)[] __attribute__((section("error_strings"), used)) = HELP; \
903const tOnErrorResetReaction g_t##ERROR_REACTION __attribute__((section("error_reactions"), used)) = { \
905 ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__), \
906 sizeof(ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__)) - 1, \
907 ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__), \
908 sizeof(ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__)) - 1 \
916#define DeclareOnErrorResetReaction(ERROR_REACTION) \
917 const tOnErrorResetReaction g_t##ERROR_REACTION; \
918 bool ERROR_REACTION(void)
929static const char g_sFileName[] __attribute__((section(
"error_strings"), used)) = __BASE_FILE__;
946void MaxFloat(
void* DataOld,
float DataNew);
947void MinFloat(
void* DataOld,
float DataNew);
949void MaxInt(
void* DataOld, int32_t DataNew);
950void MinInt(
void* DataOld, int32_t DataNew);
951void MaxUInt(
void* DataOld, uint32_t DataNew);
952void MinUInt(
void* DataOld, uint32_t DataNew);
uint32_t PendingErrosSortedByTime(tErrorListItem *pptPendingErrorList[])
Get an array of the pending Errors sorted by tTimestampFirst.
Definition: Error.c:816
void MaxInt(void *DataOld, int32_t DataNew)
Update the atatched data if new value is higher.
Definition: Error.c:701
void ErrorInit(void)
Inits the Error Stack with 0.
Definition: Error.c:763
void MaxUInt(void *DataOld, uint32_t DataNew)
Update the atatched data if new value is higher.
Definition: Error.c:723
static const char g_sFileName[]
The filename for all Errors within a module.
Definition: Error.h:929
tErrorListItem g_ptErrorList[30]
This array contains the error stack.
Definition: Error.c:283
void MinUInt(void *DataOld, uint32_t DataNew)
Update the atatched data if new value is lower.
Definition: Error.c:734
void MaxAbsFloat(void *DataOld, float DataNew)
Update the atatched data if new value abs is higher.
Definition: Error.c:690
void MinInt(void *DataOld, int32_t DataNew)
Update the atatched data if new value is lower.
Definition: Error.c:712
void MaxFloat(void *DataOld, float DataNew)
Update the atached data if new value is higher.
Definition: Error.c:668
uint16_t GetErrorId(uint32_t position)
Get Error ID of the Error on a specified Position.
Definition: Error.c:789
void MinFloat(void *DataOld, float DataNew)
Update the atatched data if new value is lower.
Definition: Error.c:679
void ErrorResetX(uint8_t ui8AccessLevel)
Resets all pending errors if access level is sufficient.
Definition: Error.c:513
bool ErrorsPending(void)
Check if errors are pending.
Definition: Error.c:752
void(* fpOnErrorX)(void)
Structure used in tError to describe a function to be called on error set.
Definition: Error.h:64
ERROR_FLAGS
Flags used for errors.
Definition: Error.h:53
@ VIEWER_RESET
Can be reset by user with Viewer access level.
Definition: Error.h:54
@ PLC_RESET
Can be reset by the PLC.
Definition: Error.h:58
@ CODE_RESET
Can be reset by the program it-selve e.g. after Init.
Definition: Error.h:59
@ 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
@ NV_STORED
Stored in Non-Volatile RAM.
Definition: Error.h:60
void ErrorClear(uint8_t ui8AccessLevel)
Removes all errors from stack if access level is sufficient, might be called after Init.
Definition: Error.c:614
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
void NoDataUpdate(void *DataOld,...)
Dummy Function for no Data-updates.
Definition: Error.c:744
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.
Definition: Error.c:567
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...
Definition: Error.h:934
tErrorListItem * _SetErrorX(const tError *ptError, const tErrorSource *ptErrorSource,...)
This function adds a error to the stack.
Definition: Error.c:352
#define MAX_NUMBER_OF_ERRORS
Size of the error stack.
Definition: Error.h:33
#define DeclareOnErrorReaction(ERROR_REACTION)
Use to declare an ErrorReaction as external.
Definition: Error.h:887
bool IsErrorPending(uint32_t position)
Check if the requestes Error-Position is pending.
Definition: Error.c:780
bool(* fpOnErrorResetX)(void)
Structure used in tError to describe a function to be called on error reset.
Definition: Error.h:80
#define DeclareOnErrorResetReaction(ERROR_REACTION)
Use to declare an ErrorResetReaction as external.
Definition: Error.h:916
uint16_t void int32_t uint32_t ParameterAccessSource uint8_t ui8AccessLevel
Definition: PARA_Timestamp.c:63
Definition of a timestamp type.
Definition: timestamp.h:30
Main error structure.
Definition: Error.h:96
const uint16_t ui16Id
Error-ID.
Definition: Error.h:97
const uint16_t ui16DataCount
Number of attached variables (not byte). See Details on Page Data appended to errors.
Definition: Error.h:98
const uint32_t ui32Flags
Flags from enum ERROR_FLAGS e.g. error reset permissions.
Definition: Error.h:99
const uint32_t ui32HelpLength
Strlen of Help.
Definition: Error.h:103
const char * Help
Long help text explaining the cause and maybe how to solve the error. See Page Help-texts in Errors f...
Definition: Error.h:102
const tOnErrorReaction * OnError
Function to be called on first time setting the error. See Page Actions on Error set and reset for de...
Definition: Error.h:104
const tOnErrorResetReaction * OnErrorReset
Function to be called on reseting the error. See Page Actions on Error set and reset for details.
Definition: Error.h:105
const uint32_t ui32DescriptionLength
Strlen of Description.
Definition: Error.h:101
const char * Description
Short Description of the error.
Definition: Error.h:100
Structure used in the error stack.
Definition: Error.h:119
Type_Timestamp tTimestampFirst
Time when the error was set the first time.
Definition: Error.h:122
Type_Timestamp tTimestampLast
Time when the error was set the last time.
Definition: Error.h:123
void * Data
Pointer to the attached data the number is stored on ptError. The length is defined in Error-Definiti...
Definition: Error.h:125
const tErrorSource * ptErrorSource
Location of the error in source code.
Definition: Error.h:121
const tError * ptError
Pointer to the error itself.
Definition: Error.h:120
uint32_t ui32ErrorCount
Number of occurrences. Starts with 1 and increments on every occurence.
Definition: Error.h:124
Structure used in tError holding source-code file an line.
Definition: Error.h:110
const uint32_t ui32Line
Source-code line.
Definition: Error.h:111
const char * File
Source-code filename and path.
Definition: Error.h:112
const uint32_t ui32FileLength
Strlen of filename.
Definition: Error.h:113
The error reaction is called on occurence of the error.
Definition: Error.h:70
const uint32_t ui32HelpSize
StrLen of Help.
Definition: Error.h:75
const fpOnErrorX fpErrorReaction
Function to be called.
Definition: Error.h:71
const char * cHelp
Help Text. See Page Help-texts in Errors for details.
Definition: Error.h:74
const char * cName
Name of the Function.
Definition: Error.h:72
const uint32_t ui32NameSize
StrLen of Name.
Definition: Error.h:73
The error reset reaction is called on reset of the error.
Definition: Error.h:86
const fpOnErrorResetX fpErrorReaction
Function to be called.
Definition: Error.h:87
const uint32_t ui32HelpSize
StrLen of Help.
Definition: Error.h:91
const char * cHelp
Help Text. See Page Help-texts in Errors for details.
Definition: Error.h:90
const char * cName
Name of the Function.
Definition: Error.h:88
const uint32_t ui32NameSize
StrLen of Name.
Definition: Error.h:89
Definition of timestamp data-structs.