Skip to content

Commit

Permalink
Merge pull request nasa#1508 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
cFE Integration candidate: 2021-05-18
  • Loading branch information
astrogeco authored May 19, 2021
2 parents 84ba9a9 + 04974cc commit 8443a46
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 24 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ The detailed cFE user's guide can be viewed at <https://github.com/nasa/cFS/blob

## Version History

### Development Build: v6.8.0-rc1+dev580

- Adds `CFE_MSG_GetNextSequenceCount` so the auto-increment of the local sequence counter works when sending tlm (and increment is enabled). Updates unit tests and adds the old-style stub. The unit tests check for the correct rollover behavior.Sequence count will roll over based on the mask. Before the fix the sequence counter would "stick" in telemetry until the passed in value rolled over.
- [docs] Correctly format code block section terminator so Markdown renders correctly
- [docs] Fix typos in developer guide
- See <https://github.com/nasa/cFE/pull/1508> and <https://github.com/nasa/cFS/pull/259>

### Development Build: v6.8.0-rc1+dev575

- Removes broken travis-ci script
Expand All @@ -21,7 +28,7 @@ a default handler routine.
- [docs] Adds documentation and comments about how the configuration facility works and where to find information on the complete set of options available
- Updates the configuration files in "sample_defs" to reflect only those parameters that are set to a non-default value along with information about why the configurable item is changed.
- Removes --quiet option so files checked go to stdout

- See <https://github.com/nasa/cFE/pull/1492> and <https://github.com/nasa/cFS/pull/256>

### Development Build: v6.8.0-rc1+dev559

Expand Down
8 changes: 4 additions & 4 deletions docs/cFE Application Developers Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,7 @@ one deployment to the next. By using these functions, Applications are
guaranteed to work regardless of the structure of the Message Header.

Although CFE_SB_SetUserDataLength APIs is available,
it is based on assumptions about the defintion of "User Data" and is
it is based on assumptions about the definition of "User Data" and is
really just a best guess since the packet structure is dependent on implementation.
The preference is to use CFE_MSG_SetSize and actual packet structure
information when available.
Expand Down Expand Up @@ -1842,7 +1842,7 @@ CFE_MSG_ValidateChecksum() and it simply returns a success or failure
indication.

Although CFE_SB_GetUserDataLength and CFE_SB_GetUserData APIs are available,
they are based on assumptions about the defintion of "User Data" and are
they are based on assumptions about the definition of "User Data" and are
really just a best guess since the packet structure is dependent on implementation.
The preference is to use the actual packet structure when available.

Expand Down Expand Up @@ -2033,7 +2033,7 @@ SAMPLE_AppData_t SAMPLE_AppData; /* Instantiate Task Data */
/* SAMPLE_AppData.BigPktBuf is no longer a valid pointer */
...
}
```c
```

## 6.9 Best Practices for using Software Bus

Expand Down Expand Up @@ -3210,7 +3210,7 @@ paradigm that allows the Time Services on the processor that has access
to the primary onboard time base to broadcast the current time to Time
Clients. As long as the Time Server has a working communication path to
all Time Clients, the time available to every Application is essentially
the same with neglible errors. When a Time Server and Time Client become
the same with negligible errors. When a Time Server and Time Client become
disconnected from one another, they each do their best to maintain the
current time with what information they have available.

