From a03bc501d8ec58ccace7b57b19c645c46578bf0d Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 16:57:41 +0000 Subject: [PATCH 01/23] WIP: Add prototype Event Management calls and Event Proxy impl files warning: fails to compile with the lib --- CMakeLists.txt | 1 + fsw/custom/bpnode_evt_cfs.c | 34 ++++++++++++++++++++++++++++++++++ fsw/custom/bpnode_evt_cfs.h | 30 ++++++++++++++++++++++++++++++ fsw/src/bp_app.c | 12 +++++++++++- 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 fsw/custom/bpnode_evt_cfs.c create mode 100644 fsw/custom/bpnode_evt_cfs.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b8459230..b71db671 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ set(APP_SRC_FILES fsw/custom/bp_semcfg.c fsw/custom/bp_storecfg.c fsw/custom/bp_tlmcfg.c + fsw/custom/bpnode_evt_cfs.c ) if (CFE_EDS_ENABLED_BUILD) diff --git a/fsw/custom/bpnode_evt_cfs.c b/fsw/custom/bpnode_evt_cfs.c new file mode 100644 index 00000000..6a0fb50f --- /dev/null +++ b/fsw/custom/bpnode_evt_cfs.c @@ -0,0 +1,34 @@ +/* + * TODO: Fill in file header, if necessary. + */ + +/************************************************ + * Includes + ************************************************/ + +#include "cfe.h" +#include "bpnode_evt_cfs.h" + +/************************************************ + * Exported Functions + ************************************************/ + +/*----------------------------------------------- + * BPNODE_EVT_Initialize_Impl + *-----------------------------------------------*/ +BPNODE_Status_t BPNODE_EVT_Initialize_Impl(void) +{ + BPNODE_Status_t ReturnStatus = { .ReturnValue = 0 }; + OS_printf("BPNODE_EVT_Initialize_Impl called!\n"); + return ReturnStatus; +} + +/*----------------------------------------------- + * BPNODE_EVT_SendEvent_Impl + *-----------------------------------------------*/ +BPNODE_Status_t BPNODE_EVT_SendEvent_Impl(uint32_t EventID) +{ + BPNODE_Status_t ReturnStatus = { .ReturnValue = 0 }; + OS_printf("BPNODE_EVT_SendEvent_Impl called with arg 0x%08X!\n", EventID); + return ReturnStatus; +} diff --git a/fsw/custom/bpnode_evt_cfs.h b/fsw/custom/bpnode_evt_cfs.h new file mode 100644 index 00000000..dfadf797 --- /dev/null +++ b/fsw/custom/bpnode_evt_cfs.h @@ -0,0 +1,30 @@ +/* + * TODO: Fill in file header, if necessary. + */ + +#ifndef BPNODE_EVT_H +#define BPNODE_EVT_H + +/************************************************ + * Includes + ************************************************/ + +#include "cfe.h" + +/************************************************ + * Typedefs + ************************************************/ + +typedef struct +{ + uint32_t ReturnValue; +} BPNODE_Status_t; + +/************************************************ + * Exported Functions + ************************************************/ + +BPNODE_Status_t BPNODE_EVT_Initialize_Impl(void); +BPNODE_Status_t BPNODE_EVT_SendEvent_Impl(uint32_t EventID); + +#endif /* BPNODE_EVT_H */ diff --git a/fsw/src/bp_app.c b/fsw/src/bp_app.c index 1c22a2ed..60dd74b4 100644 --- a/fsw/src/bp_app.c +++ b/fsw/src/bp_app.c @@ -39,6 +39,7 @@ #include "bp_dispatch.h" #include "bp_cla_bundle_io.h" #include "bplib_routing.h" +#include "bpl_evm_api.h" /************************************************ * File Data @@ -65,6 +66,8 @@ static CFE_Status_t BP_SetupLibrary(void) return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } + (void) BPL_EVM_Initialize(); + return CFE_SUCCESS; } @@ -165,9 +168,16 @@ 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", + CFE_EVS_SendEvent(BP_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "BP App Version %d.%d.%d.%d: Initialized (KRM)", BP_MAJOR_VERSION, BP_MINOR_VERSION, BP_REVISION, BP_MISSION_REV); + BPL_EVM_EventInfo_t const EventInfo = { + .Type = BPL_EVM_EventType_INFO, + .ID = 0 + }; + + (void) BPL_EVM_SendEvent(&EventInfo, "Hello, work!\n"); + return CFE_SUCCESS; } From bf38ef7abe8b8c30dc86a1bd7a0df26df30a9e49 Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 18:41:53 +0000 Subject: [PATCH 02/23] Migrate proxy api to return BPL_Status_t to match EVM --- fsw/custom/bpnode_evt_cfs.c | 9 +++++---- fsw/custom/bpnode_evt_cfs.h | 10 +++------- fsw/src/bp_app.c | 8 +++++++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/fsw/custom/bpnode_evt_cfs.c b/fsw/custom/bpnode_evt_cfs.c index 6a0fb50f..cd3a8705 100644 --- a/fsw/custom/bpnode_evt_cfs.c +++ b/fsw/custom/bpnode_evt_cfs.c @@ -7,6 +7,7 @@ ************************************************/ #include "cfe.h" +#include "bpl_evm_api.h" #include "bpnode_evt_cfs.h" /************************************************ @@ -16,9 +17,9 @@ /*----------------------------------------------- * BPNODE_EVT_Initialize_Impl *-----------------------------------------------*/ -BPNODE_Status_t BPNODE_EVT_Initialize_Impl(void) +BPL_Status_t BPNODE_EVT_Initialize_Impl(void) { - BPNODE_Status_t ReturnStatus = { .ReturnValue = 0 }; + BPL_Status_t ReturnStatus = { .ReturnValue = BPL_STATUS_SUCCESS }; OS_printf("BPNODE_EVT_Initialize_Impl called!\n"); return ReturnStatus; } @@ -26,9 +27,9 @@ BPNODE_Status_t BPNODE_EVT_Initialize_Impl(void) /*----------------------------------------------- * BPNODE_EVT_SendEvent_Impl *-----------------------------------------------*/ -BPNODE_Status_t BPNODE_EVT_SendEvent_Impl(uint32_t EventID) +BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint32_t EventID) { - BPNODE_Status_t ReturnStatus = { .ReturnValue = 0 }; + BPL_Status_t ReturnStatus = { .ReturnValue = BPL_STATUS_SUCCESS }; OS_printf("BPNODE_EVT_SendEvent_Impl called with arg 0x%08X!\n", EventID); return ReturnStatus; } diff --git a/fsw/custom/bpnode_evt_cfs.h b/fsw/custom/bpnode_evt_cfs.h index dfadf797..470baca4 100644 --- a/fsw/custom/bpnode_evt_cfs.h +++ b/fsw/custom/bpnode_evt_cfs.h @@ -10,21 +10,17 @@ ************************************************/ #include "cfe.h" +#include "bpl_evm_api.h" /************************************************ * Typedefs ************************************************/ -typedef struct -{ - uint32_t ReturnValue; -} BPNODE_Status_t; - /************************************************ * Exported Functions ************************************************/ -BPNODE_Status_t BPNODE_EVT_Initialize_Impl(void); -BPNODE_Status_t BPNODE_EVT_SendEvent_Impl(uint32_t EventID); +BPL_Status_t BPNODE_EVT_Initialize_Impl(void); +BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint32_t EventID); #endif /* BPNODE_EVT_H */ diff --git a/fsw/src/bp_app.c b/fsw/src/bp_app.c index 60dd74b4..2080a768 100644 --- a/fsw/src/bp_app.c +++ b/fsw/src/bp_app.c @@ -40,6 +40,7 @@ #include "bp_cla_bundle_io.h" #include "bplib_routing.h" #include "bpl_evm_api.h" +#include "bpnode_evt_cfs.h" /************************************************ * File Data @@ -66,7 +67,12 @@ static CFE_Status_t BP_SetupLibrary(void) return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } - (void) BPL_EVM_Initialize(); + BPL_EVM_ProxyCallbacks_t EventProxyCallbacks = { + .Initialize_Impl = BPNODE_EVT_Initialize_Impl, + .SendEvent_Impl = BPNODE_EVT_SendEvent_Impl, + }; + + (void) BPL_EVM_Initialize(EventProxyCallbacks); return CFE_SUCCESS; } From 879f0867d862c7b00838f045a575c2ca9d5c0e65 Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 18:49:26 +0000 Subject: [PATCH 03/23] Add BPL_EVM_Initialize error check to BP_SetupLibrary --- fsw/src/bp_app.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fsw/src/bp_app.c b/fsw/src/bp_app.c index 2080a768..09cb8f6d 100644 --- a/fsw/src/bp_app.c +++ b/fsw/src/bp_app.c @@ -72,7 +72,13 @@ static CFE_Status_t BP_SetupLibrary(void) .SendEvent_Impl = BPNODE_EVT_SendEvent_Impl, }; - (void) BPL_EVM_Initialize(EventProxyCallbacks); + 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; } From 7531529283905441a27c15033cc231396f866b00 Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 19:03:27 +0000 Subject: [PATCH 04/23] Add call to CFE_EVS_SendEvent from BPNODE_EVT_SendEvent_Impl --- fsw/custom/bpnode_evt_cfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fsw/custom/bpnode_evt_cfs.c b/fsw/custom/bpnode_evt_cfs.c index cd3a8705..64ef46ec 100644 --- a/fsw/custom/bpnode_evt_cfs.c +++ b/fsw/custom/bpnode_evt_cfs.c @@ -31,5 +31,9 @@ BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint32_t EventID) { BPL_Status_t ReturnStatus = { .ReturnValue = BPL_STATUS_SUCCESS }; OS_printf("BPNODE_EVT_SendEvent_Impl called with arg 0x%08X!\n", EventID); + + CFE_EVS_SendEvent(EventID, CFE_EVS_EventType_INFORMATION, + "TODO: Replace this static string!"); + return ReturnStatus; } From f1f9aeaa34c669982c3e51e847f31afa71c4eb7a Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 19:14:09 +0000 Subject: [PATCH 05/23] Destruct BPL_EVM_EventInfo_t and update refs --- fsw/src/bp_app.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fsw/src/bp_app.c b/fsw/src/bp_app.c index 09cb8f6d..cc40a245 100644 --- a/fsw/src/bp_app.c +++ b/fsw/src/bp_app.c @@ -180,15 +180,10 @@ 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 (KRM)", + CFE_EVS_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); - BPL_EVM_EventInfo_t const EventInfo = { - .Type = BPL_EVM_EventType_INFO, - .ID = 0 - }; - - (void) BPL_EVM_SendEvent(&EventInfo, "Hello, work!\n"); + (void) BPL_EVM_SendEvent(BP_INIT_INF_EID, BPL_EVM_EventType_INFO, "Hello, work!\n"); return CFE_SUCCESS; } From 9dbb7c59d1b04f51c5dc5de52e1d8a06aa7ede75 Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 19:19:08 +0000 Subject: [PATCH 06/23] Change event id to uint16_t --- fsw/custom/bpnode_evt_cfs.c | 2 +- fsw/custom/bpnode_evt_cfs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsw/custom/bpnode_evt_cfs.c b/fsw/custom/bpnode_evt_cfs.c index 64ef46ec..2fd9d88b 100644 --- a/fsw/custom/bpnode_evt_cfs.c +++ b/fsw/custom/bpnode_evt_cfs.c @@ -27,7 +27,7 @@ BPL_Status_t BPNODE_EVT_Initialize_Impl(void) /*----------------------------------------------- * BPNODE_EVT_SendEvent_Impl *-----------------------------------------------*/ -BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint32_t EventID) +BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID) { BPL_Status_t ReturnStatus = { .ReturnValue = BPL_STATUS_SUCCESS }; OS_printf("BPNODE_EVT_SendEvent_Impl called with arg 0x%08X!\n", EventID); diff --git a/fsw/custom/bpnode_evt_cfs.h b/fsw/custom/bpnode_evt_cfs.h index 470baca4..a125e62b 100644 --- a/fsw/custom/bpnode_evt_cfs.h +++ b/fsw/custom/bpnode_evt_cfs.h @@ -21,6 +21,6 @@ ************************************************/ BPL_Status_t BPNODE_EVT_Initialize_Impl(void); -BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint32_t EventID); +BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID); #endif /* BPNODE_EVT_H */ From 7e4f1c6268dd7517d98149835eb36c8930f0be41 Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 19:47:06 +0000 Subject: [PATCH 07/23] Add EventType to proxy send event impl --- fsw/custom/bpnode_evt_cfs.c | 48 ++++++++++++++++++++++++++++++++++--- fsw/custom/bpnode_evt_cfs.h | 2 +- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/fsw/custom/bpnode_evt_cfs.c b/fsw/custom/bpnode_evt_cfs.c index 2fd9d88b..30e6de9b 100644 --- a/fsw/custom/bpnode_evt_cfs.c +++ b/fsw/custom/bpnode_evt_cfs.c @@ -24,16 +24,58 @@ BPL_Status_t BPNODE_EVT_Initialize_Impl(void) return ReturnStatus; } +uint16_t BPNODE_EVT_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_EVT_SendEvent_Impl *-----------------------------------------------*/ -BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID) +BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t EventType) { BPL_Status_t ReturnStatus = { .ReturnValue = BPL_STATUS_SUCCESS }; - OS_printf("BPNODE_EVT_SendEvent_Impl called with arg 0x%08X!\n", EventID); + CFE_Status_t ProxyStatus; + uint16_t HostEventType = BPNODE_EVT_TranslateTypeToHost(EventType); - CFE_EVS_SendEvent(EventID, CFE_EVS_EventType_INFORMATION, + ProxyStatus = CFE_EVS_SendEvent(EventID, HostEventType, "TODO: Replace this static string!"); + if (ProxyStatus != CFE_SUCCESS) + { + OS_printf("BPNODE_EVT_SendEvent_Impl CFE_EVS_SendEvent returned error status: 0x%08X!\n", + ProxyStatus); + ReturnStatus.ReturnValue = BPL_STATUS_ERROR_GENERAL; + } + else + { + OS_printf("BPNODE_EVT_SendEvent_Impl called with ID 0x%08X and Type %u!\n", + EventID, (unsigned int) EventType); + ReturnStatus.ReturnValue = BPL_STATUS_SUCCESS; + } + return ReturnStatus; } diff --git a/fsw/custom/bpnode_evt_cfs.h b/fsw/custom/bpnode_evt_cfs.h index a125e62b..4ba292d9 100644 --- a/fsw/custom/bpnode_evt_cfs.h +++ b/fsw/custom/bpnode_evt_cfs.h @@ -21,6 +21,6 @@ ************************************************/ BPL_Status_t BPNODE_EVT_Initialize_Impl(void); -BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID); +BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t EventType); #endif /* BPNODE_EVT_H */ From 722c0643439d59572d290418b92805192b548c80 Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 19:49:21 +0000 Subject: [PATCH 08/23] Add basic function header comment to BPNODE_EVT_TranslateTypeToHost --- fsw/custom/bpnode_evt_cfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fsw/custom/bpnode_evt_cfs.c b/fsw/custom/bpnode_evt_cfs.c index 30e6de9b..a7a63ef8 100644 --- a/fsw/custom/bpnode_evt_cfs.c +++ b/fsw/custom/bpnode_evt_cfs.c @@ -24,6 +24,9 @@ BPL_Status_t BPNODE_EVT_Initialize_Impl(void) return ReturnStatus; } +/*----------------------------------------------- + * BPNODE_EVT_TranslateTypeToHost + *-----------------------------------------------*/ uint16_t BPNODE_EVT_TranslateTypeToHost(BPL_EVM_EventType_t EventType) { uint16_t HostEventType; From 16373298634b2a5da4c9177e2ddcdceaa81a42e0 Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 19:51:07 +0000 Subject: [PATCH 09/23] Remove ReturnStatus default val as it gets set later --- fsw/custom/bpnode_evt_cfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsw/custom/bpnode_evt_cfs.c b/fsw/custom/bpnode_evt_cfs.c index a7a63ef8..6bc5baf3 100644 --- a/fsw/custom/bpnode_evt_cfs.c +++ b/fsw/custom/bpnode_evt_cfs.c @@ -60,7 +60,7 @@ uint16_t BPNODE_EVT_TranslateTypeToHost(BPL_EVM_EventType_t EventType) *-----------------------------------------------*/ BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t EventType) { - BPL_Status_t ReturnStatus = { .ReturnValue = BPL_STATUS_SUCCESS }; + BPL_Status_t ReturnStatus; CFE_Status_t ProxyStatus; uint16_t HostEventType = BPNODE_EVT_TranslateTypeToHost(EventType); From 25f8a55b82c7e93cb979891010b8b35d7cf1726c Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 21:17:04 +0000 Subject: [PATCH 10/23] Add BPL_EVM_Deinitialize call at app exit and add some other TODOs while I was going over code with Dylan --- fsw/custom/bpnode_evt_cfs.c | 1 + fsw/src/bp_app.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/fsw/custom/bpnode_evt_cfs.c b/fsw/custom/bpnode_evt_cfs.c index 6bc5baf3..910444b6 100644 --- a/fsw/custom/bpnode_evt_cfs.c +++ b/fsw/custom/bpnode_evt_cfs.c @@ -21,6 +21,7 @@ BPL_Status_t BPNODE_EVT_Initialize_Impl(void) { BPL_Status_t ReturnStatus = { .ReturnValue = BPL_STATUS_SUCCESS }; OS_printf("BPNODE_EVT_Initialize_Impl called!\n"); + /* TODO: call EVS Register. */ return ReturnStatus; } diff --git a/fsw/src/bp_app.c b/fsw/src/bp_app.c index cc40a245..22151db2 100644 --- a/fsw/src/bp_app.c +++ b/fsw/src/bp_app.c @@ -67,6 +67,7 @@ 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_EVT_Initialize_Impl, .SendEvent_Impl = BPNODE_EVT_SendEvent_Impl, @@ -105,6 +106,7 @@ static CFE_Status_t AppInit(void) memcpy(BP_GlobalData.EventFilters, BP_EVENT_FILTER_INIT, sizeof(BP_EVENT_FILTER_INIT)); + /* TODO: would need to remove this call. */ /* Register Application with Event Services */ status = CFE_EVS_Register(BP_GlobalData.EventFilters, num_event_filters, CFE_EVS_EventFilter_BINARY); if (status != CFE_SUCCESS) @@ -230,6 +232,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", From e131d61fb63ecb5110a7e6b68ff68c1c26150e1e Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 22:04:26 +0000 Subject: [PATCH 11/23] WIP: Add EventText and variable arg list to BPNODE_EVT_SendEvent_Impl --- fsw/custom/bpnode_evt_cfs.c | 6 +++--- fsw/custom/bpnode_evt_cfs.h | 3 ++- fsw/src/bp_app.c | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fsw/custom/bpnode_evt_cfs.c b/fsw/custom/bpnode_evt_cfs.c index 910444b6..86bea8d0 100644 --- a/fsw/custom/bpnode_evt_cfs.c +++ b/fsw/custom/bpnode_evt_cfs.c @@ -59,14 +59,14 @@ uint16_t BPNODE_EVT_TranslateTypeToHost(BPL_EVM_EventType_t EventType) /*----------------------------------------------- * BPNODE_EVT_SendEvent_Impl *-----------------------------------------------*/ -BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t EventType) +BPL_Status_t BPNODE_EVT_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_EVT_TranslateTypeToHost(EventType); - ProxyStatus = CFE_EVS_SendEvent(EventID, HostEventType, - "TODO: Replace this static string!"); + ProxyStatus = CFE_EVS_SendEvent(EventID, HostEventType, EventText, EventTextArgPtr); if (ProxyStatus != CFE_SUCCESS) { diff --git a/fsw/custom/bpnode_evt_cfs.h b/fsw/custom/bpnode_evt_cfs.h index 4ba292d9..5111d36c 100644 --- a/fsw/custom/bpnode_evt_cfs.h +++ b/fsw/custom/bpnode_evt_cfs.h @@ -21,6 +21,7 @@ ************************************************/ BPL_Status_t BPNODE_EVT_Initialize_Impl(void); -BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t EventType); +BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t EventType, + char const * EventText, va_list EventTextArgPtr); #endif /* BPNODE_EVT_H */ diff --git a/fsw/src/bp_app.c b/fsw/src/bp_app.c index 22151db2..d49c2773 100644 --- a/fsw/src/bp_app.c +++ b/fsw/src/bp_app.c @@ -185,7 +185,9 @@ static CFE_Status_t AppInit(void) CFE_EVS_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); - (void) BPL_EVM_SendEvent(BP_INIT_INF_EID, BPL_EVM_EventType_INFO, "Hello, work!\n"); + (void) BPL_EVM_SendEvent(BP_INIT_INF_EID, BPL_EVM_EventType_INFO, + "Hello, work! Version %u.%u.%u.%u starting.", + 4, 3, 2, 1); return CFE_SUCCESS; } From 4ef61608427843fd01c074c6bc433ee4f2d4d37d Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 22:41:45 +0000 Subject: [PATCH 12/23] Fix event text arg expansion in BPNODE_EVT_SendEvent_Impl --- fsw/custom/bpnode_evt_cfs.c | 24 +++++++++++++++++++++++- fsw/custom/bpnode_evt_cfs.h | 15 +++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/fsw/custom/bpnode_evt_cfs.c b/fsw/custom/bpnode_evt_cfs.c index 86bea8d0..ca5f0485 100644 --- a/fsw/custom/bpnode_evt_cfs.c +++ b/fsw/custom/bpnode_evt_cfs.c @@ -6,6 +6,7 @@ * Includes ************************************************/ +#include #include "cfe.h" #include "bpl_evm_api.h" #include "bpnode_evt_cfs.h" @@ -65,8 +66,29 @@ BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t Eve BPL_Status_t ReturnStatus; CFE_Status_t ProxyStatus; uint16_t HostEventType = BPNODE_EVT_TranslateTypeToHost(EventType); + char ExpandedEventText[BPNODE_EVT_MAX_MESSAGE_LENGTH]; + int ExpandedLength; - ProxyStatus = CFE_EVS_SendEvent(EventID, HostEventType, EventText, EventTextArgPtr); + /* + ** 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_EVT_MAX_MESSAGE_LENGTH >= 2); + assert(BPNODE_EVT_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_EVT_MSG_TRUNCATED; + /* + ** TODO: should we return an error here? + ** Note: In the cFE implementation, they don't treat message truncation as an error. + */ + } + + ProxyStatus = CFE_EVS_SendEvent(EventID, HostEventType, "%s", ExpandedEventText); if (ProxyStatus != CFE_SUCCESS) { diff --git a/fsw/custom/bpnode_evt_cfs.h b/fsw/custom/bpnode_evt_cfs.h index 5111d36c..e26ab122 100644 --- a/fsw/custom/bpnode_evt_cfs.h +++ b/fsw/custom/bpnode_evt_cfs.h @@ -16,6 +16,21 @@ * Typedefs ************************************************/ +/* +** Defines the character used when truncating event strings that are too long +** Match what cFE uses (CFE_EVS_MSG_TRUNCATED) +*/ +#define BPNODE_EVT_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_EVT_MAX_MESSAGE_LENGTH (CFE_MISSION_EVS_MAX_MESSAGE_LENGTH) + /************************************************ * Exported Functions ************************************************/ From 6b836c4f93c2025e2ce8bb5dbd3e04893f61e3f6 Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 22:51:22 +0000 Subject: [PATCH 13/23] Swap BP app init event message to use BPL_EVM_SendEvent --- fsw/src/bp_app.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fsw/src/bp_app.c b/fsw/src/bp_app.c index d49c2773..00e1bbdd 100644 --- a/fsw/src/bp_app.c +++ b/fsw/src/bp_app.c @@ -182,13 +182,9 @@ 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); - (void) BPL_EVM_SendEvent(BP_INIT_INF_EID, BPL_EVM_EventType_INFO, - "Hello, work! Version %u.%u.%u.%u starting.", - 4, 3, 2, 1); - return CFE_SUCCESS; } From 80307560e6538e299f5bac578dd5a4dde4c2ee6b Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Tue, 19 Mar 2024 22:56:29 +0000 Subject: [PATCH 14/23] Clean up some of the old debug prints --- fsw/custom/bpnode_evt_cfs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fsw/custom/bpnode_evt_cfs.c b/fsw/custom/bpnode_evt_cfs.c index ca5f0485..7320ac8c 100644 --- a/fsw/custom/bpnode_evt_cfs.c +++ b/fsw/custom/bpnode_evt_cfs.c @@ -21,7 +21,7 @@ BPL_Status_t BPNODE_EVT_Initialize_Impl(void) { BPL_Status_t ReturnStatus = { .ReturnValue = BPL_STATUS_SUCCESS }; - OS_printf("BPNODE_EVT_Initialize_Impl called!\n"); + OS_printf("BPNODE_EVT_Initialize_Impl called! TODO: Call CFE_EVS_Register here!\n"); /* TODO: call EVS Register. */ return ReturnStatus; } @@ -77,7 +77,8 @@ BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t Eve assert(BPNODE_EVT_MAX_MESSAGE_LENGTH <= CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); memset(&ExpandedEventText, 0, sizeof(ExpandedEventText)); - ExpandedLength = vsnprintf((char *)ExpandedEventText, sizeof(ExpandedEventText), EventText, EventTextArgPtr); + ExpandedLength = vsnprintf((char *)ExpandedEventText, sizeof(ExpandedEventText), + EventText, EventTextArgPtr); if (ExpandedLength >= (int)sizeof(ExpandedEventText)) { /* Mark character before zero terminator to indicate truncation */ @@ -98,8 +99,6 @@ BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t Eve } else { - OS_printf("BPNODE_EVT_SendEvent_Impl called with ID 0x%08X and Type %u!\n", - EventID, (unsigned int) EventType); ReturnStatus.ReturnValue = BPL_STATUS_SUCCESS; } From 26f2acb6623cb096e88116711f15930c95c585bc Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Wed, 20 Mar 2024 15:58:12 +0000 Subject: [PATCH 15/23] Rename namespace from bpnode_evt_ to bpnode_evp_ --- CMakeLists.txt | 2 +- .../{bpnode_evt_cfs.c => bpnode_evp_cfs.c} | 28 +++++++++---------- .../{bpnode_evt_cfs.h => bpnode_evp_cfs.h} | 14 +++++----- fsw/src/bp_app.c | 6 ++-- 4 files changed, 25 insertions(+), 25 deletions(-) rename fsw/custom/{bpnode_evt_cfs.c => bpnode_evp_cfs.c} (81%) rename fsw/custom/{bpnode_evt_cfs.h => bpnode_evp_cfs.h} (74%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b71db671..832b351a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ set(APP_SRC_FILES fsw/custom/bp_semcfg.c fsw/custom/bp_storecfg.c fsw/custom/bp_tlmcfg.c - fsw/custom/bpnode_evt_cfs.c + fsw/custom/bpnode_evp_cfs.c ) if (CFE_EDS_ENABLED_BUILD) diff --git a/fsw/custom/bpnode_evt_cfs.c b/fsw/custom/bpnode_evp_cfs.c similarity index 81% rename from fsw/custom/bpnode_evt_cfs.c rename to fsw/custom/bpnode_evp_cfs.c index 7320ac8c..c44c1c2b 100644 --- a/fsw/custom/bpnode_evt_cfs.c +++ b/fsw/custom/bpnode_evp_cfs.c @@ -9,27 +9,27 @@ #include #include "cfe.h" #include "bpl_evm_api.h" -#include "bpnode_evt_cfs.h" +#include "bpnode_evp_cfs.h" /************************************************ * Exported Functions ************************************************/ /*----------------------------------------------- - * BPNODE_EVT_Initialize_Impl + * BPNODE_EVP_Initialize_Impl *-----------------------------------------------*/ -BPL_Status_t BPNODE_EVT_Initialize_Impl(void) +BPL_Status_t BPNODE_EVP_Initialize_Impl(void) { BPL_Status_t ReturnStatus = { .ReturnValue = BPL_STATUS_SUCCESS }; - OS_printf("BPNODE_EVT_Initialize_Impl called! TODO: Call CFE_EVS_Register here!\n"); + OS_printf("BPNODE_EVP_Initialize_Impl called! TODO: Call CFE_EVS_Register here!\n"); /* TODO: call EVS Register. */ return ReturnStatus; } /*----------------------------------------------- - * BPNODE_EVT_TranslateTypeToHost + * BPNODE_EVP_TranslateTypeToHost *-----------------------------------------------*/ -uint16_t BPNODE_EVT_TranslateTypeToHost(BPL_EVM_EventType_t EventType) +uint16_t BPNODE_EVP_TranslateTypeToHost(BPL_EVM_EventType_t EventType) { uint16_t HostEventType; switch (EventType) @@ -58,23 +58,23 @@ uint16_t BPNODE_EVT_TranslateTypeToHost(BPL_EVM_EventType_t EventType) } /*----------------------------------------------- - * BPNODE_EVT_SendEvent_Impl + * BPNODE_EVP_SendEvent_Impl *-----------------------------------------------*/ -BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t EventType, +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_EVT_TranslateTypeToHost(EventType); - char ExpandedEventText[BPNODE_EVT_MAX_MESSAGE_LENGTH]; + 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_EVT_MAX_MESSAGE_LENGTH >= 2); - assert(BPNODE_EVT_MAX_MESSAGE_LENGTH <= CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); + 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), @@ -82,7 +82,7 @@ BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t Eve if (ExpandedLength >= (int)sizeof(ExpandedEventText)) { /* Mark character before zero terminator to indicate truncation */ - ExpandedEventText[sizeof(ExpandedEventText) - 2u] = BPNODE_EVT_MSG_TRUNCATED; + 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. @@ -93,7 +93,7 @@ BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t Eve if (ProxyStatus != CFE_SUCCESS) { - OS_printf("BPNODE_EVT_SendEvent_Impl CFE_EVS_SendEvent returned error status: 0x%08X!\n", + OS_printf("BPNODE_EVP_SendEvent_Impl CFE_EVS_SendEvent returned error status: 0x%08X!\n", ProxyStatus); ReturnStatus.ReturnValue = BPL_STATUS_ERROR_GENERAL; } diff --git a/fsw/custom/bpnode_evt_cfs.h b/fsw/custom/bpnode_evp_cfs.h similarity index 74% rename from fsw/custom/bpnode_evt_cfs.h rename to fsw/custom/bpnode_evp_cfs.h index e26ab122..d3737729 100644 --- a/fsw/custom/bpnode_evt_cfs.h +++ b/fsw/custom/bpnode_evp_cfs.h @@ -2,8 +2,8 @@ * TODO: Fill in file header, if necessary. */ -#ifndef BPNODE_EVT_H -#define BPNODE_EVT_H +#ifndef BPNODE_EVP_CFS_H +#define BPNODE_EVP_CFS_H /************************************************ * Includes @@ -20,7 +20,7 @@ ** Defines the character used when truncating event strings that are too long ** Match what cFE uses (CFE_EVS_MSG_TRUNCATED) */ -#define BPNODE_EVT_MSG_TRUNCATED ('$') +#define BPNODE_EVP_MSG_TRUNCATED ('$') /* ** Defines the max length of the expanded event string @@ -29,14 +29,14 @@ ** - 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_EVT_MAX_MESSAGE_LENGTH (CFE_MISSION_EVS_MAX_MESSAGE_LENGTH) +#define BPNODE_EVP_MAX_MESSAGE_LENGTH (CFE_MISSION_EVS_MAX_MESSAGE_LENGTH) /************************************************ * Exported Functions ************************************************/ -BPL_Status_t BPNODE_EVT_Initialize_Impl(void); -BPL_Status_t BPNODE_EVT_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t EventType, +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_EVT_H */ +#endif /* BPNODE_EVP_CFS_H */ diff --git a/fsw/src/bp_app.c b/fsw/src/bp_app.c index 00e1bbdd..9af7febc 100644 --- a/fsw/src/bp_app.c +++ b/fsw/src/bp_app.c @@ -40,7 +40,7 @@ #include "bp_cla_bundle_io.h" #include "bplib_routing.h" #include "bpl_evm_api.h" -#include "bpnode_evt_cfs.h" +#include "bpnode_evp_cfs.h" /************************************************ * File Data @@ -69,8 +69,8 @@ static CFE_Status_t BP_SetupLibrary(void) /* TODO: Is this the right spot? */ BPL_EVM_ProxyCallbacks_t EventProxyCallbacks = { - .Initialize_Impl = BPNODE_EVT_Initialize_Impl, - .SendEvent_Impl = BPNODE_EVT_SendEvent_Impl, + .Initialize_Impl = BPNODE_EVP_Initialize_Impl, + .SendEvent_Impl = BPNODE_EVP_SendEvent_Impl, }; BPL_Status_t BPL_EVM_Status; From 29701c369e3ac7c5e89cd6dce806783269fd641f Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Wed, 20 Mar 2024 16:40:19 +0000 Subject: [PATCH 16/23] Move CFE_EVS_Register call and filter decl into EVP --- fsw/custom/bpnode_evp_cfs.c | 45 +++++++++++++++++++++++++++++++++++-- fsw/src/bp_app.c | 17 -------------- fsw/src/bp_global.h | 1 - 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/fsw/custom/bpnode_evp_cfs.c b/fsw/custom/bpnode_evp_cfs.c index c44c1c2b..16d212ee 100644 --- a/fsw/custom/bpnode_evp_cfs.c +++ b/fsw/custom/bpnode_evp_cfs.c @@ -8,9 +8,33 @@ #include #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}, + {BP_STORE_INFO_EID, CFE_EVS_FIRST_8_STOP}, + {BP_BPLIB_INFO_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 ************************************************/ @@ -21,8 +45,25 @@ BPL_Status_t BPNODE_EVP_Initialize_Impl(void) { BPL_Status_t ReturnStatus = { .ReturnValue = BPL_STATUS_SUCCESS }; - OS_printf("BPNODE_EVP_Initialize_Impl called! TODO: Call CFE_EVS_Register here!\n"); - /* TODO: call EVS Register. */ + 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 + { + OS_printf("BPNODE_EVP_Initialize_Impl registered %u event filters with EVS!\n", + (unsigned int) BPNODE_EVP_CFS_NUM_EVENT_FILTERS); + ReturnStatus.ReturnValue = BPL_STATUS_SUCCESS; + } + return ReturnStatus; } diff --git a/fsw/src/bp_app.c b/fsw/src/bp_app.c index 9af7febc..3230aee2 100644 --- a/fsw/src/bp_app.c +++ b/fsw/src/bp_app.c @@ -89,29 +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)); - - /* TODO: would need to remove this call. */ - /* 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) diff --git a/fsw/src/bp_global.h b/fsw/src/bp_global.h index e779a5aa..79158c9e 100644 --- a/fsw/src/bp_global.h +++ b/fsw/src/bp_global.h @@ -44,7 +44,6 @@ typedef struct CFE_SB_PipeId_t AppPipe; BP_HkPkt_t HkPkt; BP_FlowHkPkt_t FlowHkPkt; - CFE_EVS_BinFilter_t EventFilters[BP_MAX_EVENT_FILTERS]; char AppName[CFE_MISSION_MAX_API_LEN]; char ConfigTableName[CFE_TBL_MAX_FULL_NAME_LEN]; From 3828a506b74f0ce5f3f89a3f23c4df0cbe9760cc Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Wed, 20 Mar 2024 16:44:01 +0000 Subject: [PATCH 17/23] Remove unused Event IDs from default EVS filter to fix error The default array size was 9, when the max (set from CFE_PLATFORM_EVS_MAX_EVENT_FILTERS) is 8. These two EIDs weren't being referenced anywhere anyway, so I just removed them from the list. --- fsw/custom/bpnode_evp_cfs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fsw/custom/bpnode_evp_cfs.c b/fsw/custom/bpnode_evp_cfs.c index 16d212ee..deebfe52 100644 --- a/fsw/custom/bpnode_evp_cfs.c +++ b/fsw/custom/bpnode_evp_cfs.c @@ -28,8 +28,6 @@ static const CFE_EVS_BinFilter_t BPNODE_EVP_CFS_EVENT_FILTER[] = { {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 BPNODE_EVP_CFS_NUM_EVENT_FILTERS = sizeof(BPNODE_EVP_CFS_EVENT_FILTER) / From 30174050ab01e4b10d64a49c20bda98fbdadacc1 Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Wed, 20 Mar 2024 16:52:34 +0000 Subject: [PATCH 18/23] Remove newly unreferenced Event IDs Now that they aren't listed in the Event IDs filter, there's no refs to them. --- fsw/inc/bp_eventids.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/fsw/inc/bp_eventids.h b/fsw/inc/bp_eventids.h index 457f5cab..48d1ab28 100644 --- a/fsw/inc/bp_eventids.h +++ b/fsw/inc/bp_eventids.h @@ -59,9 +59,6 @@ #define BP_LIB_CONFIG_ERR_EID 36 #define BP_FILE_ERR_EID 37 #define BP_FILE_POLLING_NOT_ACTIVE_ERR_EID 38 -#define BP_STORE_INFO_EID 39 - -#define BP_BPLIB_INFO_EID 40 /* placeholder for CLA/Bundle flow events */ #define BP_CLA_INIT_INF_EID 50 From f5173ee040e4a17e5d870ce717d72ca2f6220508 Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Wed, 20 Mar 2024 17:48:26 +0000 Subject: [PATCH 19/23] Update debug prints in BPNODE_EVP_Initialize_Impl and SendEvent_Impl --- fsw/custom/bpnode_evp_cfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fsw/custom/bpnode_evp_cfs.c b/fsw/custom/bpnode_evp_cfs.c index deebfe52..28ab75c8 100644 --- a/fsw/custom/bpnode_evp_cfs.c +++ b/fsw/custom/bpnode_evp_cfs.c @@ -57,8 +57,6 @@ BPL_Status_t BPNODE_EVP_Initialize_Impl(void) } else { - OS_printf("BPNODE_EVP_Initialize_Impl registered %u event filters with EVS!\n", - (unsigned int) BPNODE_EVP_CFS_NUM_EVENT_FILTERS); ReturnStatus.ReturnValue = BPL_STATUS_SUCCESS; } @@ -128,6 +126,10 @@ BPL_Status_t BPNODE_EVP_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t Eve */ } + /* 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); + ProxyStatus = CFE_EVS_SendEvent(EventID, HostEventType, "%s", ExpandedEventText); if (ProxyStatus != CFE_SUCCESS) From 278c7d8964f721b35db439fa101d4359cca4378a Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Wed, 20 Mar 2024 18:04:19 +0000 Subject: [PATCH 20/23] Remove redundant ReturnStatus assignment in BPNODE_EVP_Initialize_Impl --- fsw/custom/bpnode_evp_cfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsw/custom/bpnode_evp_cfs.c b/fsw/custom/bpnode_evp_cfs.c index 28ab75c8..d34ce83f 100644 --- a/fsw/custom/bpnode_evp_cfs.c +++ b/fsw/custom/bpnode_evp_cfs.c @@ -42,7 +42,7 @@ const size_t BPNODE_EVP_CFS_NUM_EVENT_FILTERS = sizeof(BPNODE_EVP_CFS_EVENT_FILT *-----------------------------------------------*/ BPL_Status_t BPNODE_EVP_Initialize_Impl(void) { - BPL_Status_t ReturnStatus = { .ReturnValue = BPL_STATUS_SUCCESS }; + BPL_Status_t ReturnStatus; CFE_Status_t CfeEvsRegisterStatus; CfeEvsRegisterStatus = CFE_EVS_Register(BPNODE_EVP_CFS_EVENT_FILTER, From d6b3f0a03bf6534ffcdd8e5e217ac5f6f267a19c Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Mon, 25 Mar 2024 16:00:11 +0000 Subject: [PATCH 21/23] Remove EVP Init from callback functions in EVM --- fsw/custom/bpnode_evp_cfs.c | 14 ++++---------- fsw/custom/bpnode_evp_cfs.h | 2 +- fsw/src/bp_app.c | 5 ++++- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/fsw/custom/bpnode_evp_cfs.c b/fsw/custom/bpnode_evp_cfs.c index d34ce83f..1cefae69 100644 --- a/fsw/custom/bpnode_evp_cfs.c +++ b/fsw/custom/bpnode_evp_cfs.c @@ -38,11 +38,10 @@ const size_t BPNODE_EVP_CFS_NUM_EVENT_FILTERS = sizeof(BPNODE_EVP_CFS_EVENT_FILT ************************************************/ /*----------------------------------------------- - * BPNODE_EVP_Initialize_Impl + * BPNODE_EVP_Initialize *-----------------------------------------------*/ -BPL_Status_t BPNODE_EVP_Initialize_Impl(void) +CFE_Status_t BPNODE_EVP_Initialize(void) { - BPL_Status_t ReturnStatus; CFE_Status_t CfeEvsRegisterStatus; CfeEvsRegisterStatus = CFE_EVS_Register(BPNODE_EVP_CFS_EVENT_FILTER, @@ -51,16 +50,11 @@ BPL_Status_t BPNODE_EVP_Initialize_Impl(void) if (CfeEvsRegisterStatus != CFE_SUCCESS) { - OS_printf("BPNODE_EVP_Initialize_Impl call to CFE_EVS_Register returned error: %u!\n", + OS_printf("BPNODE_EVP_Initialize 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; + return CfeEvsRegisterStatus; } /*----------------------------------------------- diff --git a/fsw/custom/bpnode_evp_cfs.h b/fsw/custom/bpnode_evp_cfs.h index d3737729..186a89d4 100644 --- a/fsw/custom/bpnode_evp_cfs.h +++ b/fsw/custom/bpnode_evp_cfs.h @@ -35,7 +35,7 @@ * Exported Functions ************************************************/ -BPL_Status_t BPNODE_EVP_Initialize_Impl(void); +CFE_Status_t BPNODE_EVP_Initialize(void); BPL_Status_t BPNODE_EVP_SendEvent_Impl(uint16_t EventID, BPL_EVM_EventType_t EventType, char const * EventText, va_list EventTextArgPtr); diff --git a/fsw/src/bp_app.c b/fsw/src/bp_app.c index 3230aee2..4435d8d1 100644 --- a/fsw/src/bp_app.c +++ b/fsw/src/bp_app.c @@ -69,7 +69,6 @@ static CFE_Status_t BP_SetupLibrary(void) /* TODO: Is this the right spot? */ BPL_EVM_ProxyCallbacks_t EventProxyCallbacks = { - .Initialize_Impl = BPNODE_EVP_Initialize_Impl, .SendEvent_Impl = BPNODE_EVP_SendEvent_Impl, }; @@ -92,6 +91,10 @@ static CFE_Status_t AppInit(void) CFE_Status_t status = CFE_SUCCESS; CFE_ES_AppId_t app_id; + status = BPNODE_EVP_Initialize(); + if (status != CFE_SUCCESS) + return status; + memset(&BP_GlobalData, 0, sizeof(BP_GlobalData)); BP_GlobalData.Throttles = BP_Throttles; From 2483add1c195655cea841c217cf06e5977188a1f Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Mon, 25 Mar 2024 16:06:37 +0000 Subject: [PATCH 22/23] Remove TODO comment --- fsw/src/bp_app.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fsw/src/bp_app.c b/fsw/src/bp_app.c index 4435d8d1..a224dfe6 100644 --- a/fsw/src/bp_app.c +++ b/fsw/src/bp_app.c @@ -67,7 +67,6 @@ static CFE_Status_t BP_SetupLibrary(void) return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } - /* TODO: Is this the right spot? */ BPL_EVM_ProxyCallbacks_t EventProxyCallbacks = { .SendEvent_Impl = BPNODE_EVP_SendEvent_Impl, }; From ffcd02f169b5dbb494ec45bb9fcf4687acd70634 Mon Sep 17 00:00:00 2001 From: krmoore2 Date: Mon, 25 Mar 2024 17:39:33 +0000 Subject: [PATCH 23/23] Revert "Remove EVP Init from callback functions in EVM" This reverts commit d6b3f0a03bf6534ffcdd8e5e217ac5f6f267a19c. --- fsw/custom/bpnode_evp_cfs.c | 14 ++++++++++---- fsw/custom/bpnode_evp_cfs.h | 2 +- fsw/src/bp_app.c | 5 +---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/fsw/custom/bpnode_evp_cfs.c b/fsw/custom/bpnode_evp_cfs.c index 1cefae69..d34ce83f 100644 --- a/fsw/custom/bpnode_evp_cfs.c +++ b/fsw/custom/bpnode_evp_cfs.c @@ -38,10 +38,11 @@ const size_t BPNODE_EVP_CFS_NUM_EVENT_FILTERS = sizeof(BPNODE_EVP_CFS_EVENT_FILT ************************************************/ /*----------------------------------------------- - * BPNODE_EVP_Initialize + * BPNODE_EVP_Initialize_Impl *-----------------------------------------------*/ -CFE_Status_t BPNODE_EVP_Initialize(void) +BPL_Status_t BPNODE_EVP_Initialize_Impl(void) { + BPL_Status_t ReturnStatus; CFE_Status_t CfeEvsRegisterStatus; CfeEvsRegisterStatus = CFE_EVS_Register(BPNODE_EVP_CFS_EVENT_FILTER, @@ -50,11 +51,16 @@ CFE_Status_t BPNODE_EVP_Initialize(void) if (CfeEvsRegisterStatus != CFE_SUCCESS) { - OS_printf("BPNODE_EVP_Initialize call to CFE_EVS_Register returned error: %u!\n", + 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 CfeEvsRegisterStatus; + return ReturnStatus; } /*----------------------------------------------- diff --git a/fsw/custom/bpnode_evp_cfs.h b/fsw/custom/bpnode_evp_cfs.h index 186a89d4..d3737729 100644 --- a/fsw/custom/bpnode_evp_cfs.h +++ b/fsw/custom/bpnode_evp_cfs.h @@ -35,7 +35,7 @@ * Exported Functions ************************************************/ -CFE_Status_t BPNODE_EVP_Initialize(void); +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); diff --git a/fsw/src/bp_app.c b/fsw/src/bp_app.c index a224dfe6..69fe22c8 100644 --- a/fsw/src/bp_app.c +++ b/fsw/src/bp_app.c @@ -68,6 +68,7 @@ static CFE_Status_t BP_SetupLibrary(void) } BPL_EVM_ProxyCallbacks_t EventProxyCallbacks = { + .Initialize_Impl = BPNODE_EVP_Initialize_Impl, .SendEvent_Impl = BPNODE_EVP_SendEvent_Impl, }; @@ -90,10 +91,6 @@ static CFE_Status_t AppInit(void) CFE_Status_t status = CFE_SUCCESS; CFE_ES_AppId_t app_id; - status = BPNODE_EVP_Initialize(); - if (status != CFE_SUCCESS) - return status; - memset(&BP_GlobalData, 0, sizeof(BP_GlobalData)); BP_GlobalData.Throttles = BP_Throttles;