Skip to content

Commit

Permalink
Fix #2362, Add source routing APIs to SB
Browse files Browse the repository at this point in the history
Add two new APIs that allow more control over the message routing.
These allow the caller to directly specify the route (MsgId) and size of
the content, and the message will be delivered based on the passed in
values vs. the values inside the message itself.

This restructures the existing/historical API calls to use the same
underlying mechanism.  Send/Receive actions have a transaction object
associated and this tracks the status and events.  Common event
reporting is done based on this transaction object.
  • Loading branch information
jphickey committed Jun 2, 2023
1 parent b429d91 commit 9a81cb6
Show file tree
Hide file tree
Showing 15 changed files with 2,693 additions and 1,254 deletions.
36 changes: 35 additions & 1 deletion modules/cfe_testcase/src/sb_sendrecv_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void TestBasicTransmitRecv(void)
UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, -100), CFE_SB_BAD_ARGUMENT);

/*
* Note, the CFE_SB_TransmitMsg now adheres to the "UpdateHeader" flag.
* Note, the CFE_SB_TransmitMsg now adheres to the "EnableUpdate" flag.
* Thus, the sequence numbers should come back with the value from the Route (1-2)
* rather than the value the message was filled with initially.
*
Expand Down Expand Up @@ -598,10 +598,44 @@ void TestMiscMessageUtils(void)
CFE_SB_BAD_ARGUMENT);
}

void TestSourceRouting(void)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
CFE_SB_Buffer_t * TxBufPtr;
const CFE_SB_Buffer_t *RxBufPtr;
size_t RxSize;
CFE_SB_MsgId_t RxMsgId;
CFE_SB_PipeId_t PipeId;

/* Random data -- not a CCSDS header (this is intentional) */
const uint8_t Content[16] = {0xe9, 0xf2, 0x67, 0x3d, 0x5e, 0x54, 0x1a, 0xa5,
0xe9, 0xe2, 0x11, 0xe8, 0x71, 0x85, 0xb7, 0x0d};

/* Setup, create a pipe and subscribe (one cmd, one tlm) */
UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId, 5, "TestPipe"), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_FT_CMD_MSGID, PipeId, CFE_SB_DEFAULT_QOS, 3), CFE_SUCCESS);

TxBufPtr = CFE_SB_AllocateMessageBuffer(sizeof(Content));
UtAssert_NOT_NULL(TxBufPtr);
memcpy(TxBufPtr, Content, sizeof(Content));

UtAssert_INT32_EQ(CFE_SB_TransmitBufferWithRoute(TxBufPtr, sizeof(Content), CFE_FT_CMD_MSGID, false, CFE_SB_POLL),
CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_SB_ReceiveBufferWithRoute(PipeId, &RxBufPtr, &RxSize, &RxMsgId, false, CFE_SB_POLL),
CFE_SUCCESS);

UtAssert_ADDRESS_EQ(RxBufPtr, TxBufPtr);
UtAssert_UINT32_EQ(RxSize, sizeof(Content));
CFE_Assert_MSGID_EQ(RxMsgId, CFE_FT_CMD_MSGID);

/* Cleanup */
UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId), CFE_SUCCESS);
}

