29#if __STDC_VERSION__ >= 201112L && ! defined __cplusplus
32 #define static_assert _Static_assert
36#define MAX_NUMBER_OF_ERRORS 30
39#define MIN_ERR_REACTION_NAME_LENTH 10
41#define MIN_DESCRIPTION_LENTH 10
43#define MIN_HELP_LENTH 20
46#define ERROR_STACK_OVERFLOW 0x80000000
49#define ERROR_SYSTEM_VERSION 2
132#define ERR_VAR_NAME_SRT(x, y) x ## y
134#define ERR_VAR_NAME(x, y) ERR_VAR_NAME_SRT(x, y)
137#define xstr(s) str(s)
142#define ASSERT_REACTION_NAME(NAME) static_assert(sizeof(NAME) > MIN_ERR_REACTION_NAME_LENTH, \
143"Error reaction name to short must be at least "xstr(MIN_ERR_REACTION_NAME_LENTH)" characters long!") \
146#define ASSERT_DESCRIPTION(DESCRIPTION) static_assert(sizeof(DESCRIPTION) > MIN_DESCRIPTION_LENTH, \
147"Error description text to short must be at least "xstr(MIN_DESCRIPTION_LENTH)" characters long!") \
150#define ASSERT_HELP(HELP) static_assert(sizeof(HELP) > MIN_HELP_LENTH, \
151"Error help text to short must be at least "xstr(MIN_HELP_LENTH)" characters long!") \
164#define DefineError(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP) \
165 ASSERT_DESCRIPTION(DESCRIPTION); \
167 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
168 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
170 const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
174 g_s##ID##Description, \
175 sizeof(DESCRIPTION) - 1, \
179 &g_t##ON_ERROR_RESET, \
193#define DefineErrorData(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA_COUNT) \
194 ASSERT_DESCRIPTION(DESCRIPTION); \
196 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
197 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
199 const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
203 g_s##ID##Description, \
204 sizeof(DESCRIPTION) - 1, \
208 &g_t##ON_ERROR_RESET, \
216#define DeclareError(ID) const tError g_t##ID
228#define SetError(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP) \
231 ASSERT_DESCRIPTION(DESCRIPTION); \
233 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
234 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
235 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
238 sizeof(g_sFileName) - 1 \
241 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
245 g_s##ID##Description, \
246 sizeof(DESCRIPTION) - 1, \
250 &g_t##ON_ERROR_RESET, \
252 _SetErrorX(&g_t##ID, &g_t##ID##Source); \
266#define SetErrorSource(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, SOURCE) \
269 ASSERT_DESCRIPTION(DESCRIPTION); \
271 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
272 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
274 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
278 g_s##ID##Description, \
279 sizeof(DESCRIPTION) - 1, \
283 &g_t##ON_ERROR_RESET, \
285 _SetErrorX(&g_t##ID, SOURCE); \
299#define SetErrorData1(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1) \
302 ASSERT_DESCRIPTION(DESCRIPTION); \
304 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
305 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
306 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
309 sizeof(g_sFileName) - 1 \
312 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
316 g_s##ID##Description, \
317 sizeof(DESCRIPTION) - 1, \
321 &g_t##ON_ERROR_RESET, \
323 if(sizeof(DATA1) < 4) \
325 int32_t ERR_VAR_NAME(DataTemp, __LINE__) = DATA1; \
326 _SetErrorX(&g_t##ID, &g_t##ID##Source, ERR_VAR_NAME(DataTemp, __LINE__)); \
330 _SetErrorX(&g_t##ID, &g_t##ID##Source, *(uint32_t*)&DATA1); \
348#define SetErrorData1Compare(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, COMPARE1) \
351 ASSERT_DESCRIPTION(DESCRIPTION); \
353 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
354 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
355 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
358 sizeof(g_sFileName) - 1 \
361 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
365 g_s##ID##Description, \
366 sizeof(DESCRIPTION) - 1, \
370 &g_t##ON_ERROR_RESET, \
373 tErrorListItem* ERR_VAR_NAME(ptError, __LINE__); \
374 if(sizeof(DATA1) < 4) \
376 int32_t ERR_VAR_NAME(DataTemp, __LINE__) = DATA1; \
377 ERR_VAR_NAME(ptError, __LINE__) = _SetErrorX(&g_t##ID, &g_t##ID##Source, ERR_VAR_NAME(DataTemp, __LINE__)); \
381 ERR_VAR_NAME(ptError, __LINE__) = _SetErrorX(&g_t##ID, &g_t##ID##Source, *(uint32_t*)&DATA1); \
383 COMPARE1(ERR_VAR_NAME(ptError, __LINE__)->Data, DATA1); \
398#define SetErrorData2(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, DATA2) \
401 ASSERT_DESCRIPTION(DESCRIPTION); \
403 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
404 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
405 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
408 sizeof(g_sFileName) - 1 \
411 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
415 g_s##ID##Description, \
416 sizeof(DESCRIPTION) - 1, \
420 &g_t##ON_ERROR_RESET, \
423 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
424 if(sizeof(DATA1) < 4) \
426 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
427 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
431 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
433 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
434 if(sizeof(DATA2) < 4) \
436 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
437 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
441 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
443 _SetErrorX(&g_t##ID, &g_t##ID##Source, *ERR_VAR_NAME(pDataTemp1, __LINE__), *ERR_VAR_NAME(pDataTemp2, __LINE__)); \
462#define SetErrorData2Compare(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, COMPARE1, DATA2, COMPARE2) \
465 ASSERT_DESCRIPTION(DESCRIPTION); \
467 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
468 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
469 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
472 sizeof(g_sFileName) - 1 \
475 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
479 g_s##ID##Description, \
480 sizeof(DESCRIPTION) - 1, \
484 &g_t##ON_ERROR_RESET, \
487 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
488 if(sizeof(DATA1) < 4) \
490 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
491 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
495 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
497 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
498 if(sizeof(DATA2) < 4) \
500 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
501 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
505 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
507 tErrorListItem* ERR_VAR_NAME(ptError, __LINE__) = _SetErrorX(&g_t##ID, &g_t##ID##Source, *ERR_VAR_NAME(pDataTemp1, __LINE__), \
508 *ERR_VAR_NAME(pDataTemp2, __LINE__)); \
509 if((ERR_VAR_NAME(ptError, __LINE__) != 0) && (ERR_VAR_NAME(ptError, __LINE__)->Data != 0)) \
511 COMPARE1(ERR_VAR_NAME(ptError, __LINE__)->Data, DATA1); \
512 COMPARE2(ERR_VAR_NAME(ptError, __LINE__)->Data + 4, DATA2); \
529#define SetErrorData3(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, DATA2, DATA3) \
532 ASSERT_DESCRIPTION(DESCRIPTION); \
534 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
535 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
536 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
539 sizeof(g_sFileName) - 1 \
542 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
546 g_s##ID##Description, \
547 sizeof(DESCRIPTION) - 1, \
551 &g_t##ON_ERROR_RESET, \
554 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
555 if(sizeof(DATA1) < 4) \
557 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
558 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
562 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
564 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
565 if(sizeof(DATA2) < 4) \
567 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
568 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
572 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
574 int32_t* ERR_VAR_NAME(pDataTemp3, __LINE__); \
575 if(sizeof(DATA3) < 4) \
577 int32_t ERR_VAR_NAME(DataTemp3, __LINE__) = DATA3; \
578 ERR_VAR_NAME(pDataTemp3, __LINE__) = &ERR_VAR_NAME(DataTemp3, __LINE__); \
582 ERR_VAR_NAME(pDataTemp3, __LINE__) = (int32_t*)&(DATA3); \
584 _SetErrorX(&g_t##ID, &g_t##ID##Source, *ERR_VAR_NAME(pDataTemp1, __LINE__), *ERR_VAR_NAME(pDataTemp2, __LINE__), \
585 *ERR_VAR_NAME(pDataTemp3, __LINE__)); \
602#define SetErrorData4(ID, PERMISSION, ON_ERROR, ON_ERROR_RESET, DESCRIPTION, HELP, DATA1, DATA2, DATA3, DATA4) \
605 ASSERT_DESCRIPTION(DESCRIPTION); \
607 static const char g_s##ID##Description[] __attribute__((section("error_strings"), used)) = DESCRIPTION; \
608 static const char g_s##ID##Help[] __attribute__((section("error_strings"), used)) = HELP; \
609 static const tErrorSource g_t##ID##Source __attribute__((section("error_sources"), used)) = { \
612 sizeof(g_sFileName) - 1 \
615 static const tError g_t##ID __attribute__((section("error_descriptor"), used)) = { \
619 g_s##ID##Description, \
620 sizeof(DESCRIPTION) - 1, \
624 &g_t##ON_ERROR_RESET, \
627 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
628 if(sizeof(DATA1) < 4) \
630 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
631 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
635 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
637 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
638 if(sizeof(DATA2) < 4) \
640 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
641 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
645 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
647 int32_t* ERR_VAR_NAME(pDataTemp3, __LINE__); \
648 if(sizeof(DATA3) < 4) \
650 int32_t ERR_VAR_NAME(DataTemp3, __LINE__) = DATA3; \
651 ERR_VAR_NAME(pDataTemp3, __LINE__) = &ERR_VAR_NAME(DataTemp3, __LINE__); \
655 ERR_VAR_NAME(pDataTemp3, __LINE__) = (int32_t*)&(DATA3); \
657 int32_t* ERR_VAR_NAME(pDataTemp4, __LINE__); \
658 if(sizeof(DATA4) < 4) \
660 int32_t ERR_VAR_NAME(DataTemp4, __LINE__) = DATA4; \
661 ERR_VAR_NAME(pDataTemp4, __LINE__) = &ERR_VAR_NAME(DataTemp4, __LINE__); \
665 ERR_VAR_NAME(pDataTemp4, __LINE__) = (int32_t*)&(DATA4); \
667 _SetErrorX(&g_t##ID, &g_t##ID##Source, *ERR_VAR_NAME(pDataTemp1, __LINE__), *ERR_VAR_NAME(pDataTemp2, __LINE__), \
668 *ERR_VAR_NAME(pDataTemp3, __LINE__), *ERR_VAR_NAME(pDataTemp4, __LINE__)); \
675#define SetErrorId(ID) \
678 static const tErrorSource ERR_VAR_NAME(g_t##ID##Source, __LINE__) __attribute__((section("error_sources"), used)) = { \
681 sizeof(g_sFileName) - 1 \
684 _SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__)); \
692#define SetErrorIdData1(ID, DATA1) \
695 static const tErrorSource ERR_VAR_NAME(g_t##ID##Source, __LINE__) __attribute__((section("error_sources"), used)) = { \
698 sizeof(g_sFileName) - 1 \
701 if(sizeof(DATA1) < 4) \
703 int32_t ERR_VAR_NAME(DataTemp, __LINE__) = DATA1; \
704 _SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__), ERR_VAR_NAME(DataTemp, __LINE__)); \
708 _SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__), DATA1); \
718#define SetErrorIdData2(ID, DATA1, DATA2) \
721 static const tErrorSource ERR_VAR_NAME(g_t##ID##Source, __LINE__) __attribute__((section("error_sources"), used)) = { \
724 sizeof(g_sFileName) - 1 \
727 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
728 if(sizeof(DATA1) < 4) \
730 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
731 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
735 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
737 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
738 if(sizeof(DATA2) < 4) \
740 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
741 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
745 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
747 _SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__), *ERR_VAR_NAME(pDataTemp1, __LINE__), \
748 *ERR_VAR_NAME(pDataTemp2, __LINE__)); \
758#define SetErrorIdData3(ID, DATA1, DATA2, DATA3) \
761 static const tErrorSource ERR_VAR_NAME(g_t##ID##Source, __LINE__) __attribute__((section("error_sources"), used)) = { \
764 sizeof(g_sFileName) - 1 \
767 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
768 if(sizeof(DATA1) < 4) \
770 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
771 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
775 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
777 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
778 if(sizeof(DATA2) < 4) \
780 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
781 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
785 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
787 int32_t* ERR_VAR_NAME(pDataTemp3, __LINE__); \
788 if(sizeof(DATA3) < 4) \
790 int32_t ERR_VAR_NAME(DataTemp3, __LINE__) = DATA3; \
791 ERR_VAR_NAME(pDataTemp3, __LINE__) = &ERR_VAR_NAME(DataTemp3, __LINE__); \
795 ERR_VAR_NAME(pDataTemp3, __LINE__) = (int32_t*)&(DATA3); \
797 _SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__), *ERR_VAR_NAME(pDataTemp1, __LINE__), \
798 *ERR_VAR_NAME(pDataTemp2, __LINE__), \
799 *ERR_VAR_NAME(pDataTemp3, __LINE__)); \
810#define SetErrorIdData4(ID, DATA1, DATA2, DATA3, DATA4) \
813 static const tErrorSource ERR_VAR_NAME(g_t##ID##Source, __LINE__) __attribute__((section("error_sources"), used)) = { \
816 sizeof(g_sFileName) - 1 \
819 int32_t* ERR_VAR_NAME(pDataTemp1, __LINE__); \
820 if(sizeof(DATA1) < 4) \
822 int32_t ERR_VAR_NAME(DataTemp1, __LINE__) = DATA1; \
823 ERR_VAR_NAME(pDataTemp1, __LINE__) = &ERR_VAR_NAME(DataTemp1, __LINE__); \
827 ERR_VAR_NAME(pDataTemp1, __LINE__) = (int32_t*)&(DATA1); \
829 int32_t* ERR_VAR_NAME(pDataTemp2, __LINE__); \
830 if(sizeof(DATA2) < 4) \
832 int32_t ERR_VAR_NAME(DataTemp2, __LINE__) = DATA2; \
833 ERR_VAR_NAME(pDataTemp2, __LINE__) = &ERR_VAR_NAME(DataTemp2, __LINE__); \
837 ERR_VAR_NAME(pDataTemp2, __LINE__) = (int32_t*)&(DATA2); \
839 int32_t* ERR_VAR_NAME(pDataTemp3, __LINE__); \
840 if(sizeof(DATA3) < 4) \
842 int32_t ERR_VAR_NAME(DataTemp3, __LINE__) = DATA3; \
843 ERR_VAR_NAME(pDataTemp3, __LINE__) = &ERR_VAR_NAME(DataTemp3, __LINE__); \
847 ERR_VAR_NAME(pDataTemp3, __LINE__) = (int32_t*)&(DATA3); \
849 int32_t* ERR_VAR_NAME(pDataTemp4, __LINE__); \
850 if(sizeof(DATA4) < 4) \
852 int32_t ERR_VAR_NAME(DataTemp4, __LINE__) = DATA4; \
853 ERR_VAR_NAME(pDataTemp4, __LINE__) = &ERR_VAR_NAME(DataTemp4, __LINE__); \
857 ERR_VAR_NAME(pDataTemp4, __LINE__) = (int32_t*)&(DATA4); \
859 _SetErrorX(&g_t##ID, &ERR_VAR_NAME(g_t##ID##Source, __LINE__), *ERR_VAR_NAME(pDataTemp1, __LINE__), \
860 *ERR_VAR_NAME(pDataTemp2, __LINE__), \
861 *ERR_VAR_NAME(pDataTemp3, __LINE__), \
862 *ERR_VAR_NAME(pDataTemp4, __LINE__)); \
872#define DefineOnErrorReaction(ERROR_REACTION, NAME, HELP) \
873ASSERT_REACTION_NAME(NAME); \
875static const char ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__)[] __attribute__((section("error_strings"), used)) = NAME; \
876static const char ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__)[] __attribute__((section("error_strings"), used)) = HELP; \
877const tOnErrorReaction g_t##ERROR_REACTION __attribute__((section("error_reactions"), used)) = { \
879 ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__), \
880 sizeof(ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__)) - 1, \
881 ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__), \
882 sizeof(ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__)) - 1 \
890#define DeclareOnErrorReaction(ERROR_REACTION) \
891 const tOnErrorReaction g_t##ERROR_REACTION; \
892 void ERROR_REACTION(void)
901#define DefineOnErrorResetReaction(ERROR_REACTION, NAME, HELP) \
902ASSERT_REACTION_NAME(NAME); \
904static const char ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__)[] __attribute__((section("error_strings"), used)) = NAME; \
905static const char ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__)[] __attribute__((section("error_strings"), used)) = HELP; \
906const tOnErrorResetReaction g_t##ERROR_REACTION __attribute__((section("error_reactions"), used)) = { \
908 ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__), \
909 sizeof(ERR_VAR_NAME(g_s##ERROR_REACTION##Name, __LINE__)) - 1, \
910 ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__), \
911 sizeof(ERR_VAR_NAME(g_s##ERROR_REACTION##Help, __LINE__)) - 1 \
919#define DeclareOnErrorResetReaction(ERROR_REACTION) \
920 const tOnErrorResetReaction g_t##ERROR_REACTION; \
921 bool ERROR_REACTION(void)
932static const char g_sFileName[] __attribute__((section(
"error_strings"), used)) = __BASE_FILE__;
949void MaxFloat(
void* DataOld,
float DataNew);
950void MinFloat(
void* DataOld,
float DataNew);
952void MaxInt(
void* DataOld, int32_t DataNew);
953void MinInt(
void* DataOld, int32_t DataNew);
954void MaxUInt(
void* DataOld, uint32_t DataNew);
955void MinUInt(
void* DataOld, uint32_t DataNew);
uint32_t PendingErrosSortedByTime(tErrorListItem *pptPendingErrorList[])
Get an array of the pending Errors sorted by tTimestampFirst.
Definition: Error.c:865
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:932
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
bool IsErrorIdPending(uint16_t ui16ErrorId)
Check if a Error-ID is pending.
Definition: Error.c:790
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:838
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:67
ERROR_FLAGS
Flags used for errors.
Definition: Error.h:56
@ VIEWER_RESET
Can be reset by user with Viewer access level.
Definition: Error.h:57
@ PLC_RESET
Can be reset by the PLC.
Definition: Error.h:61
@ CODE_RESET
Can be reset by the program it-selve e.g. after Init.
Definition: Error.h:62
@ DEVELOPER_RESET
Can be reset by user with Developer access level.
Definition: Error.h:60
@ PROFESSIONAL_RESET
Can be reset by user with Professional access level.
Definition: Error.h:59
@ USER_RESET
Can be reset by user with User access level.
Definition: Error.h:58
@ NV_STORED
Stored in Non-Volatile RAM.
Definition: Error.h:63
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
bool IsErrorIdRangePending(uint16_t ui16ErrorIdStart, uint16_t ui16ErrorIdEnd)
Check if a Error in the range is pending.
Definition: Error.c:815
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:937
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:36
#define DeclareOnErrorReaction(ERROR_REACTION)
Use to declare an ErrorReaction as external.
Definition: Error.h:890
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:83
#define DeclareOnErrorResetReaction(ERROR_REACTION)
Use to declare an ErrorResetReaction as external.
Definition: Error.h:919
uint16_t void int32_t uint32_t ParameterAccessSource uint8_t ui8AccessLevel
Definition: PARA_Timestamp.c:63
Definition of a timestamp type.
Definition: timestamp.h:33
Main error structure.
Definition: Error.h:99
const uint16_t ui16Id
Error-ID.
Definition: Error.h:100
const uint16_t ui16DataCount
Number of attached variables (not byte). See Details on Page Data appended to errors.
Definition: Error.h:101
const uint32_t ui32Flags
Flags from enum ERROR_FLAGS e.g. error reset permissions.
Definition: Error.h:102
const uint32_t ui32HelpLength
Strlen of Help.
Definition: Error.h:106
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:105
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:107
const tOnErrorResetReaction * OnErrorReset
Function to be called on reseting the error. See Page Actions on Error set and reset for details.
Definition: Error.h:108
const uint32_t ui32DescriptionLength
Strlen of Description.
Definition: Error.h:104
const char * Description
Short Description of the error.
Definition: Error.h:103
Structure used in the error stack.
Definition: Error.h:122
Type_Timestamp tTimestampFirst
Time when the error was set the first time.
Definition: Error.h:125
Type_Timestamp tTimestampLast
Time when the error was set the last time.
Definition: Error.h:126
void * Data
Pointer to the attached data the number is stored on ptError. The length is defined in Error-Definiti...
Definition: Error.h:128
const tErrorSource * ptErrorSource
Location of the error in source code.
Definition: Error.h:124
const tError * ptError
Pointer to the error itself.
Definition: Error.h:123
uint32_t ui32ErrorCount
Number of occurrences. Starts with 1 and increments on every occurence.
Definition: Error.h:127
Structure used in tError holding source-code file an line.
Definition: Error.h:113
const uint32_t ui32Line
Source-code line.
Definition: Error.h:114
const char * File
Source-code filename and path.
Definition: Error.h:115
const uint32_t ui32FileLength
Strlen of filename.
Definition: Error.h:116
The error reaction is called on occurence of the error.
Definition: Error.h:73
const uint32_t ui32HelpSize
StrLen of Help.
Definition: Error.h:78
const fpOnErrorX fpErrorReaction
Function to be called.
Definition: Error.h:74
const char * cHelp
Help Text. See Page Help-texts in Errors for details.
Definition: Error.h:77
const char * cName
Name of the Function.
Definition: Error.h:75
const uint32_t ui32NameSize
StrLen of Name.
Definition: Error.h:76
The error reset reaction is called on reset of the error.
Definition: Error.h:89
const fpOnErrorResetX fpErrorReaction
Function to be called.
Definition: Error.h:90
const uint32_t ui32HelpSize
StrLen of Help.
Definition: Error.h:94
const char * cHelp
Help Text. See Page Help-texts in Errors for details.
Definition: Error.h:93
const char * cName
Name of the Function.
Definition: Error.h:91
const uint32_t ui32NameSize
StrLen of Name.
Definition: Error.h:92
Definition of timestamp data-structs.