Skip to content

Commit

Permalink
Merge pull request #154 from jphickey/fix-153-msgidvalue
Browse files Browse the repository at this point in the history
Fix #153, apply CFE_SB_ValueToMsgId where required
  • Loading branch information
astrogeco authored Sep 21, 2021
2 parents 847ba8e + 294e6af commit 35fa4f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions fsw/src/sample_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ int32 SAMPLE_APP_Init(void)
/*
** Initialize housekeeping packet (clear user data area).
*/
CFE_MSG_Init(&SAMPLE_APP_Data.HkTlm.TlmHeader.Msg, SAMPLE_APP_HK_TLM_MID, sizeof(SAMPLE_APP_Data.HkTlm));
CFE_MSG_Init(&SAMPLE_APP_Data.HkTlm.TlmHeader.Msg, CFE_SB_ValueToMsgId(SAMPLE_APP_HK_TLM_MID),
sizeof(SAMPLE_APP_Data.HkTlm));

/*
** Create Software Bus message pipe.
Expand All @@ -178,7 +179,7 @@ int32 SAMPLE_APP_Init(void)
/*
** Subscribe to Housekeeping request commands
*/
status = CFE_SB_Subscribe(SAMPLE_APP_SEND_HK_MID, SAMPLE_APP_Data.CommandPipe);
status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(SAMPLE_APP_SEND_HK_MID), SAMPLE_APP_Data.CommandPipe);
if (status != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("Sample App: Error Subscribing to HK request, RC = 0x%08lX\n", (unsigned long)status);
Expand All @@ -188,7 +189,7 @@ int32 SAMPLE_APP_Init(void)
/*
** Subscribe to ground command packets
*/
status = CFE_SB_Subscribe(SAMPLE_APP_CMD_MID, SAMPLE_APP_Data.CommandPipe);
status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(SAMPLE_APP_CMD_MID), SAMPLE_APP_Data.CommandPipe);
if (status != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("Sample App: Error Subscribing to Command, RC = 0x%08lX\n", (unsigned long)status);
Expand Down Expand Up @@ -233,7 +234,7 @@ void SAMPLE_APP_ProcessCommandPacket(CFE_SB_Buffer_t *SBBufPtr)

CFE_MSG_GetMsgId(&SBBufPtr->Msg, &MsgId);

switch (MsgId)
switch (CFE_SB_MsgIdToValue(MsgId))
{
case SAMPLE_APP_CMD_MID:
SAMPLE_APP_ProcessGroundCommand(SBBufPtr);
Expand Down
4 changes: 2 additions & 2 deletions unit-test/coveragetest/coveragetest_sample_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,15 @@ void Test_SAMPLE_APP_ProcessCommandPacket(void)
* The CFE_MSG_GetMsgId() stub uses a data buffer to hold the
* message ID values to return.
*/
TestMsgId = SAMPLE_APP_CMD_MID;
TestMsgId = CFE_SB_ValueToMsgId(SAMPLE_APP_CMD_MID);
FcnCode = SAMPLE_APP_NOOP_CC;
MsgSize = sizeof(TestMsg.Noop);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false);
SAMPLE_APP_ProcessCommandPacket(&TestMsg.SBBuf);

TestMsgId = SAMPLE_APP_SEND_HK_MID;
TestMsgId = CFE_SB_ValueToMsgId(SAMPLE_APP_SEND_HK_MID);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false);
SAMPLE_APP_ProcessCommandPacket(&TestMsg.SBBuf);

Expand Down

0 comments on commit 35fa4f7

Please sign in to comment.