-
Notifications
You must be signed in to change notification settings - Fork 0
Add initial prototype Event Management files #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 10 commits
932cab1
6caa14d
f92608b
aaa793e
358f127
e1a9532
bc1c419
c8db3a9
e47a46b
6406c2c
7ab5697
3bd6233
af121e2
bd88db4
90d94a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * TODO: Fill in file header, if necessary. | ||
| */ | ||
|
|
||
| #ifndef BPL_EVM_H | ||
| #define BPL_EVM_H | ||
|
|
||
| /****************************************************************************** | ||
| INCLUDES | ||
| ******************************************************************************/ | ||
|
|
||
| #include "bplib_api_types.h" | ||
|
|
||
| /************************************************ | ||
| * Typedefs | ||
| ************************************************/ | ||
|
|
||
| typedef enum | ||
| { | ||
| BPL_EVM_EventType_UNKNOWN = 0, | ||
| BPL_EVM_EventType_DEBUG = 1, | ||
| BPL_EVM_EventType_INFO = 2, | ||
| BPL_EVM_EventType_WARNING = 3, | ||
| BPL_EVM_EventType_ERROR = 4, | ||
| BPL_EVM_EventType_CRITICAL = 5 | ||
| } BPL_EVM_EventType_t; | ||
|
|
||
| typedef struct | ||
| { | ||
| uint32_t ReturnValue; | ||
| } BPL_Status_t; | ||
|
|
||
| #define BPL_STATUS_SUCCESS (0u) | ||
| #define BPL_STATUS_ERROR_GENERAL (1u) | ||
| #define BPL_STATUS_ERROR_INPUT_INVALID (2u) | ||
| #define BPL_STATUS_ERROR_PROXY_INIT (3u) | ||
|
Comment on lines
+28
to
+36
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume these should be moved to somewhere else (if we decide to keep the struct impl of the return types, as discussed). |
||
|
|
||
| typedef struct | ||
| { | ||
| BPL_Status_t (*Initialize_Impl)(void); | ||
| BPL_Status_t (*SendEvent_Impl)(uint16_t EventID, BPL_EVM_EventType_t EventType, | ||
| char const * EventText, va_list EventTextArgPtr); | ||
| } BPL_EVM_ProxyCallbacks_t; | ||
|
|
||
| /************************************************ | ||
| * Exported Functions | ||
| ************************************************/ | ||
|
|
||
| BPL_Status_t BPL_EVM_Initialize(BPL_EVM_ProxyCallbacks_t ProxyCallbacks); | ||
| char const * BPL_EVM_EventTypeToString(BPL_EVM_EventType_t Type); | ||
| BPL_Status_t BPL_EVM_SendEvent(uint16_t EventID, BPL_EVM_EventType_t EventType, | ||
| char const * EventText, ...); | ||
| void BPL_EVM_Deinitialize(void); | ||
|
|
||
| #endif /* BPL_EVM_H */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| /* | ||
| * TODO: Fill in file header, if necessary. | ||
| */ | ||
|
|
||
| /****************************************************************************** | ||
| INCLUDES | ||
| ******************************************************************************/ | ||
|
|
||
| #include <stdarg.h> | ||
| #include "cfe.h" | ||
| #include "bpl_evm_api.h" | ||
|
|
||
| /****************************************************************************** | ||
| TYPEDEFS | ||
| ******************************************************************************/ | ||
|
|
||
|
|
||
| /****************************************************************************** | ||
| LOCAL DATA | ||
| ******************************************************************************/ | ||
|
|
||
| BPL_EVM_ProxyCallbacks_t BPL_EVM_ProxyCallbacks; | ||
|
|
||
| /****************************************************************************** | ||
| LOCAL FUNCTIONS | ||
| ******************************************************************************/ | ||
|
|
||
| BPL_Status_t BPL_EVM_Initialize(BPL_EVM_ProxyCallbacks_t ProxyCallbacks) | ||
| { | ||
| BPL_Status_t ReturnStatus; | ||
| BPL_Status_t ProxyInitImplReturnStatus; | ||
|
|
||
| if ((ProxyCallbacks.Initialize_Impl == NULL) || (ProxyCallbacks.SendEvent_Impl == NULL)) | ||
| { | ||
| ReturnStatus.ReturnValue = BPL_STATUS_ERROR_INPUT_INVALID; | ||
| OS_printf("BPL_EVM_Initialize got an invalid argument!\n"); | ||
| } | ||
| else | ||
| { | ||
| /* impl callbacks determined to be valid */ | ||
| BPL_EVM_ProxyCallbacks.Initialize_Impl = ProxyCallbacks.Initialize_Impl; | ||
| BPL_EVM_ProxyCallbacks.SendEvent_Impl = ProxyCallbacks.SendEvent_Impl; | ||
|
|
||
| /* TODO: immediately want to call the proxy init, or wait for a directive to do so? */ | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to address this TODO
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider removing the |
||
| ProxyInitImplReturnStatus = BPL_EVM_ProxyCallbacks.Initialize_Impl(); | ||
| if (ProxyInitImplReturnStatus.ReturnValue != BPL_STATUS_SUCCESS) | ||
| { | ||
| ReturnStatus.ReturnValue = BPL_STATUS_ERROR_PROXY_INIT; | ||
| OS_printf("BPL_EVM_Initialize hit error (%u) when calling proxy init!\n", | ||
| ProxyInitImplReturnStatus.ReturnValue); | ||
| } | ||
| else | ||
| { | ||
| ReturnStatus.ReturnValue = BPL_STATUS_SUCCESS; | ||
| } | ||
| } | ||
|
|
||
| return ReturnStatus; | ||
| } | ||
|
|
||
| char const * BPL_EVM_EventTypeToString(BPL_EVM_EventType_t Type) | ||
| { | ||
| /* BPL_EVM_EventTypeStrings should always match BPL_EVM_EventType_t. */ | ||
| static char const * BPL_EVM_EventTypeStrings[] = { | ||
| "UNKNOWN", | ||
| "DEBUG", | ||
| "INFO", | ||
| "WARNING", | ||
| "ERROR", | ||
| "CRITICAL" | ||
| }; | ||
|
|
||
| switch (Type) | ||
| { | ||
| case BPL_EVM_EventType_DEBUG: | ||
| return BPL_EVM_EventTypeStrings[1]; | ||
| case BPL_EVM_EventType_INFO: | ||
| return BPL_EVM_EventTypeStrings[2]; | ||
| case BPL_EVM_EventType_WARNING: | ||
| return BPL_EVM_EventTypeStrings[3]; | ||
| case BPL_EVM_EventType_ERROR: | ||
| return BPL_EVM_EventTypeStrings[4]; | ||
| case BPL_EVM_EventType_CRITICAL: | ||
| return BPL_EVM_EventTypeStrings[5]; | ||
| default: | ||
| /* This default case also captures the BPL_EVM_EventType_UNKNOWN case. */ | ||
| return BPL_EVM_EventTypeStrings[0]; | ||
| } | ||
| } | ||
|
|
||
| BPL_Status_t BPL_EVM_SendEvent(uint16_t EventID, BPL_EVM_EventType_t EventType, | ||
| char const * EventText, ...) | ||
| { | ||
| BPL_Status_t ReturnStatus; | ||
| BPL_Status_t ProxyReturnStatus; | ||
| va_list EventTextArgsPtr; | ||
|
|
||
| char const * EventTypeString = BPL_EVM_EventTypeToString(EventType); | ||
| OS_printf("BPL_EVM_SendEvent called! Event Info (%s, %u).\n", | ||
| EventTypeString, | ||
| EventID); | ||
|
|
||
| if (BPL_EVM_ProxyCallbacks.SendEvent_Impl == NULL) | ||
| { | ||
| ReturnStatus.ReturnValue = BPL_STATUS_ERROR_PROXY_INIT; | ||
| } | ||
| else if (EventText == NULL) | ||
| { | ||
| ReturnStatus.ReturnValue = BPL_STATUS_ERROR_INPUT_INVALID; | ||
| } | ||
| else | ||
| { | ||
| va_start(EventTextArgsPtr, EventText); | ||
| ProxyReturnStatus = BPL_EVM_ProxyCallbacks.SendEvent_Impl(EventID, EventType, EventText, EventTextArgsPtr); | ||
| va_end(EventTextArgsPtr); | ||
|
|
||
| if (ProxyReturnStatus.ReturnValue != BPL_STATUS_SUCCESS) | ||
| { | ||
| ReturnStatus.ReturnValue = BPL_STATUS_ERROR_GENERAL; | ||
| OS_printf("BPL_EVM_SendEvent hit error (%u) when calling proxy impl!\n", | ||
| ProxyReturnStatus.ReturnValue); | ||
| } | ||
| else | ||
| { | ||
| ReturnStatus.ReturnValue = BPL_STATUS_SUCCESS; | ||
| } | ||
| } | ||
|
|
||
| return ReturnStatus; | ||
| } | ||
|
|
||
| void BPL_EVM_Deinitialize(void) | ||
| { | ||
| /* Clear proxy function pointers */ | ||
| BPL_EVM_ProxyCallbacks.Initialize_Impl = NULL; | ||
| BPL_EVM_ProxyCallbacks.SendEvent_Impl = NULL; | ||
|
|
||
| return; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does there need to be a file header for these files?