void SBSendRecvTestSetup(void)
{
UtTest_Add(TestBasicTransmitRecv, NULL, NULL, "Test Basic Transmit/Receive");
UtTest_Add(TestZeroCopyTransmitRecv, NULL, NULL, "Test Zero Copy Transmit/Receive");
UtTest_Add(TestMsgBroadcast, NULL, NULL, "Test Msg Broadcast");
UtTest_Add(TestSourceRouting, NULL, NULL, "Test Source Routing APIs");
UtTest_Add(TestMiscMessageUtils, NULL, NULL, "Test Miscellaneous Message Utility APIs");
}
3 changes: 2 additions & 1 deletion modules/core_api/fsw/inc/cfe_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ CFE_Status_t CFE_MSG_Init(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId, CFE_M
*
* \param[inout] MsgPtr A pointer to the buffer that contains the message @nonnull.
* \param[in] SeqCnt The current sequence number from the message route
* \param[in] MsgSize The size of the message
*
* \return Execution status, see \ref CFEReturnCodes
* \retval #CFE_SUCCESS \copybrief CFE_SUCCESS
* \retval #CFE_MSG_BAD_ARGUMENT \copybrief CFE_MSG_BAD_ARGUMENT
*/
CFE_Status_t CFE_MSG_UpdateHeader(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt);
CFE_Status_t CFE_MSG_UpdateHeader(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt, CFE_MSG_Size_t MsgSize);

/**\}*/

Expand Down
87 changes: 81 additions & 6 deletions modules/core_api/fsw/inc/cfe_sb.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ CFE_Status_t CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeI
** software bus will read the message ID from the message header to
** determine which pipes should receive the message.
**
** In general, the "UpdateHeader" parameter should be passed as "true"
** In general, the "EnableUpdate" parameter should be passed as "true"
** if the message was newly constructed by the sender and is being sent
** for the first time. When forwarding a message that originated from
** an external entity (e.g. messages passing through CI or SBN), the
Expand All @@ -421,15 +421,15 @@ CFE_Status_t CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeI
**
** \param[in] MsgPtr A pointer to the message to be sent @nonnull. This must point
** to the first byte of the message header.
** \param[in] UpdateHeader Update the headers of the message
** \param[in] EnableUpdate Update the headers of the message
**
** \return Execution status, see \ref CFEReturnCodes
** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS
** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT
** \retval #CFE_SB_MSG_TOO_BIG \copybrief CFE_SB_MSG_TOO_BIG
** \retval #CFE_SB_BUF_ALOC_ERR \covtest \copybrief CFE_SB_BUF_ALOC_ERR
**/
CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool UpdateHeader);
CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool EnableUpdate);

/*****************************************************************************/
/**
Expand Down Expand Up @@ -471,6 +471,46 @@ CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool UpdateHead
** \retval #CFE_SB_NO_MESSAGE \copybrief CFE_SB_NO_MESSAGE
**/
CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut);

/*****************************************************************************/
/**
** \brief Receive a generic buffer
**
** \par Description
** This routine accepts an abstract buffer via the software bus
** from the specified pipe, without relying on the MsgId and/or routing
** information from the message headers. As a result, the buffer need not
** strictly be a CFE CMD/TLM message, it can be any arbitrary data. The
** routing information is passed out-of-band and will be returned in the specified
** buffers.
**
** The message also may be verified if "EnableVerify" is set to true. In this
** case, CFE_MSG_Verify() is invoked on the received message, and if this results
** in validation failure, the message will be internally discarded and not passed
** back to the caller. Note that in this case, the buffer cannot be arbitrary data,
** it must be compliant with the expected headers. Arbitrary data can only be passed
** by setting this parameter to "false"
**
** \par Assumptions, External Events, and Notes:
** - See CFE_SB_ReceiveBuffer()
**
** \param[in] PipeId Pipe ID to receive from
** \param[out] BufPtr A pointer to the buffer to be received @nonnull.
** \param[out] ContentSize Actual content size of the message
** \param[out] RoutingMsgId Destination/Route to which the message was sent
** \param[in] EnableVerify Verify the headers of the message
** \param[in] TimeOut Maxmimum amount of time to block
**
** \return Execution status, see \ref CFEReturnCodes
** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS
** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT
** \retval #CFE_SB_TIME_OUT \copybrief CFE_SB_TIME_OUT
** \retval #CFE_SB_PIPE_RD_ERR \covtest \copybrief CFE_SB_PIPE_RD_ERR
** \retval #CFE_SB_NO_MESSAGE \copybrief CFE_SB_NO_MESSAGE
*/
CFE_Status_t CFE_SB_ReceiveBufferWithRoute(CFE_SB_PipeId_t PipeId, const CFE_SB_Buffer_t **BufPtr, size_t *ContentSize,
CFE_SB_MsgId_t *RoutingMsgId, bool EnableVerify, int32 TimeOut);

/** @} */

/** @defgroup CFEAPISBZeroCopy cFE Zero Copy APIs
Expand Down Expand Up @@ -544,7 +584,7 @@ CFE_Status_t CFE_SB_ReleaseMessageBuffer(CFE_SB_Buffer_t *BufPtr);
** internal buffer. The "zero copy" interface can be used to improve
** performance in high-rate, high-volume software bus traffic.
**
** In general, the "UpdateHeader" parameter should be passed as "true"
** In general, the "EnableUpdate" parameter should be passed as "true"
** if the message was newly constructed by the sender and is being sent
** for the first time. When forwarding a message that originated from
** an external entity (e.g. messages passing through CI or SBN), the
Expand All @@ -568,14 +608,49 @@ CFE_Status_t CFE_SB_ReleaseMessageBuffer(CFE_SB_Buffer_t *BufPtr);
** sequence counter if set to do so.
**
** \param[in] BufPtr A pointer to the buffer to be sent @nonnull.
** \param[in] UpdateHeader Update the headers of the message
** \param[in] EnableUpdate Update the headers of the message
**
** \return Execution status, see \ref CFEReturnCodes
** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS
** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT
** \retval #CFE_SB_MSG_TOO_BIG \copybrief CFE_SB_MSG_TOO_BIG
**/
CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool UpdateHeader);
CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool EnableUpdate);

