Skip to content

Commit

Permalink
Fix #204, Check return value of calls to CFE_SB_Subscribe()
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Oct 11, 2024
1 parent fe6c9fd commit 8af52cf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
2 changes: 2 additions & 0 deletions fsw/inc/to_lab_eventids.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#define TO_LAB_NOOP_INF_EID 18
#define TO_LAB_TBL_ERR_EID 19
#define TO_LAB_ENCODE_ERR_EID 20
#define TO_LAB_SUBSCRIBE_CMD_ERR_EID 21
#define TO_LAB_SUBSCRIBE_HK_ERR_EID 22

/******************************************************************************/

Expand Down
31 changes: 24 additions & 7 deletions fsw/src/to_lab_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ CFE_Status_t TO_LAB_init(void)

if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't register table status %i",
CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO can't register table status %i",
__LINE__, (int)status);
}
}
Expand All @@ -152,7 +152,7 @@ CFE_Status_t TO_LAB_init(void)

if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't load table status %i",
CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO can't load table status %i",
__LINE__, (int)status);
}
}
Expand All @@ -163,7 +163,7 @@ CFE_Status_t TO_LAB_init(void)

if (status != CFE_SUCCESS && status != CFE_TBL_INFO_UPDATED)
{
CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't get table addr status %i",
CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO can't get table addr status %i",
__LINE__, (int)status);
}
}
Expand All @@ -176,22 +176,39 @@ CFE_Status_t TO_LAB_init(void)
status = CFE_SB_CreatePipe(&TO_LAB_Global.Cmd_pipe, PipeDepth, PipeName);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't create cmd pipe status %i",
CFE_EVS_SendEvent(TO_LAB_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO can't create cmd pipe status %i",
__LINE__, (int)status);
}
}

if (status == CFE_SUCCESS)
{

CFE_SB_Subscribe(CFE_SB_ValueToMsgId(TO_LAB_CMD_MID), TO_LAB_Global.Cmd_pipe);
status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(TO_LAB_CMD_MID), TO_LAB_Global.Cmd_pipe);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_SUBSCRIBE_CMD_ERR_EID, CFE_EVS_EventType_ERROR,
"L%d TO can't subscribe to cmd mid status %i", __LINE__, (int)status);
}
}

if (status == CFE_SUCCESS)
{
CFE_SB_Subscribe(CFE_SB_ValueToMsgId(TO_LAB_SEND_HK_MID), TO_LAB_Global.Cmd_pipe);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_SUBSCRIBE_HK_ERR_EID, CFE_EVS_EventType_ERROR,
"L%d TO can't subscribe to HK mid status %i", __LINE__, (int)status);
}
}

if (status == CFE_SUCCESS)
{
/* Create TO TLM pipe */
status = CFE_SB_CreatePipe(&TO_LAB_Global.Tlm_pipe, ToTlmPipeDepth, ToTlmPipeName);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_TLMPIPE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't create Tlm pipe status %i",
CFE_EVS_SendEvent(TO_LAB_TLMPIPE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO can't create Tlm pipe status %i",
__LINE__, (int)status);
}
}
Expand All @@ -212,7 +229,7 @@ CFE_Status_t TO_LAB_init(void)
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_SUBSCRIBE_ERR_EID, CFE_EVS_EventType_ERROR,
"L%d TO Can't subscribe to stream 0x%x status %i", __LINE__,
"L%d TO can't subscribe to stream 0x%x status %i", __LINE__,
(unsigned int)CFE_SB_MsgIdToValue(SubEntry->Stream), (int)status);
}

Expand Down

0 comments on commit 8af52cf

Please sign in to comment.