-
Notifications
You must be signed in to change notification settings - Fork 0
Add prototype Event Management calls and Event Proxy impl 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 19 commits
a03bc50
bf38ef7
879f086
7531529
f1f9aea
9dbb7c5
7e4f1c6
722c064
1637329
25f8a55
e131d61
4ef6160
6b836c4
8030756
26f2acb
29701c3
3828a50
3017405
f5173ee
278c7d8
d6b3f0a
2483add
ffcd02f
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,147 @@ | ||
| /* | ||
| * TODO: Fill in file header, if necessary. | ||
| */ | ||
|
|
||
| /************************************************ | ||
| * Includes | ||
| ************************************************/ | ||
|
|
||
| #include <assert.h> | ||
| #include "cfe.h" | ||
| #include "bp_eventids.h" | ||
| #include "bpl_evm_api.h" | ||
| #include "bpnode_evp_cfs.h" | ||
|
|
||
| /************************************************ | ||
| * Local Data | ||
| ************************************************/ | ||
|
|
||
| /* | ||
| ** Limits: | ||
| ** - Must contain less than or equal to CFE_PLATFORM_EVS_MAX_EVENT_FILTERS entries | ||
| */ | ||
| static const CFE_EVS_BinFilter_t BPNODE_EVP_CFS_EVENT_FILTER[] = { | ||
| {BP_IO_SEND_ERR_EID, CFE_EVS_FIRST_8_STOP}, | ||
| {BP_IO_RECEIVE_ERR_EID, CFE_EVS_FIRST_8_STOP}, | ||
| {BP_LIB_PROC_ERR_EID, CFE_EVS_FIRST_8_STOP}, | ||
| {BP_LIB_LOAD_ERR_EID, CFE_EVS_FIRST_8_STOP}, | ||
| {BP_LIB_STORE_ERR_EID, CFE_EVS_FIRST_8_STOP}, | ||
| {BP_LIB_ACCEPT_ERR_EID, CFE_EVS_FIRST_8_STOP}, | ||
| {BP_FILE_ERR_EID, CFE_EVS_FIRST_8_STOP}, | ||
| }; | ||
|
|
||
| const size_t BPNODE_EVP_CFS_NUM_EVENT_FILTERS = sizeof(BPNODE_EVP_CFS_EVENT_FILTER) / | ||
| sizeof(BPNODE_EVP_CFS_EVENT_FILTER[0]); | ||
|
|
||
| /************************************************ | ||
| * Exported Functions | ||
| ************************************************/ | ||
|
|
||
| /*----------------------------------------------- | ||
| * BPNODE_EVP_Initialize_Impl | ||
| *-----------------------------------------------*/ | ||
| BPL_Status_t BPNODE_EVP_Initialize_Impl(void) | ||
| { | ||
| BPL_Status_t ReturnStatus = { .ReturnValue = BPL_STATUS_SUCCESS }; | ||
| CFE_Status_t CfeEvsRegisterStatus; | ||
|
|
||
| CfeEvsRegisterStatus = CFE_EVS_Register(BPNODE_EVP_CFS_EVENT_FILTER, | ||
| BPNODE_EVP_CFS_NUM_EVENT_FILTERS, | ||
| CFE_EVS_EventFilter_BINARY); | ||
|
|
||
| if (CfeEvsRegisterStatus != CFE_SUCCESS) | ||
| { | ||
| OS_printf("BPNODE_EVP_Initialize_Impl call to CFE_EVS_Register returned error: %u!\n", | ||
| CfeEvsRegisterStatus); | ||
| ReturnStatus.ReturnValue = BPL_STATUS_ERROR_PROXY_INIT; | ||
| } | ||
| else | ||
| { | ||
| ReturnStatus.ReturnValue = BPL_STATUS_SUCCESS; | ||
| } | ||
|
|
||
| return ReturnStatus; | ||
| } | ||
|
|
||
| /*----------------------------------------------- | ||
| * BPNODE_EVP_TranslateTypeToHost | ||
| *-----------------------------------------------*/ | ||
| uint16_t BPNODE_EVP_TranslateTypeToHost(BPL_EVM_EventType_t EventType) | ||
| { | ||
| uint16_t HostEventType; | ||
| switch (EventType) | ||
| { | ||
| case BPL_EVM_EventType_DEBUG: | ||
| HostEventType = CFE_EVS_EventType_DEBUG; | ||
| break; | ||
| case BPL_EVM_EventType_INFO: | ||
| HostEventType = CFE_EVS_EventType_INFORMATION; | ||
| break; | ||
| case BPL_EVM_EventType_WARNING: | ||
| HostEventType = CFE_EVS_EventType_ERROR; | ||
| break; | ||
| case BPL_EVM_EventType_ERROR: | ||
| HostEventType = CFE_EVS_EventType_ERROR; | ||
| break; | ||
| case BPL_EVM_EventType_CRITICAL: | ||
| HostEventType = CFE_EVS_EventType_CRITICAL; | ||
| break; | ||
| default: | ||
| /* This default case also captures the BPL_EVM_EventType_UNKNOWN case. */ | ||
| HostEventType = CFE_EVS_EventType_ERROR; | ||
| break; | ||
| } | ||
| return HostEventType; | ||
| } | ||
|
|
||
| /*----------------------------------------------- | ||
| * BPNODE_EVP_SendEvent_Impl | ||
| *-----------------------------------------------*/ | ||
| BPL_Status_t BPNODE_EVP_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t EventType, | ||
| char const * EventText, va_list EventTextArgPtr) | ||
| { | ||
| BPL_Status_t ReturnStatus; | ||
| CFE_Status_t ProxyStatus; | ||
| uint16_t HostEventType = BPNODE_EVP_TranslateTypeToHost(EventType); | ||
| char ExpandedEventText[BPNODE_EVP_MAX_MESSAGE_LENGTH]; | ||
| int ExpandedLength; | ||
|
|
||
| /* | ||
| ** Due to how we truncate the message if its too long (as seen in code, below), | ||
| ** we need to ensure that this buffer is at least 2 characters long. | ||
| */ | ||
| assert(BPNODE_EVP_MAX_MESSAGE_LENGTH >= 2); | ||
| assert(BPNODE_EVP_MAX_MESSAGE_LENGTH <= CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); | ||
|
|
||
| memset(&ExpandedEventText, 0, sizeof(ExpandedEventText)); | ||
| ExpandedLength = vsnprintf((char *)ExpandedEventText, sizeof(ExpandedEventText), | ||
| EventText, EventTextArgPtr); | ||
| if (ExpandedLength >= (int)sizeof(ExpandedEventText)) | ||
| { | ||
| /* Mark character before zero terminator to indicate truncation */ | ||
| ExpandedEventText[sizeof(ExpandedEventText) - 2u] = BPNODE_EVP_MSG_TRUNCATED; | ||
| /* | ||
| ** TODO: should we return an error here? | ||
| ** Note: In the cFE implementation, they don't treat message truncation as an error. | ||
| */ | ||
| } | ||
|
|
||
| /* TODO: We'll probably want to remove this, or wrap it behind an "if debug" compiler flag. */ | ||
| OS_printf("BPNODE_EVP_SendEvent_Impl(%u, %s, %s)\n", | ||
| EventID, BPL_EVM_EventTypeToString(EventType), ExpandedEventText); | ||
|
Comment on lines
+129
to
+131
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. Should I simply remove this, or are there debug print flags in BP that we should use? |
||
|
|
||
| ProxyStatus = CFE_EVS_SendEvent(EventID, HostEventType, "%s", ExpandedEventText); | ||
|
|
||
| if (ProxyStatus != CFE_SUCCESS) | ||
| { | ||
| OS_printf("BPNODE_EVP_SendEvent_Impl CFE_EVS_SendEvent returned error status: 0x%08X!\n", | ||
| ProxyStatus); | ||
|
Comment on lines
+137
to
+138
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. Here and other places, I've put |
||
| ReturnStatus.ReturnValue = BPL_STATUS_ERROR_GENERAL; | ||
| } | ||
| else | ||
| { | ||
| ReturnStatus.ReturnValue = BPL_STATUS_SUCCESS; | ||
| } | ||
|
|
||
| return ReturnStatus; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * TODO: Fill in file header, if necessary. | ||
| */ | ||
|
|
||
| #ifndef BPNODE_EVP_CFS_H | ||
| #define BPNODE_EVP_CFS_H | ||
|
|
||
| /************************************************ | ||
| * Includes | ||
| ************************************************/ | ||
|
|
||
| #include "cfe.h" | ||
| #include "bpl_evm_api.h" | ||
|
|
||
| /************************************************ | ||
| * Typedefs | ||
| ************************************************/ | ||
|
|
||
| /* | ||
| ** Defines the character used when truncating event strings that are too long | ||
| ** Match what cFE uses (CFE_EVS_MSG_TRUNCATED) | ||
| */ | ||
| #define BPNODE_EVP_MSG_TRUNCATED ('$') | ||
|
|
||
| /* | ||
| ** Defines the max length of the expanded event string | ||
| ** | ||
| ** Limits: | ||
| ** - must be greater than or equal to 2 | ||
| ** - must be less than or equal to host limit (CFE_MISSION_EVS_MAX_MESSAGE_LENGTH) | ||
| */ | ||
| #define BPNODE_EVP_MAX_MESSAGE_LENGTH (CFE_MISSION_EVS_MAX_MESSAGE_LENGTH) | ||
|
|
||
| /************************************************ | ||
| * Exported Functions | ||
| ************************************************/ | ||
|
|
||
| BPL_Status_t BPNODE_EVP_Initialize_Impl(void); | ||
| BPL_Status_t BPNODE_EVP_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t EventType, | ||
| char const * EventText, va_list EventTextArgPtr); | ||
|
|
||
| #endif /* BPNODE_EVP_CFS_H */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,8 @@ | |
| #include "bp_dispatch.h" | ||
| #include "bp_cla_bundle_io.h" | ||
| #include "bplib_routing.h" | ||
| #include "bpl_evm_api.h" | ||
| #include "bpnode_evp_cfs.h" | ||
|
|
||
| /************************************************ | ||
| * File Data | ||
|
|
@@ -65,6 +67,20 @@ static CFE_Status_t BP_SetupLibrary(void) | |
| return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; | ||
| } | ||
|
|
||
| /* TODO: Is this the right spot? */ | ||
| BPL_EVM_ProxyCallbacks_t EventProxyCallbacks = { | ||
| .Initialize_Impl = BPNODE_EVP_Initialize_Impl, | ||
| .SendEvent_Impl = BPNODE_EVP_SendEvent_Impl, | ||
| }; | ||
|
|
||
| BPL_Status_t BPL_EVM_Status; | ||
| BPL_EVM_Status = BPL_EVM_Initialize(EventProxyCallbacks); | ||
| if (BPL_EVM_Status.ReturnValue != BPL_STATUS_SUCCESS) | ||
| { | ||
| fprintf(stderr, "%s(): BPL_EVM_Initialize failed\n", __func__); | ||
| return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; | ||
| } | ||
|
|
||
| return CFE_SUCCESS; | ||
| } | ||
|
|
||
|
|
@@ -73,28 +89,12 @@ static CFE_Status_t BP_SetupLibrary(void) | |
| *-----------------------------------------------*/ | ||
| static CFE_Status_t AppInit(void) | ||
| { | ||
| static const CFE_EVS_BinFilter_t BP_EVENT_FILTER_INIT[] = { | ||
| {BP_IO_SEND_ERR_EID, CFE_EVS_FIRST_8_STOP}, {BP_IO_RECEIVE_ERR_EID, CFE_EVS_FIRST_8_STOP}, | ||
| {BP_LIB_PROC_ERR_EID, CFE_EVS_FIRST_8_STOP}, {BP_LIB_LOAD_ERR_EID, CFE_EVS_FIRST_8_STOP}, | ||
| {BP_LIB_STORE_ERR_EID, CFE_EVS_FIRST_8_STOP}, {BP_LIB_ACCEPT_ERR_EID, CFE_EVS_FIRST_8_STOP}, | ||
| {BP_FILE_ERR_EID, CFE_EVS_FIRST_8_STOP}, {BP_STORE_INFO_EID, CFE_EVS_FIRST_8_STOP}, | ||
| {BP_BPLIB_INFO_EID, CFE_EVS_FIRST_8_STOP}}; | ||
|
|
||
| const size_t num_event_filters = sizeof(BP_EVENT_FILTER_INIT) / sizeof(BP_EVENT_FILTER_INIT[0]); | ||
| CFE_Status_t status = CFE_SUCCESS; | ||
| CFE_ES_AppId_t app_id; | ||
|
|
||
| assert(num_event_filters <= BP_MAX_EVENT_FILTERS); | ||
| memset(&BP_GlobalData, 0, sizeof(BP_GlobalData)); | ||
| BP_GlobalData.Throttles = BP_Throttles; | ||
|
|
||
| memcpy(BP_GlobalData.EventFilters, BP_EVENT_FILTER_INIT, sizeof(BP_EVENT_FILTER_INIT)); | ||
|
|
||
| /* Register Application with Event Services */ | ||
| status = CFE_EVS_Register(BP_GlobalData.EventFilters, num_event_filters, CFE_EVS_EventFilter_BINARY); | ||
| if (status != CFE_SUCCESS) | ||
| return status; | ||
|
|
||
| /* Get Application ID */ | ||
| status = CFE_ES_GetAppID(&app_id); | ||
| if (status != CFE_SUCCESS) | ||
|
|
@@ -165,7 +165,7 @@ static CFE_Status_t AppInit(void) | |
| BP_DoRebuildFlowBitmask(); | ||
|
|
||
| /* Application startup event message */ | ||
| CFE_EVS_SendEvent(BP_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "BP App Version %d.%d.%d.%d: Initialized", | ||
| (void) BPL_EVM_SendEvent(BP_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "BP App Version %d.%d.%d.%d: Initialized", | ||
| BP_MAJOR_VERSION, BP_MINOR_VERSION, BP_REVISION, BP_MISSION_REV); | ||
|
Comment on lines
166
to
168
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. The previous call to However, if we wanted to check the return status, it would look something like this: /* Application startup event message */
BPL_Status_t BPL_EVM_SendEventStatus;
(void) BPL_EVM_SendEvent(BP_INIT_INF_EID, CFE_EVS_EventType_INFORMATION,
"BP App Version %d.%d.%d.%d: Initialized",
BP_MAJOR_VERSION, BP_MINOR_VERSION, BP_REVISION, BP_MISSION_REV);
if (BPL_EVM_SendEventStatus.ReturnValue != BPL_STATUS_SUCCESS)
{
fprintf(stderr, "%s(): First BPL_EVM_SendEvent call failed\n", __func__);
return BPL_EVM_SendEventStatus.ReturnValue;
}I find this to be a little too distracting for such a benign activity, but I'm happy to go with the group's decision on whether to continue ignoring the status return from Send Event calls. |
||
|
|
||
| return CFE_SUCCESS; | ||
|
|
@@ -213,6 +213,7 @@ void BP_AppMain(void) | |
| } | ||
|
|
||
| /* Exit Application */ | ||
| BPL_EVM_Deinitialize(); | ||
| CFE_EVS_SendEvent(BP_EXIT_ERR_EID, CFE_EVS_EventType_ERROR, "BP application terminating: result = 0x%08X", | ||
| (unsigned int)run_status); | ||
| CFE_ES_WriteToSysLog("BP application terminating: result = 0x%08X\n", | ||
|
|
||
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.
This error handling response should be reviewed by the group.