Expand Down
16 changes: 16 additions & 0 deletions modules/core_api/fsw/inc/cfe_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,22 @@ CFE_Status_t CFE_MSG_GetSequenceCount(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_S
*/
CFE_Status_t CFE_MSG_SetSequenceCount(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt);

/*****************************************************************************/
/**
* \brief Gets the next sequence count value (rolls over if appropriate)
*
* \par Description
* Abstract method to get the next valid sequence count value.
* Will roll over to zero for any input value greater than or
* equal to the maximum possible sequence count value given
* the field in the header.
*
* \param[in] SeqCnt Sequence count
*
* \return The next valid sequence count value
*/
CFE_MSG_SequenceCount_t CFE_MSG_GetNextSequenceCount(CFE_MSG_SequenceCount_t SeqCnt);

/*****************************************************************************/
/**
* \brief Gets the message EDS version
Expand Down
2 changes: 1 addition & 1 deletion modules/core_api/fsw/inc/cfe_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define CFE_VERSION_H

/* Development Build Macro Definitions */
#define CFE_BUILD_NUMBER 575 /*!< Development Build: Number of commits since baseline */
#define CFE_BUILD_NUMBER 580 /*!< Development Build: Number of commits since baseline */
#define CFE_BUILD_BASELINE \
"v6.8.0-rc1" /*!< Development Build: git tag that is the base for the current development \
*/
Expand Down
18 changes: 18 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 @@ -360,3 +360,21 @@ void UT_DefaultHandler_CFE_MSG_ValidateChecksum(void *UserObj, UT_EntryKey_t Fun
sizeof(*IsValid));
}
}