/*****************************************************************************/
/**
** \brief Transmit a generic buffer with source routing
**
** \par Description
** This routine sends an abstract buffer via the software bus directly
** to the specified destination, without relying on the MsgId and/or routing
** information from the message headers. As a result, the buffer need not
** strictly be a CFE CMD/TLM message, it can be any arbitrary data (but see note).
** The buffer will be delivered to subscribers based on the message ID passed in.
**
** \par Assumptions, External Events, and Notes:
** -# See CFE_SB_TransmitBuffer() - the passed-in buffer object is consumed by this
** call in a similar manner.
** -# If "EnableUpdate" is passed as "true", then the content must be a CFE message
** with the expected headers (it cannot be arbitrary data, as the header update
** will modify it based on the normally expected header). Only when this boolean
** is passed as "false" does this routine not access the buffer at all.
** -# For normal broadcast messages, the TimeOut should generally be CFE_SB_POLL only.
** Nonzero timeouts may be useful for point-to-point connections as a future enhancement.
**
** \param[in] BufPtr A pointer to the buffer to be sent @nonnull.
** \param[in] ContentSize Actual content size of the message
** \param[in] RoutingMsgId Destination/Route to which the message should be broadcast
** \param[in] EnableUpdate Update the headers of the message
** \param[in] TimeOut Maxmimum amount of time to block (not for broadcast)
**
** \return Execution status, see \ref CFEReturnCodes
** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS
** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT
** \retval #CFE_SB_MSG_TOO_BIG \copybrief CFE_SB_MSG_TOO_BIG
*/
CFE_Status_t CFE_SB_TransmitBufferWithRoute(CFE_SB_Buffer_t *BufPtr, size_t ContentSize, CFE_SB_MsgId_t RoutingMsgId,
bool EnableUpdate, int32 TimeOut);

/** @} */

Expand Down
16 changes: 16 additions & 0 deletions modules/core_api/ut-stubs/src/cfe_msg_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,19 @@ void UT_DefaultHandler_CFE_MSG_GetNextSequenceCount(void *UserObj, UT_EntryKey_t

UT_Stub_SetReturnValue(FuncKey, return_value);
}

