Skip to content

Commit

Permalink
Fix #96, Check returns from CFE calls during init
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Nov 9, 2023
1 parent 68a7336 commit d5e6f3c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
27 changes: 15 additions & 12 deletions fsw/inc/ci_lab_eventids.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_INIT_INF_EID 3
#define CI_LAB_MID_ERR_EID 4
#define CI_LAB_NOOP_INF_EID 5
#define CI_LAB_RESET_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_CMD_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_INIT_INF_EID 3
#define CI_LAB_MID_ERR_EID 4
#define CI_LAB_NOOP_INF_EID 5
#define CI_LAB_RESET_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_CMD_LEN_ERR_EID 16

#endif
31 changes: 27 additions & 4 deletions fsw/src/ci_lab_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d5e6f3c

Please sign in to comment.