Skip to content

Commit

Permalink
Fix nasa#45, Opaque CFE_SB_MsgId_t values
Browse files Browse the repository at this point in the history
Do not assume CFE_SB_MsgId_t is implicitly integral in nature.
When an integer value is required for printing or backward
compatibility, use the explicit conversion routine to
get this.
  • Loading branch information
jphickey committed Apr 6, 2020
1 parent fe9e3ef commit cf78269
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions fsw/src/ci_lab_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ void CI_LAB_TaskInit(void)
CFE_EVS_EventFilter_BINARY);

CFE_SB_CreatePipe(&CI_LAB_Global.CommandPipe, CI_LAB_PIPE_DEPTH, "CI_LAB_CMD_PIPE");
CFE_SB_Subscribe(CI_LAB_CMD_MID, CI_LAB_Global.CommandPipe);
CFE_SB_Subscribe(CI_LAB_SEND_HK_MID, CI_LAB_Global.CommandPipe);
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 = OS_SocketOpen(&CI_LAB_Global.SocketID, OS_SocketDomain_INET, OS_SocketType_DATAGRAM);
if (status != OS_SUCCESS)
Expand Down Expand Up @@ -201,7 +201,9 @@ void CI_LAB_TaskInit(void)
*/
OS_TaskInstallDeleteHandler(&CI_LAB_delete_callback);

CFE_SB_InitMsg(&CI_LAB_Global.HkBuffer.HkTlm, CI_LAB_HK_TLM_MID, CI_LAB_HK_TLM_LNGTH, true);
CFE_SB_InitMsg(&CI_LAB_Global.HkBuffer.HkTlm,
CFE_SB_ValueToMsgId(CI_LAB_HK_TLM_MID),
CI_LAB_HK_TLM_LNGTH, true);

CFE_EVS_SendEvent(CI_LAB_STARTUP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI Lab Initialized. Version %d.%d.%d.%d",
CI_LAB_MAJOR_VERSION, CI_LAB_MINOR_VERSION, CI_LAB_REVISION, CI_LAB_MISSION_REV);
Expand All @@ -225,7 +227,7 @@ void CI_LAB_ProcessCommandPacket(void)
CFE_SB_MsgId_t MsgId;
MsgId = CFE_SB_GetMsgId(CI_LAB_Global.MsgPtr);

switch (MsgId)
switch (CFE_SB_MsgIdToValue(MsgId))
{
case CI_LAB_CMD_MID:
CI_LAB_ProcessGroundCommand();
Expand All @@ -238,7 +240,7 @@ void CI_LAB_ProcessCommandPacket(void)
default:
CI_LAB_Global.HkBuffer.HkTlm.Payload.CommandErrorCounter++;
CFE_EVS_SendEvent(CI_LAB_COMMAND_ERR_EID, CFE_EVS_EventType_ERROR, "CI: invalid command packet,MID = 0x%x",
MsgId);
(unsigned int)CFE_SB_MsgIdToValue(MsgId));
break;
}

Expand Down Expand Up @@ -407,8 +409,11 @@ bool CI_LAB_VerifyCmdLength(CFE_SB_MsgPtr_t msg, uint16 ExpectedLength)
uint16 CommandCode = CFE_SB_GetCmdCode(msg);

CFE_EVS_SendEvent(CI_LAB_LEN_ERR_EID, CFE_EVS_EventType_ERROR,
"Invalid msg length: ID = 0x%X, CC = %d, Len = %d, Expected = %d", MessageID, CommandCode,
ActualLength, ExpectedLength);
"Invalid msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u",
(unsigned int)CFE_SB_MsgIdToValue(MessageID),
(unsigned int)CommandCode,
(unsigned int)ActualLength,
(unsigned int)ExpectedLength);
result = false;
CI_LAB_Global.HkBuffer.HkTlm.Payload.CommandErrorCounter++;
}
Expand Down

0 comments on commit cf78269

Please sign in to comment.