/*------------------------------------------------------------
*
* Default handler for CFE_MSG_Verify coverage stub function
*
*------------------------------------------------------------*/
void UT_DefaultHandler_CFE_MSG_Verify(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
{
bool *VerifyStatus = UT_Hook_GetArgValueByName(Context, "VerifyStatus", bool *);

/* by default just always return true -- a UT case that needs something else can override this handler */
if (VerifyStatus != NULL)
{
*VerifyStatus = true;
}
}
21 changes: 20 additions & 1 deletion modules/core_api/ut-stubs/src/cfe_msg_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void UT_DefaultHandler_CFE_MSG_GetSystem(void *, UT_EntryKey_t, const UT_StubCon
void UT_DefaultHandler_CFE_MSG_GetType(void *, UT_EntryKey_t, const UT_StubContext_t *);
void UT_DefaultHandler_CFE_MSG_GetTypeFromMsgId(void *, UT_EntryKey_t, const UT_StubContext_t *);
void UT_DefaultHandler_CFE_MSG_ValidateChecksum(void *, UT_EntryKey_t, const UT_StubContext_t *);
void UT_DefaultHandler_CFE_MSG_Verify(void *, UT_EntryKey_t, const UT_StubContext_t *);

/*
* ----------------------------------------------------
Expand Down Expand Up @@ -626,12 +627,13 @@ CFE_Status_t CFE_MSG_SetType(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Type_t Type)
* Generated stub function for CFE_MSG_UpdateHeader()
* ----------------------------------------------------
*/
CFE_Status_t CFE_MSG_UpdateHeader(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt)
CFE_Status_t CFE_MSG_UpdateHeader(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt, CFE_MSG_Size_t MsgSize)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
UT_GenStub_SetupReturnBuffer(CFE_MSG_UpdateHeader, CFE_Status_t);

UT_GenStub_AddParam(CFE_MSG_UpdateHeader, CFE_MSG_Message_t *, MsgPtr);
UT_GenStub_AddParam(CFE_MSG_UpdateHeader, CFE_MSG_SequenceCount_t, SeqCnt);
UT_GenStub_AddParam(CFE_MSG_UpdateHeader, CFE_MSG_Size_t, MsgSize);

UT_GenStub_Execute(CFE_MSG_UpdateHeader, Basic, NULL);

Expand All @@ -654,3 +656,20 @@ CFE_Status_t CFE_MSG_ValidateChecksum(const CFE_MSG_Message_t *MsgPtr, bool *IsV

return UT_GenStub_GetReturnValue(CFE_MSG_ValidateChecksum, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for CFE_MSG_Verify()
* ----------------------------------------------------
*/
CFE_Status_t CFE_MSG_Verify(const CFE_MSG_Message_t *MsgPtr, bool *VerifyStatus)
{
UT_GenStub_SetupReturnBuffer(CFE_MSG_Verify, CFE_Status_t);

UT_GenStub_AddParam(CFE_MSG_Verify, const CFE_MSG_Message_t *, MsgPtr);
UT_GenStub_AddParam(CFE_MSG_Verify, bool *, VerifyStatus);

UT_GenStub_Execute(CFE_MSG_Verify, Basic, UT_DefaultHandler_CFE_MSG_Verify);

return UT_GenStub_GetReturnValue(CFE_MSG_Verify, CFE_Status_t);
}
51 changes: 47 additions & 4 deletions modules/core_api/ut-stubs/src/cfe_sb_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,28 @@ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t Pipe
return UT_GenStub_GetReturnValue(CFE_SB_ReceiveBuffer, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for CFE_SB_ReceiveBufferWithRoute()
* ----------------------------------------------------
*/
CFE_Status_t CFE_SB_ReceiveBufferWithRoute(CFE_SB_PipeId_t PipeId, const CFE_SB_Buffer_t **BufPtr, size_t *ContentSize,

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
CFE_SB_MsgId_t *RoutingMsgId, bool EnableVerify, int32 TimeOut)
{
UT_GenStub_SetupReturnBuffer(CFE_SB_ReceiveBufferWithRoute, CFE_Status_t);

UT_GenStub_AddParam(CFE_SB_ReceiveBufferWithRoute, CFE_SB_PipeId_t, PipeId);
UT_GenStub_AddParam(CFE_SB_ReceiveBufferWithRoute, const CFE_SB_Buffer_t **, BufPtr);
UT_GenStub_AddParam(CFE_SB_ReceiveBufferWithRoute, size_t *, ContentSize);
UT_GenStub_AddParam(CFE_SB_ReceiveBufferWithRoute, CFE_SB_MsgId_t *, RoutingMsgId);
UT_GenStub_AddParam(CFE_SB_ReceiveBufferWithRoute, bool, EnableVerify);
UT_GenStub_AddParam(CFE_SB_ReceiveBufferWithRoute, int32, TimeOut);

UT_GenStub_Execute(CFE_SB_ReceiveBufferWithRoute, Basic, NULL);

return UT_GenStub_GetReturnValue(CFE_SB_ReceiveBufferWithRoute, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for CFE_SB_ReleaseMessageBuffer()
Expand Down Expand Up @@ -384,29 +406,50 @@ void CFE_SB_TimeStampMsg(CFE_MSG_Message_t *MsgPtr)
* Generated stub function for CFE_SB_TransmitBuffer()
* ----------------------------------------------------
*/
CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool UpdateHeader)
CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool EnableUpdate)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
UT_GenStub_SetupReturnBuffer(CFE_SB_TransmitBuffer, CFE_Status_t);

UT_GenStub_AddParam(CFE_SB_TransmitBuffer, CFE_SB_Buffer_t *, BufPtr);
UT_GenStub_AddParam(CFE_SB_TransmitBuffer, bool, UpdateHeader);
UT_GenStub_AddParam(CFE_SB_TransmitBuffer, bool, EnableUpdate);

UT_GenStub_Execute(CFE_SB_TransmitBuffer, Basic, UT_DefaultHandler_CFE_SB_TransmitBuffer);

return UT_GenStub_GetReturnValue(CFE_SB_TransmitBuffer, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for CFE_SB_TransmitBufferWithRoute()
* ----------------------------------------------------
*/
CFE_Status_t CFE_SB_TransmitBufferWithRoute(CFE_SB_Buffer_t *BufPtr, size_t ContentSize, CFE_SB_MsgId_t RoutingMsgId,

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
bool EnableUpdate, int32 TimeOut)
{
UT_GenStub_SetupReturnBuffer(CFE_SB_TransmitBufferWithRoute, CFE_Status_t);

UT_GenStub_AddParam(CFE_SB_TransmitBufferWithRoute, CFE_SB_Buffer_t *, BufPtr);
UT_GenStub_AddParam(CFE_SB_TransmitBufferWithRoute, size_t, ContentSize);
UT_GenStub_AddParam(CFE_SB_TransmitBufferWithRoute, CFE_SB_MsgId_t, RoutingMsgId);
UT_GenStub_AddParam(CFE_SB_TransmitBufferWithRoute, bool, EnableUpdate);
UT_GenStub_AddParam(CFE_SB_TransmitBufferWithRoute, int32, TimeOut);

UT_GenStub_Execute(CFE_SB_TransmitBufferWithRoute, Basic, NULL);

return UT_GenStub_GetReturnValue(CFE_SB_TransmitBufferWithRoute, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for CFE_SB_TransmitMsg()
* ----------------------------------------------------
*/
CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool UpdateHeader)
CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool EnableUpdate)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
UT_GenStub_SetupReturnBuffer(CFE_SB_TransmitMsg, CFE_Status_t);

UT_GenStub_AddParam(CFE_SB_TransmitMsg, const CFE_MSG_Message_t *, MsgPtr);
UT_GenStub_AddParam(CFE_SB_TransmitMsg, bool, UpdateHeader);
UT_GenStub_AddParam(CFE_SB_TransmitMsg, bool, EnableUpdate);

UT_GenStub_Execute(CFE_SB_TransmitMsg, Basic, UT_DefaultHandler_CFE_SB_TransmitMsg);

Expand Down
3 changes: 2 additions & 1 deletion modules/msg/fsw/src/cfe_msg_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ CFE_Status_t CFE_MSG_Init(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId, CFE_M
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_Status_t CFE_MSG_UpdateHeader(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt)
CFE_Status_t CFE_MSG_UpdateHeader(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt, CFE_MSG_Size_t MsgSize)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
if (MsgPtr == NULL)
{
Expand All @@ -69,6 +69,7 @@ CFE_Status_t CFE_MSG_UpdateHeader(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCou

/* Sequence count is in the basic CCSDS Primary Hdr, so all msgs have it */
CFE_MSG_SetSequenceCount(MsgPtr, SeqCnt);
CFE_MSG_SetSize(MsgPtr, MsgSize);

/*
* TLM packets have a timestamp in the secondary header.
Expand Down
6 changes: 3 additions & 3 deletions modules/msg/ut-coverage/test_cfe_msg_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,18 @@ void Test_MSG_UpdateHeader(void)
CheckCnt = 0;

/* bad buffer */
UtAssert_INT32_EQ(CFE_MSG_UpdateHeader(NULL, SeqCnt), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_UpdateHeader(NULL, SeqCnt, sizeof(LocalBuf)), CFE_MSG_BAD_ARGUMENT);

/* nominal, cmd */
CFE_MSG_SetType(&LocalBuf.msg, CFE_MSG_Type_Cmd);
CFE_UtAssert_SUCCESS(CFE_MSG_UpdateHeader(&LocalBuf.msg, SeqCnt));
CFE_UtAssert_SUCCESS(CFE_MSG_UpdateHeader(&LocalBuf.msg, SeqCnt, sizeof(LocalBuf)));
CFE_MSG_GetSequenceCount(&LocalBuf.msg, &CheckCnt);
UtAssert_UINT32_EQ(CheckCnt, SeqCnt);
++SeqCnt;

/* nominal, tlm */
CFE_MSG_SetType(&LocalBuf.msg, CFE_MSG_Type_Tlm);
CFE_UtAssert_SUCCESS(CFE_MSG_UpdateHeader(&LocalBuf.msg, SeqCnt));
CFE_UtAssert_SUCCESS(CFE_MSG_UpdateHeader(&LocalBuf.msg, SeqCnt, sizeof(LocalBuf)));
CFE_MSG_GetSequenceCount(&LocalBuf.msg, &CheckCnt);
UtAssert_UINT32_EQ(CheckCnt, SeqCnt);
++SeqCnt;
Expand Down
Loading

0 comments on commit 9a81cb6

Please sign in to comment.