/*------------------------------------------------------------
*
* Default handler for CFE_MSG_GetNextSequenceCount coverage stub function
*
*------------------------------------------------------------*/
void UT_DefaultHandler_CFE_MSG_GetNextSequenceCount(void *UserObj, UT_EntryKey_t FuncKey,
const UT_StubContext_t *Context)
{
int32 status;
CFE_MSG_SequenceCount_t return_value;

UT_Stub_GetInt32StatusCode(Context, &status);

return_value = status;

UT_Stub_SetReturnValue(FuncKey, return_value);
}
17 changes: 17 additions & 0 deletions modules/core_api/ut-stubs/src/cfe_msg_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern void UT_DefaultHandler_CFE_MSG_GetHasSecondaryHeader(void *, UT_EntryKey_
extern void UT_DefaultHandler_CFE_MSG_GetHeaderVersion(void *, UT_EntryKey_t, const UT_StubContext_t *);
extern void UT_DefaultHandler_CFE_MSG_GetMsgId(void *, UT_EntryKey_t, const UT_StubContext_t *);
extern void UT_DefaultHandler_CFE_MSG_GetMsgTime(void *, UT_EntryKey_t, const UT_StubContext_t *);
extern void UT_DefaultHandler_CFE_MSG_GetNextSequenceCount(void *, UT_EntryKey_t, const UT_StubContext_t *);
extern void UT_DefaultHandler_CFE_MSG_GetPlaybackFlag(void *, UT_EntryKey_t, const UT_StubContext_t *);
extern void UT_DefaultHandler_CFE_MSG_GetSegmentationFlag(void *, UT_EntryKey_t, const UT_StubContext_t *);
extern void UT_DefaultHandler_CFE_MSG_GetSequenceCount(void *, UT_EntryKey_t, const UT_StubContext_t *);
Expand Down Expand Up @@ -197,6 +198,22 @@ CFE_Status_t CFE_MSG_GetMsgTime(const CFE_MSG_Message_t *MsgPtr, CFE_TIME_SysTim
return UT_GenStub_GetReturnValue(CFE_MSG_GetMsgTime, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for CFE_MSG_GetNextSequenceCount()
* ----------------------------------------------------
*/
CFE_MSG_SequenceCount_t CFE_MSG_GetNextSequenceCount(CFE_MSG_SequenceCount_t SeqCnt)
{
UT_GenStub_SetupReturnBuffer(CFE_MSG_GetNextSequenceCount, CFE_MSG_SequenceCount_t);

UT_GenStub_AddParam(CFE_MSG_GetNextSequenceCount, CFE_MSG_SequenceCount_t, SeqCnt);

UT_GenStub_Execute(CFE_MSG_GetNextSequenceCount, Basic, UT_DefaultHandler_CFE_MSG_GetNextSequenceCount);

return UT_GenStub_GetReturnValue(CFE_MSG_GetNextSequenceCount, CFE_MSG_SequenceCount_t);
}

/*
* ----------------------------------------------------
* Generated stub function for CFE_MSG_GetPlaybackFlag()
Expand Down
20 changes: 20 additions & 0 deletions modules/msg/fsw/src/cfe_msg_ccsdspri.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,26 @@ int32 CFE_MSG_SetSequenceCount(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_
return CFE_SUCCESS;
}

/*----------------------------------------------------------------
*
* Function: CFE_MSG_GetNextSequenceCount
*
* Implemented per public API
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_MSG_SequenceCount_t CFE_MSG_GetNextSequenceCount(CFE_MSG_SequenceCount_t SeqCnt)
{
SeqCnt++;

if (SeqCnt > CFE_MSG_SEQCNT_MASK)
{
SeqCnt = 0;
}

return SeqCnt;
}

/*----------------------------------------------------------------
*
* Function: CFE_MSG_GetSize
Expand Down
19 changes: 14 additions & 5 deletions modules/msg/ut-coverage/test_cfe_msg_ccsdspri.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,13 @@ void Test_MSG_SegmentationFlag(void)

void Test_MSG_SequenceCount(void)
{
CFE_MSG_Message_t msg;
CFE_MSG_ApId_t input[] = {0, TEST_SEQUENCE_MAX / 2, TEST_SEQUENCE_MAX};
CFE_MSG_ApId_t actual = TEST_SEQUENCE_MAX;
int i;
CFE_MSG_Message_t msg;
const CFE_MSG_SequenceCount_t input[] = {0, TEST_SEQUENCE_MAX / 2, TEST_SEQUENCE_MAX};
CFE_MSG_SequenceCount_t actual = TEST_SEQUENCE_MAX;
CFE_MSG_SequenceCount_t maxsc;
int i;

memset(&maxsc, 0xFF, sizeof(maxsc));

UtPrintf("Bad parameter tests, Null pointers and invalid (max valid + 1, max)");
memset(&msg, 0, sizeof(msg));
Expand All @@ -410,7 +413,7 @@ void Test_MSG_SequenceCount(void)
ASSERT_EQ(CFE_MSG_SetSequenceCount(NULL, input[0]), CFE_MSG_BAD_ARGUMENT);
ASSERT_EQ(CFE_MSG_SetSequenceCount(&msg, TEST_SEQUENCE_MAX + 1), CFE_MSG_BAD_ARGUMENT);
ASSERT_EQ(Test_MSG_NotZero(&msg), 0);
ASSERT_EQ(CFE_MSG_SetSequenceCount(&msg, 0xFFFF), CFE_MSG_BAD_ARGUMENT);
ASSERT_EQ(CFE_MSG_SetSequenceCount(&msg, maxsc), CFE_MSG_BAD_ARGUMENT);
ASSERT_EQ(Test_MSG_NotZero(&msg), 0);

UtPrintf("Set to all F's, various valid inputs");
Expand Down Expand Up @@ -452,6 +455,12 @@ void Test_MSG_SequenceCount(void)
ASSERT_EQ(Test_MSG_NotZero(&msg), MSG_SEQUENCE_FLAG);
}
}

UtPrintf("Fully exercise getting next sequence count");
ASSERT_EQ(CFE_MSG_GetNextSequenceCount(0), 1);
ASSERT_EQ(CFE_MSG_GetNextSequenceCount(TEST_SEQUENCE_MAX / 2), (TEST_SEQUENCE_MAX / 2) + 1);
ASSERT_EQ(CFE_MSG_GetNextSequenceCount(TEST_SEQUENCE_MAX), 0);
ASSERT_EQ(CFE_MSG_GetNextSequenceCount(maxsc), 0);
}

/*
Expand Down
25 changes: 21 additions & 4 deletions modules/sb/ut-coverage/sb_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -2820,7 +2820,7 @@ void Test_TransmitMsg_BasicSend(void)

} /* end Test_TransmitMsg_BasicSend */

/* Sequence count hook */
/* Set sequence count hook */
static int32 UT_CheckSetSequenceCount(void *UserObj, int32 StubRetcode, uint32 CallCount,
const UT_StubContext_t *Context)
{
Expand All @@ -2843,54 +2843,70 @@ void Test_TransmitMsg_SequenceCount(void)
CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm;
uint32 PipeDepth = 10;
CFE_MSG_SequenceCount_t SeqCnt;
CFE_MSG_SequenceCount_t SeqCntExpected;

/* Set up hook for checking CFE_MSG_SetSequenceCount calls */
UT_SetHookFunction(UT_KEY(CFE_MSG_SetSequenceCount), UT_CheckSetSequenceCount, &SeqCnt);

SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "SeqCntTestPipe"));
SETUP(CFE_SB_Subscribe(MsgId, PipeId));

/* Note the Sequence count value doesn't really matter, just set unique to confirm use */
SeqCntExpected = 1;
UT_SetDefaultReturnValue(UT_KEY(CFE_MSG_GetNextSequenceCount), SeqCntExpected);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false);

SETUP(CFE_SB_TransmitMsg(&TlmPkt.Hdr.Msg, true));
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_SetSequenceCount)), 1);
ASSERT_EQ(SeqCnt, 1);
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_GetNextSequenceCount)), 1);
ASSERT_EQ(SeqCnt, SeqCntExpected);

UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false);
ASSERT(CFE_SB_TransmitMsg(&TlmPkt.Hdr.Msg, false));

/* Assert sequence count wasn't set */
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_GetNextSequenceCount)), 1);
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_SetSequenceCount)), 1);

SeqCntExpected = 2;
UT_SetDefaultReturnValue(UT_KEY(CFE_MSG_GetNextSequenceCount), SeqCntExpected);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false);
ASSERT(CFE_SB_TransmitMsg(&TlmPkt.Hdr.Msg, true));
ASSERT_EQ(SeqCnt, 2);
ASSERT_EQ(SeqCnt, SeqCntExpected);
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_SetSequenceCount)), 2);
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_GetNextSequenceCount)), 2);

EVTCNT(2);
EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID);

SETUP(CFE_SB_Unsubscribe(MsgId, PipeId)); /* should have no subscribers now */

SeqCntExpected = 3;
UT_SetDefaultReturnValue(UT_KEY(CFE_MSG_GetNextSequenceCount), SeqCntExpected);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false);
SETUP(CFE_SB_TransmitMsg(&TlmPkt.Hdr.Msg, true)); /* increment to 3 */
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_SetSequenceCount)), 3);
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_GetNextSequenceCount)), 3);

SETUP(CFE_SB_Subscribe(MsgId, PipeId)); /* resubscribe so we can receive a msg */

SeqCntExpected = 4;
UT_SetDefaultReturnValue(UT_KEY(CFE_MSG_GetNextSequenceCount), SeqCntExpected);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false);
SETUP(CFE_SB_TransmitMsg(&TlmPkt.Hdr.Msg, true)); /* increment to 4 */
ASSERT_EQ(SeqCnt, 4);
ASSERT_EQ(SeqCnt, SeqCntExpected);
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_SetSequenceCount)), 4);
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_GetNextSequenceCount)), 4);

TEARDOWN(CFE_SB_DeletePipe(PipeId));

Expand Down Expand Up @@ -3135,6 +3151,7 @@ void Test_TransmitBuffer_IncrementSeqCnt(void)
UtAssert_Failed("Unexpected NULL pointer returned from ZeroCopyGetPtr");
}

UT_SetDefaultReturnValue(UT_KEY(CFE_MSG_GetNextSequenceCount), 1);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false);
Expand Down
6 changes: 5 additions & 1 deletion modules/sbr/fsw/src/cfe_sbr_route_unsorted.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <string.h>

