From 9f37dde4c5bbce6e2d1ecc8949a84525fdd34ab0 Mon Sep 17 00:00:00 2001 From: Avi Date: Tue, 8 Nov 2022 10:16:19 +1000 Subject: [PATCH] Fix #96, Check returns from CFE calls during init --- fsw/inc/ci_lab_eventids.h | 27 +++++++++++++++------------ fsw/src/ci_lab_app.c | 31 +++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/fsw/inc/ci_lab_eventids.h b/fsw/inc/ci_lab_eventids.h index 7380bd4..fda8b00 100644 --- a/fsw/inc/ci_lab_eventids.h +++ b/fsw/inc/ci_lab_eventids.h @@ -23,17 +23,20 @@ #ifndef CI_LAB_EVENTIDS_H #define CI_LAB_EVENTIDS_H -#define CI_LAB_RESERVED_EID 0 -#define CI_LAB_SOCKETCREATE_ERR_EID 1 -#define CI_LAB_SOCKETBIND_ERR_EID 2 -#define CI_LAB_STARTUP_INF_EID 3 -#define CI_LAB_COMMAND_ERR_EID 4 -#define CI_LAB_COMMANDNOP_INF_EID 5 -#define CI_LAB_COMMANDRST_INF_EID 6 -#define CI_LAB_INGEST_INF_EID 7 -#define CI_LAB_INGEST_LEN_ERR_EID 8 -#define CI_LAB_INGEST_ALLOC_ERR_EID 9 -#define CI_LAB_INGEST_SEND_ERR_EID 10 -#define CI_LAB_LEN_ERR_EID 16 +#define CI_LAB_RESERVED_EID 0 +#define CI_LAB_SOCKETCREATE_ERR_EID 1 +#define CI_LAB_SOCKETBIND_ERR_EID 2 +#define CI_LAB_STARTUP_INF_EID 3 +#define CI_LAB_COMMAND_ERR_EID 4 +#define CI_LAB_COMMANDNOP_INF_EID 5 +#define CI_LAB_COMMANDRST_INF_EID 6 +#define CI_LAB_INGEST_INF_EID 7 +#define CI_LAB_INGEST_LEN_ERR_EID 8 +#define CI_LAB_INGEST_ALLOC_ERR_EID 9 +#define CI_LAB_INGEST_SEND_ERR_EID 10 +#define CI_LAB_CREATE_PIPE_ERR_EID 11 +#define CI_LAB_SB_SUBSCRIBE_CMD_ERR_EID 12 +#define CI_LAB_SB_SUBSCRIBE_HK_ERR_EID 13 +#define CI_LAB_LEN_ERR_EID 16 #endif diff --git a/fsw/src/ci_lab_app.c b/fsw/src/ci_lab_app.c index 11c9d0a..8cb550c 100644 --- a/fsw/src/ci_lab_app.c +++ b/fsw/src/ci_lab_app.c @@ -106,11 +106,34 @@ void CI_LAB_TaskInit(void) memset(&CI_LAB_Global, 0, sizeof(CI_LAB_Global)); - CFE_EVS_Register(NULL, 0, CFE_EVS_EventFilter_BINARY); + status = CFE_EVS_Register(NULL, 0, CFE_EVS_EventFilter_BINARY); + if (status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("CI_LAB: Error registering for Event Services, RC = 0x%08X\n", (unsigned int)status); + } + + status = CFE_SB_CreatePipe(&CI_LAB_Global.CommandPipe, CI_LAB_PIPE_DEPTH, "CI_LAB_CMD_PIPE"); + if (status == CFE_SUCCESS) + { + status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CI_LAB_CMD_MID), CI_LAB_Global.CommandPipe); + if (status != CFE_SUCCESS) + { + CFE_EVS_SendEvent(CI_LAB_SB_SUBSCRIBE_CMD_ERR_EID, CFE_EVS_EventType_ERROR, + "Error subscribing to SB Commands, RC = 0x%08X", (unsigned int)status); + } - CFE_SB_CreatePipe(&CI_LAB_Global.CommandPipe, CI_LAB_PIPE_DEPTH, "CI_LAB_CMD_PIPE"); - CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CI_LAB_CMD_MID), CI_LAB_Global.CommandPipe); - CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CI_LAB_SEND_HK_MID), CI_LAB_Global.CommandPipe); + status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CI_LAB_SEND_HK_MID), CI_LAB_Global.CommandPipe); + if (status != CFE_SUCCESS) + { + CFE_EVS_SendEvent(CI_LAB_SB_SUBSCRIBE_HK_ERR_EID, CFE_EVS_EventType_ERROR, + "Error subscribing to SB HK Request, RC = 0x%08X", (unsigned int)status); + } + } + else + { + CFE_EVS_SendEvent(CI_LAB_CREATE_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, + "Error creating SB Command Pipe, RC = 0x%08X", (unsigned int)status); + } status = OS_SocketOpen(&CI_LAB_Global.SocketID, OS_SocketDomain_INET, OS_SocketType_DATAGRAM); if (status != OS_SUCCESS)