@@ -142,24 +142,27 @@ void TestBasicTransmitRecv(void)
142142 /*
143143 * Note, the CFE_SB_TransmitMsg ignores the "IncrementSequence" flag for commands.
144144 * Thus, all the sequence numbers should come back with the original value set (11)
145+ *
146+ * Note this also utilizes the CFE_SB_PEND_FOREVER flag - if working correctly,
147+ * there should be a message in the queue, so it should not block.
145148 */
146- UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId1 , 100 ), CFE_SUCCESS );
149+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId1 , CFE_SB_PEND_FOREVER ), CFE_SUCCESS );
147150 UtAssert_INT32_EQ (CFE_MSG_GetMsgId (& MsgBuf -> Msg , & MsgId ), CFE_SUCCESS );
148151 UtAssert_INT32_EQ (CFE_MSG_GetSequenceCount (& MsgBuf -> Msg , & Seq1 ), CFE_SUCCESS );
149152 CFE_UtAssert_MSGID_EQ (MsgId , CFE_FT_CMD_MSGID );
150153 CmdPtr = (const CFE_FT_TestCmdMessage_t * )MsgBuf ;
151154 UtAssert_UINT32_EQ (CmdPtr -> CmdPayload , 0x0c0ffee );
152155 UtAssert_UINT32_EQ (Seq1 , 11 );
153156
154- UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId1 , 100 ), CFE_SUCCESS );
157+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId1 , CFE_SB_PEND_FOREVER ), CFE_SUCCESS );
155158 UtAssert_INT32_EQ (CFE_MSG_GetMsgId (& MsgBuf -> Msg , & MsgId ), CFE_SUCCESS );
156159 UtAssert_INT32_EQ (CFE_MSG_GetSequenceCount (& MsgBuf -> Msg , & Seq1 ), CFE_SUCCESS );
157160 CFE_UtAssert_MSGID_EQ (MsgId , CFE_FT_CMD_MSGID );
158161 CmdPtr = (const CFE_FT_TestCmdMessage_t * )MsgBuf ;
159162 UtAssert_UINT32_EQ (CmdPtr -> CmdPayload , 0x1c0ffee );
160163 UtAssert_UINT32_EQ (Seq1 , 11 );
161164
162- UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId1 , 100 ), CFE_SUCCESS );
165+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId1 , CFE_SB_PEND_FOREVER ), CFE_SUCCESS );
163166 UtAssert_INT32_EQ (CFE_MSG_GetMsgId (& MsgBuf -> Msg , & MsgId ), CFE_SUCCESS );
164167 UtAssert_INT32_EQ (CFE_MSG_GetSequenceCount (& MsgBuf -> Msg , & Seq1 ), CFE_SUCCESS );
165168 CFE_UtAssert_MSGID_EQ (MsgId , CFE_FT_CMD_MSGID );
@@ -168,6 +171,7 @@ void TestBasicTransmitRecv(void)
168171 UtAssert_UINT32_EQ (Seq1 , 11 );
169172
170173 /* Final should not be in the pipe, should have been rejected due to MsgLim */
174+ /* Must not use CFE_SB_PEND_FOREVER here, as this will cause the test to block */
171175 UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId1 , 100 ), CFE_SB_TIME_OUT );
172176
173177 /*
@@ -205,15 +209,179 @@ void TestBasicTransmitRecv(void)
205209 UtAssert_INT32_EQ (CFE_SB_DeletePipe (PipeId2 ), CFE_SUCCESS );
206210}
207211
212+ /*
213+ * Test distribution/broadcasting features (MsgLimit/PipeDepth enforcement, etc)
214+ *
215+ * Important to verify that although some receive pipes may have errors/limits, it should not affect
216+ * the transmit side nor should it affect delivery to pipes that do not have limit errors.
217+ */
218+ void TestMsgBroadcast (void )
219+ {
220+ CFE_SB_PipeId_t PipeId1 ;
221+ CFE_SB_PipeId_t PipeId2 ;
222+ CFE_SB_PipeId_t PipeId3 ;
223+ CFE_SB_PipeId_t PipeId4 ;
224+ CFE_FT_TestCmdMessage_t CmdMsg ;
225+ CFE_SB_MsgId_t MsgId ;
226+ CFE_SB_Buffer_t * MsgBuf1 ;
227+ CFE_SB_Buffer_t * MsgBuf2 ;
228+ CFE_SB_Buffer_t * MsgBuf3 ;
229+ CFE_SB_Buffer_t * MsgBuf4 ;
230+ const CFE_FT_TestCmdMessage_t * CmdPtr ;
231+
232+ UtPrintf ("Testing: MsgLimit enforcement" );
233+
234+ /* Setup - subscribe same MsgId to multiple different pipes with different limits */
235+ UtAssert_INT32_EQ (CFE_SB_CreatePipe (& PipeId1 , 3 , "TestPipe1" ), CFE_SUCCESS );
236+ UtAssert_INT32_EQ (CFE_SB_CreatePipe (& PipeId2 , 3 , "TestPipe2" ), CFE_SUCCESS );
237+ UtAssert_INT32_EQ (CFE_SB_CreatePipe (& PipeId3 , 3 , "TestPipe3" ), CFE_SUCCESS );
238+ UtAssert_INT32_EQ (CFE_SB_CreatePipe (& PipeId4 , 5 , "TestPipe4" ), CFE_SUCCESS );
239+ UtAssert_INT32_EQ (CFE_SB_SubscribeEx (CFE_FT_CMD_MSGID , PipeId1 , CFE_SB_DEFAULT_QOS , 1 ), CFE_SUCCESS );
240+ UtAssert_INT32_EQ (CFE_SB_SubscribeEx (CFE_FT_CMD_MSGID , PipeId2 , CFE_SB_DEFAULT_QOS , 2 ), CFE_SUCCESS );
241+ UtAssert_INT32_EQ (CFE_SB_SubscribeEx (CFE_FT_CMD_MSGID , PipeId3 , CFE_SB_DEFAULT_QOS , 4 ), CFE_SUCCESS );
242+ UtAssert_INT32_EQ (CFE_SB_SubscribeEx (CFE_FT_CMD_MSGID , PipeId4 , CFE_SB_DEFAULT_QOS , 6 ), CFE_SUCCESS );
243+
244+ /* Initialize the message content */
245+ UtAssert_INT32_EQ (CFE_MSG_Init (& CmdMsg .CmdHeader .Msg , CFE_FT_CMD_MSGID , sizeof (CmdMsg )), CFE_SUCCESS );
246+
247+ /* Make unique content in each message. Sending should always be successful. */
248+ CmdMsg .CmdPayload = 0xbabb1e00 ;
249+ UtAssert_INT32_EQ (CFE_SB_TransmitMsg (& CmdMsg .CmdHeader .Msg , true), CFE_SUCCESS );
250+ CmdMsg .CmdPayload = 0xbabb1e01 ;
251+ UtAssert_INT32_EQ (CFE_SB_TransmitMsg (& CmdMsg .CmdHeader .Msg , true), CFE_SUCCESS );
252+ CmdMsg .CmdPayload = 0xbabb1e02 ;
253+ UtAssert_INT32_EQ (CFE_SB_TransmitMsg (& CmdMsg .CmdHeader .Msg , true), CFE_SUCCESS );
254+ CmdMsg .CmdPayload = 0xbabb1e03 ;
255+ UtAssert_INT32_EQ (CFE_SB_TransmitMsg (& CmdMsg .CmdHeader .Msg , true), CFE_SUCCESS );
256+
257+ /* Now receive 1st message from Pipes, actual msg should appear on all (no limit violations here) */
258+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf1 , PipeId1 , CFE_SB_POLL ), CFE_SUCCESS );
259+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf2 , PipeId2 , CFE_SB_POLL ), CFE_SUCCESS );
260+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf3 , PipeId3 , CFE_SB_POLL ), CFE_SUCCESS );
261+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf4 , PipeId4 , CFE_SB_POLL ), CFE_SUCCESS );
262+
263+ /* All pipes should have gotten the same actual buffer */
264+ UtAssert_ADDRESS_EQ (MsgBuf1 , MsgBuf2 );
265+ UtAssert_ADDRESS_EQ (MsgBuf1 , MsgBuf3 );
266+ UtAssert_ADDRESS_EQ (MsgBuf1 , MsgBuf4 );
267+
268+ /* Confirm content */
269+ UtAssert_INT32_EQ (CFE_MSG_GetMsgId (& MsgBuf1 -> Msg , & MsgId ), CFE_SUCCESS );
270+ CFE_UtAssert_MSGID_EQ (MsgId , CFE_FT_CMD_MSGID );
271+ CmdPtr = (const CFE_FT_TestCmdMessage_t * )MsgBuf1 ;
272+ UtAssert_UINT32_EQ (CmdPtr -> CmdPayload , 0xbabb1e00 );
273+
274+ /* Now receive 2nd message from Pipes, should not appear on PipeId 1 due to MsgLimit */
275+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf1 , PipeId1 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
276+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf2 , PipeId2 , CFE_SB_POLL ), CFE_SUCCESS );
277+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf3 , PipeId3 , CFE_SB_POLL ), CFE_SUCCESS );
278+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf4 , PipeId4 , CFE_SB_POLL ), CFE_SUCCESS );
279+
280+ /* All pipes should have gotten the same actual buffer */
281+ UtAssert_ADDRESS_EQ (MsgBuf2 , MsgBuf3 );
282+ UtAssert_ADDRESS_EQ (MsgBuf2 , MsgBuf4 );
283+
284+ /* Confirm content */
285+ UtAssert_INT32_EQ (CFE_MSG_GetMsgId (& MsgBuf2 -> Msg , & MsgId ), CFE_SUCCESS );
286+ CFE_UtAssert_MSGID_EQ (MsgId , CFE_FT_CMD_MSGID );
287+ CmdPtr = (const CFE_FT_TestCmdMessage_t * )MsgBuf2 ;
288+ UtAssert_UINT32_EQ (CmdPtr -> CmdPayload , 0xbabb1e01 );
289+
290+ /* Now receive 3rd message from Pipes, should not appear on PipeId 1 or 2 due to MsgLimit */
291+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf1 , PipeId1 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
292+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf2 , PipeId2 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
293+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf3 , PipeId3 , CFE_SB_POLL ), CFE_SUCCESS );
294+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf4 , PipeId4 , CFE_SB_POLL ), CFE_SUCCESS );
295+
296+ /* All pipes should have gotten the same actual buffer */
297+ UtAssert_ADDRESS_EQ (MsgBuf3 , MsgBuf4 );
298+
299+ /* Confirm content */
300+ UtAssert_INT32_EQ (CFE_MSG_GetMsgId (& MsgBuf3 -> Msg , & MsgId ), CFE_SUCCESS );
301+ CFE_UtAssert_MSGID_EQ (MsgId , CFE_FT_CMD_MSGID );
302+ CmdPtr = (const CFE_FT_TestCmdMessage_t * )MsgBuf3 ;
303+ UtAssert_UINT32_EQ (CmdPtr -> CmdPayload , 0xbabb1e02 );
304+
305+ /* Now receive 4th message from Pipes, should only appear on PipeId4 due PipeDepth limit on 3 */
306+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf1 , PipeId1 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
307+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf2 , PipeId2 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
308+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf3 , PipeId3 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
309+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf4 , PipeId4 , CFE_SB_POLL ), CFE_SUCCESS );
310+
311+ /* Confirm content */
312+ UtAssert_INT32_EQ (CFE_MSG_GetMsgId (& MsgBuf4 -> Msg , & MsgId ), CFE_SUCCESS );
313+ CFE_UtAssert_MSGID_EQ (MsgId , CFE_FT_CMD_MSGID );
314+ CmdPtr = (const CFE_FT_TestCmdMessage_t * )MsgBuf4 ;
315+ UtAssert_UINT32_EQ (CmdPtr -> CmdPayload , 0xbabb1e03 );
316+
317+ UtPrintf ("Testing: Unsubscribe single pipe" );
318+
319+ /* Now unsubscribe only one of the pipes, and confirm no messages delivered to that pipe */
320+ UtAssert_INT32_EQ (CFE_SB_Unsubscribe (CFE_FT_CMD_MSGID , PipeId2 ), CFE_SUCCESS );
321+
322+ /* Send two more messages */
323+ CmdMsg .CmdPayload = 0xbabb1e04 ;
324+ UtAssert_INT32_EQ (CFE_SB_TransmitMsg (& CmdMsg .CmdHeader .Msg , true), CFE_SUCCESS );
325+ CmdMsg .CmdPayload = 0xbabb1e05 ;
326+ UtAssert_INT32_EQ (CFE_SB_TransmitMsg (& CmdMsg .CmdHeader .Msg , true), CFE_SUCCESS );
327+
328+ /* poll all pipes again, message should appear on all except PipeId2 (Unsubscribed) */
329+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf1 , PipeId1 , CFE_SB_POLL ), CFE_SUCCESS );
330+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf2 , PipeId2 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
331+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf3 , PipeId3 , CFE_SB_POLL ), CFE_SUCCESS );
332+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf4 , PipeId4 , CFE_SB_POLL ), CFE_SUCCESS );
333+
334+ /* All pipes should have gotten the same actual buffer */
335+ UtAssert_ADDRESS_EQ (MsgBuf1 , MsgBuf3 );
336+ UtAssert_ADDRESS_EQ (MsgBuf1 , MsgBuf4 );
337+
338+ /* Confirm content */
339+ UtAssert_INT32_EQ (CFE_MSG_GetMsgId (& MsgBuf1 -> Msg , & MsgId ), CFE_SUCCESS );
340+ CFE_UtAssert_MSGID_EQ (MsgId , CFE_FT_CMD_MSGID );
341+ CmdPtr = (const CFE_FT_TestCmdMessage_t * )MsgBuf1 ;
342+ UtAssert_UINT32_EQ (CmdPtr -> CmdPayload , 0xbabb1e04 );
343+
344+ /* poll all pipes again, message should appear on all except PipeId1 (MsgLim) or PipeId2 (Unsubscribed) */
345+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf1 , PipeId1 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
346+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf2 , PipeId2 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
347+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf3 , PipeId3 , CFE_SB_POLL ), CFE_SUCCESS );
348+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf4 , PipeId4 , CFE_SB_POLL ), CFE_SUCCESS );
349+
350+ /* All pipes should have gotten the same actual buffer */
351+ UtAssert_ADDRESS_EQ (MsgBuf3 , MsgBuf4 );
352+
353+ /* Confirm content */
354+ UtAssert_INT32_EQ (CFE_MSG_GetMsgId (& MsgBuf3 -> Msg , & MsgId ), CFE_SUCCESS );
355+ CFE_UtAssert_MSGID_EQ (MsgId , CFE_FT_CMD_MSGID );
356+ CmdPtr = (const CFE_FT_TestCmdMessage_t * )MsgBuf3 ;
357+ UtAssert_UINT32_EQ (CmdPtr -> CmdPayload , 0xbabb1e05 );
358+
359+ /* poll all pipes again, all should be empty now */
360+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf1 , PipeId1 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
361+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf2 , PipeId2 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
362+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf3 , PipeId3 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
363+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf4 , PipeId4 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
364+
365+ /* Cleanup */
366+ UtAssert_INT32_EQ (CFE_SB_DeletePipe (PipeId1 ), CFE_SUCCESS );
367+ UtAssert_INT32_EQ (CFE_SB_DeletePipe (PipeId2 ), CFE_SUCCESS );
368+ UtAssert_INT32_EQ (CFE_SB_DeletePipe (PipeId3 ), CFE_SUCCESS );
369+ UtAssert_INT32_EQ (CFE_SB_DeletePipe (PipeId4 ), CFE_SUCCESS );
370+ }
371+
208372/* This is a variant of the message transmit API that does not copy */
209373void TestZeroCopyTransmitRecv (void )
210374{
211- CFE_SB_PipeId_t PipeId1 ;
212- CFE_SB_PipeId_t PipeId2 ;
213- CFE_SB_Buffer_t * CmdBuf ;
214- CFE_SB_Buffer_t * TlmBuf ;
215- CFE_SB_Buffer_t * MsgBuf ;
216- CFE_SB_MsgId_t MsgId ;
375+ CFE_SB_PipeId_t PipeId1 ;
376+ CFE_SB_PipeId_t PipeId2 ;
377+ CFE_SB_Buffer_t * CmdBuf ;
378+ CFE_SB_Buffer_t * TlmBuf ;
379+ CFE_SB_Buffer_t * MsgBuf ;
380+ CFE_SB_MsgId_t MsgId ;
381+ CFE_MSG_SequenceCount_t SeqCmd1 ;
382+ CFE_MSG_SequenceCount_t SeqTlm1 ;
383+ CFE_MSG_SequenceCount_t SeqCmd2 ;
384+ CFE_MSG_SequenceCount_t SeqTlm2 ;
217385
218386 /* Setup, create a pipe and subscribe (one cmd, one tlm) */
219387 UtAssert_INT32_EQ (CFE_SB_CreatePipe (& PipeId1 , 5 , "TestPipe1" ), CFE_SUCCESS );
@@ -290,6 +458,61 @@ void TestZeroCopyTransmitRecv(void)
290458 UtAssert_ADDRESS_EQ (MsgBuf , CmdBuf ); /* should be the same actual buffer (not a copy) */
291459 UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId1 , CFE_SB_POLL ), CFE_SB_NO_MESSAGE );
292460
461+ UtPrintf ("Testing: CFE_SB_TransmitBuffer sequence number updates" );
462+
463+ /* Send a set of messages with and without sequence number update flag */
464+ UtAssert_NOT_NULL (CmdBuf = CFE_SB_AllocateMessageBuffer (sizeof (CFE_FT_TestCmdMessage_t )));
465+ UtAssert_NOT_NULL (TlmBuf = CFE_SB_AllocateMessageBuffer (sizeof (CFE_FT_TestTlmMessage_t )));
466+ UtAssert_INT32_EQ (CFE_MSG_Init (& CmdBuf -> Msg , CFE_FT_CMD_MSGID , sizeof (CFE_FT_TestCmdMessage_t )), CFE_SUCCESS );
467+ UtAssert_INT32_EQ (CFE_MSG_Init (& TlmBuf -> Msg , CFE_FT_TLM_MSGID , sizeof (CFE_FT_TestTlmMessage_t )), CFE_SUCCESS );
468+ UtAssert_INT32_EQ (CFE_MSG_SetSequenceCount (& CmdBuf -> Msg , 1234 ), CFE_SUCCESS );
469+ UtAssert_INT32_EQ (CFE_MSG_SetSequenceCount (& TlmBuf -> Msg , 5678 ), CFE_SUCCESS );
470+ UtAssert_INT32_EQ (CFE_SB_TransmitBuffer (CmdBuf , true), CFE_SUCCESS );
471+ UtAssert_INT32_EQ (CFE_SB_TransmitBuffer (TlmBuf , true), CFE_SUCCESS );
472+
473+ /* Receive and get initial sequence count */
474+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId1 , CFE_SB_POLL ), CFE_SUCCESS );
475+ UtAssert_INT32_EQ (CFE_MSG_GetSequenceCount (& MsgBuf -> Msg , & SeqCmd1 ), CFE_SUCCESS );
476+ UtAssert_UINT32_EQ (SeqCmd1 , 1234 ); /* NOTE: commands currently do NOT honor "Increment" flag */
477+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId2 , CFE_SB_POLL ), CFE_SUCCESS );
478+ UtAssert_INT32_EQ (CFE_MSG_GetSequenceCount (& MsgBuf -> Msg , & SeqTlm1 ), CFE_SUCCESS );
479+
480+ /* Send a second message also with increment = true and confirm value */
481+ UtAssert_NOT_NULL (CmdBuf = CFE_SB_AllocateMessageBuffer (sizeof (CFE_FT_TestCmdMessage_t )));
482+ UtAssert_NOT_NULL (TlmBuf = CFE_SB_AllocateMessageBuffer (sizeof (CFE_FT_TestTlmMessage_t )));
483+ UtAssert_INT32_EQ (CFE_MSG_Init (& CmdBuf -> Msg , CFE_FT_CMD_MSGID , sizeof (CFE_FT_TestCmdMessage_t )), CFE_SUCCESS );
484+ UtAssert_INT32_EQ (CFE_MSG_Init (& TlmBuf -> Msg , CFE_FT_TLM_MSGID , sizeof (CFE_FT_TestTlmMessage_t )), CFE_SUCCESS );
485+ UtAssert_INT32_EQ (CFE_MSG_SetSequenceCount (& CmdBuf -> Msg , 1234 ), CFE_SUCCESS );
486+ UtAssert_INT32_EQ (CFE_MSG_SetSequenceCount (& TlmBuf -> Msg , 5678 ), CFE_SUCCESS );
487+ UtAssert_INT32_EQ (CFE_SB_TransmitBuffer (CmdBuf , true), CFE_SUCCESS );
488+ UtAssert_INT32_EQ (CFE_SB_TransmitBuffer (TlmBuf , true), CFE_SUCCESS );
489+
490+ /* Receive and get current sequence count */
491+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId1 , CFE_SB_POLL ), CFE_SUCCESS );
492+ UtAssert_INT32_EQ (CFE_MSG_GetSequenceCount (& MsgBuf -> Msg , & SeqCmd2 ), CFE_SUCCESS );
493+ UtAssert_UINT32_EQ (SeqCmd2 , 1234 ); /* NOTE: commands currently do NOT honor "Increment" flag */
494+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId2 , CFE_SB_POLL ), CFE_SUCCESS );
495+ UtAssert_INT32_EQ (CFE_MSG_GetSequenceCount (& MsgBuf -> Msg , & SeqTlm2 ), CFE_SUCCESS );
496+ UtAssert_UINT32_EQ (SeqTlm2 , CFE_MSG_GetNextSequenceCount (SeqTlm1 )); /* should be +1 from the previous */
497+
498+ /* Send a third message also with increment = false and confirm value */
499+ UtAssert_NOT_NULL (CmdBuf = CFE_SB_AllocateMessageBuffer (sizeof (CFE_FT_TestCmdMessage_t )));
500+ UtAssert_NOT_NULL (TlmBuf = CFE_SB_AllocateMessageBuffer (sizeof (CFE_FT_TestTlmMessage_t )));
501+ UtAssert_INT32_EQ (CFE_MSG_Init (& CmdBuf -> Msg , CFE_FT_CMD_MSGID , sizeof (CFE_FT_TestCmdMessage_t )), CFE_SUCCESS );
502+ UtAssert_INT32_EQ (CFE_MSG_Init (& TlmBuf -> Msg , CFE_FT_TLM_MSGID , sizeof (CFE_FT_TestTlmMessage_t )), CFE_SUCCESS );
503+ UtAssert_INT32_EQ (CFE_MSG_SetSequenceCount (& CmdBuf -> Msg , 1234 ), CFE_SUCCESS );
504+ UtAssert_INT32_EQ (CFE_MSG_SetSequenceCount (& TlmBuf -> Msg , 5678 ), CFE_SUCCESS );
505+ UtAssert_INT32_EQ (CFE_SB_TransmitBuffer (CmdBuf , false), CFE_SUCCESS );
506+ UtAssert_INT32_EQ (CFE_SB_TransmitBuffer (TlmBuf , false), CFE_SUCCESS );
507+
508+ /* Receive and get sequence count, should NOT be incremented from previous */
509+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId1 , CFE_SB_POLL ), CFE_SUCCESS );
510+ UtAssert_INT32_EQ (CFE_MSG_GetSequenceCount (& MsgBuf -> Msg , & SeqCmd1 ), CFE_SUCCESS );
511+ UtAssert_UINT32_EQ (SeqCmd1 , 1234 ); /* should match initialized value */
512+ UtAssert_INT32_EQ (CFE_SB_ReceiveBuffer (& MsgBuf , PipeId2 , CFE_SB_POLL ), CFE_SUCCESS );
513+ UtAssert_INT32_EQ (CFE_MSG_GetSequenceCount (& MsgBuf -> Msg , & SeqTlm1 ), CFE_SUCCESS );
514+ UtAssert_UINT32_EQ (SeqTlm1 , 5678 ); /* should match initialized value */
515+
293516 /* Cleanup */
294517 UtAssert_INT32_EQ (CFE_SB_DeletePipe (PipeId1 ), CFE_SUCCESS );
295518 UtAssert_INT32_EQ (CFE_SB_DeletePipe (PipeId2 ), CFE_SUCCESS );
@@ -371,5 +594,6 @@ void SBSendRecvTestSetup(void)
371594{
372595 UtTest_Add (TestBasicTransmitRecv , NULL , NULL , "Test Basic Transmit/Receive" );
373596 UtTest_Add (TestZeroCopyTransmitRecv , NULL , NULL , "Test Zero Copy Transmit/Receive" );
597+ UtTest_Add (TestMsgBroadcast , NULL , NULL , "Test Msg Broadcast" );
374598 UtTest_Add (TestMiscMessageUtils , NULL , NULL , "Test Miscellaneous Message Utility APIs" );
375- }
599+ }
0 commit comments