#include "cfe_sb.h"
#include "cfe_msg.h"

/******************************************************************************
* Type Definitions
Expand Down Expand Up @@ -182,9 +183,12 @@ void CFE_SBR_SetDestListHeadPtr(CFE_SBR_RouteId_t RouteId, CFE_SB_DestinationD_t
*-----------------------------------------------------------------*/
void CFE_SBR_IncrementSequenceCounter(CFE_SBR_RouteId_t RouteId)
{
CFE_MSG_SequenceCount_t *cnt;

if (CFE_SBR_IsValidRouteId(RouteId))
{
CFE_SBR_RDATA.RoutingTbl[CFE_SBR_RouteIdToValue(RouteId)].SeqCnt++;
cnt = &CFE_SBR_RDATA.RoutingTbl[CFE_SBR_RouteIdToValue(RouteId)].SeqCnt;
*cnt = CFE_MSG_GetNextSequenceCount(*cnt);
}
}

Expand Down
21 changes: 13 additions & 8 deletions modules/sbr/ut-coverage/test_cfe_sbr_route_unsorted.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ void Test_SBR_Route_Unsort_General(void)
void Test_SBR_Route_Unsort_GetSet(void)
{

CFE_SB_RouteId_Atom_t routeidx;
CFE_SB_MsgId_t msgid[3];
CFE_SBR_RouteId_t routeid[3];
CFE_SB_DestinationD_t dest[2];
uint32 count;
uint32 i;
CFE_SB_RouteId_Atom_t routeidx;
CFE_SB_MsgId_t msgid[3];
CFE_SBR_RouteId_t routeid[3];
CFE_SB_DestinationD_t dest[2];
CFE_MSG_SequenceCount_t seqcntexpected[] = {1, 2};
uint32 count;
uint32 i;

UtPrintf("Invalid route ID checks");
routeid[0] = CFE_SBR_INVALID_ROUTE_ID;
Expand Down Expand Up @@ -167,20 +168,24 @@ void Test_SBR_Route_Unsort_GetSet(void)
}

/* Check the msgid matches and increment a sequence counter */
UT_SetDefaultReturnValue(UT_KEY(CFE_MSG_GetNextSequenceCount), seqcntexpected[0]);
for (i = 0; i < 3; i++)
{
ASSERT_TRUE(CFE_SB_MsgId_Equal(msgid[i], CFE_SBR_GetMsgId(routeid[i])));
CFE_SBR_IncrementSequenceCounter(routeid[0]);
}
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_GetNextSequenceCount)), 3);

/* Increment route 1 once and set dest pointers */
UT_SetDefaultReturnValue(UT_KEY(CFE_MSG_GetNextSequenceCount), seqcntexpected[1]);
CFE_SBR_IncrementSequenceCounter(routeid[1]);
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_GetNextSequenceCount)), 4);
CFE_SBR_SetDestListHeadPtr(routeid[1], &dest[1]);
CFE_SBR_SetDestListHeadPtr(routeid[2], &dest[0]);

UtPrintf("Verify remaining set values");
ASSERT_EQ(CFE_SBR_GetSequenceCounter(routeid[0]), 3);
ASSERT_EQ(CFE_SBR_GetSequenceCounter(routeid[1]), 1);
ASSERT_EQ(CFE_SBR_GetSequenceCounter(routeid[0]), seqcntexpected[0]);
ASSERT_EQ(CFE_SBR_GetSequenceCounter(routeid[1]), seqcntexpected[1]);
ASSERT_EQ(CFE_SBR_GetSequenceCounter(routeid[2]), 0);
UtAssert_ADDRESS_EQ(CFE_SBR_GetDestListHeadPtr(routeid[0]), NULL);
UtAssert_ADDRESS_EQ(CFE_SBR_GetDestListHeadPtr(routeid[1]), &dest[1]);
Expand Down

0 comments on commit 8443a46

Please sign in to comment.