Skip to content

Commit

Permalink
Merge pull request #2346 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
cFE Integration candidate: Caelum-rc4+dev51
  • Loading branch information
dzbaker authored May 22, 2023
2 parents 4deea95 + 57f4374 commit b429d91
Show file tree
Hide file tree
Showing 26 changed files with 437 additions and 106 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Development Build: v7.0.0-rc4+dev318
- generalize update header parameter
- add msg verify capability
- See <https://github.com/nasa/cFE/pull/2336> and <https://github.com/nasa/cFE/pull/2338>

## Development Build: v7.0.0-rc4+dev312
- adjust UT pool buffer size for platform config
- Remove unused CFE_PLATFORM_ES_RESET_AREA_SIZE
Expand Down
13 changes: 7 additions & 6 deletions modules/cfe_testcase/src/sb_sendrecv_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ void TestBasicTransmitRecv(void)
UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, -100), CFE_SB_BAD_ARGUMENT);

/*
* Note, the CFE_SB_TransmitMsg ignores the "IncrementSequence" flag for commands.
* Thus, all the sequence numbers should come back with the original value set (11)
* Note, the CFE_SB_TransmitMsg now adheres to the "UpdateHeader" 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.
*
* Note this also utilizes the CFE_SB_PEND_FOREVER flag - if working correctly,
* there should be a message in the queue, so it should not block.
Expand All @@ -157,15 +158,15 @@ void TestBasicTransmitRecv(void)
CFE_Assert_MSGID_EQ(MsgId, CFE_FT_CMD_MSGID);
CmdPtr = (const CFE_FT_TestCmdMessage_t *)MsgBuf;
UtAssert_UINT32_EQ(CmdPtr->CmdPayload, 0x0c0ffee);
UtAssert_UINT32_EQ(Seq1, 11);
UtAssert_UINT32_EQ(Seq1, 1);

UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, CFE_SB_PEND_FOREVER), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_MSG_GetMsgId(&MsgBuf->Msg, &MsgId), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&MsgBuf->Msg, &Seq1), CFE_SUCCESS);
CFE_Assert_MSGID_EQ(MsgId, CFE_FT_CMD_MSGID);
CmdPtr = (const CFE_FT_TestCmdMessage_t *)MsgBuf;
UtAssert_UINT32_EQ(CmdPtr->CmdPayload, 0x1c0ffee);
UtAssert_UINT32_EQ(Seq1, 11);
UtAssert_UINT32_EQ(Seq1, 2);

UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, CFE_SB_PEND_FOREVER), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_MSG_GetMsgId(&MsgBuf->Msg, &MsgId), CFE_SUCCESS);
Expand Down Expand Up @@ -480,7 +481,7 @@ void TestZeroCopyTransmitRecv(void)
/* Receive and get initial sequence count */
UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, CFE_SB_POLL), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&MsgBuf->Msg, &SeqCmd1), CFE_SUCCESS);
UtAssert_UINT32_EQ(SeqCmd1, 1234); /* NOTE: commands currently do NOT honor "Increment" flag */
UtAssert_UINT32_EQ(SeqCmd1, 6); /* NOTE: commands now honor "Update" flag */
UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId2, CFE_SB_POLL), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&MsgBuf->Msg, &SeqTlm1), CFE_SUCCESS);

Expand All @@ -497,7 +498,7 @@ void TestZeroCopyTransmitRecv(void)
/* Receive and get current sequence count */
UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, CFE_SB_POLL), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&MsgBuf->Msg, &SeqCmd2), CFE_SUCCESS);
UtAssert_UINT32_EQ(SeqCmd2, 1234); /* NOTE: commands currently do NOT honor "Increment" flag */
UtAssert_UINT32_EQ(SeqCmd2, 7); /* NOTE: commands now honor "Update" flag */
UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId2, CFE_SB_POLL), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&MsgBuf->Msg, &SeqTlm2), CFE_SUCCESS);
UtAssert_UINT32_EQ(SeqTlm2, CFE_MSG_GetNextSequenceCount(SeqTlm1)); /* should be +1 from the previous */
Expand Down
51 changes: 51 additions & 0 deletions modules/core_api/fsw/inc/cfe_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,31 @@
* \retval #CFE_MSG_BAD_ARGUMENT \copybrief CFE_MSG_BAD_ARGUMENT
*/
CFE_Status_t CFE_MSG_Init(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId, CFE_MSG_Size_t Size);

/*****************************************************************************/
/**
* \brief Set/compute all dynamically-updated headers on a message
*
* \par Description
* This routine updates all dynamic header fields on a message, and is typically
* invoked via SB just prior to broadcasting the message. Dynamic headers include
* are values that should be computed/updated per message, including:
* - the sequence number
* - the timestamp, if present
* - any error control or checksum fields, if present
*
* The MSG module implementation determines which header fields meet this criteria
* and how they should be computed.
*
* \param[inout] MsgPtr A pointer to the buffer that contains the message @nonnull.
* \param[in] SeqCnt The current sequence number from the message route
*
* \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);

/**\}*/

/** \defgroup CFEAPIMSGHeaderPri cFE Message Primary Header APIs
Expand Down Expand Up @@ -700,4 +725,30 @@ CFE_Status_t CFE_MSG_GetTypeFromMsgId(CFE_SB_MsgId_t MsgId, CFE_MSG_Type_t *Type

/**\}*/

/** \defgroup CFEAPIMSGMsgVerify cFE Message Checking APIs
* \{
*/
/*****************************************************************************/
/**
* \brief Checks message headers against expected values
*
* \par Description
* This routine validates that any error-control field(s) in the message header
* matches the expected value.
*
* The specific function of this API is entirely dependent on the header fields
* and may be a no-op if no error checking is implemented. In that case, it
* will always output "true".
*
* \param[in] MsgPtr Message Pointer @nonnull
* \param[out] VerifyStatus Output variable to be set to verification result @nonnull
*
* \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_Verify(const CFE_MSG_Message_t *MsgPtr, bool *VerifyStatus);

/**\}*/

#endif /* CFE_MSG_H */
30 changes: 21 additions & 9 deletions modules/core_api/fsw/inc/cfe_sb.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,26 +402,34 @@ 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"
** 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
** parameter should be passed as "false" to not overwrite existing data.
**
** \par Assumptions, External Events, and Notes:
** - This routine will not normally wait for the receiver tasks to
** process the message before returning control to the caller's task.
** - However, if a higher priority task is pending and subscribed to
** this message, that task may get to run before returning
** control to the caller.
** - In previous versions of CFE, the boolean parameter referred to the
** sequence number header of telemetry messages only. This has been
** extended to apply more generically to any headers, as determined by
** the CFE MSG implementation.
**
** \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] IncrementSequenceCount Boolean to increment the internally tracked
** sequence count and update the message if the
** buffer contains a telemetry message
** \param[in] UpdateHeader 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 IncrementSequenceCount);
CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool UpdateHeader);

/*****************************************************************************/
/**
Expand Down Expand Up @@ -536,6 +544,12 @@ 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"
** 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
** parameter should be passed as "false" to not overwrite existing data.
**
** \par Assumptions, External Events, and Notes:
** -# A handle returned by #CFE_SB_AllocateMessageBuffer is "consumed" by
** a _successful_ call to #CFE_SB_TransmitBuffer.
Expand All @@ -553,17 +567,15 @@ CFE_Status_t CFE_SB_ReleaseMessageBuffer(CFE_SB_Buffer_t *BufPtr);
** -# This function will increment and apply the internally tracked
** sequence counter if set to do so.
**
** \param[in] BufPtr A pointer to the buffer to be sent @nonnull.
** \param[in] IncrementSequenceCount Boolean to increment the internally tracked
** sequence count and update the message if the
** buffer contains a telemetry message
** \param[in] BufPtr A pointer to the buffer to be sent @nonnull.
** \param[in] UpdateHeader 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 IncrementSequenceCount);
CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool UpdateHeader);

/** @} */

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 @@ -26,7 +26,7 @@
#define CFE_VERSION_H

/* Development Build Macro Definitions */
#define CFE_BUILD_NUMBER 312 /**< @brief Development: Number of development git commits since CFE_BUILD_BASELINE */
#define CFE_BUILD_NUMBER 318 /**< @brief Development: Number of development git commits since CFE_BUILD_BASELINE */
#define CFE_BUILD_BASELINE "v7.0.0-rc4" /**< @brief Development: Reference git tag for build number */

/* See \ref cfsversions for definitions */
Expand Down
4 changes: 2 additions & 2 deletions modules/core_api/ut-stubs/src/cfe_config_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include "cfe_config.h"
#include "utgenstub.h"

extern void UT_DefaultHandler_CFE_Config_GetObjPointer(void *, UT_EntryKey_t, const UT_StubContext_t *);
extern void UT_DefaultHandler_CFE_Config_GetString(void *, UT_EntryKey_t, const UT_StubContext_t *);
void UT_DefaultHandler_CFE_Config_GetObjPointer(void *, UT_EntryKey_t, const UT_StubContext_t *);
void UT_DefaultHandler_CFE_Config_GetString(void *, UT_EntryKey_t, const UT_StubContext_t *);

/*
* ----------------------------------------------------
Expand Down
43 changes: 43 additions & 0 deletions modules/core_api/ut-stubs/src/cfe_error_stubs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
*
* Copyright (c) 2020 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
************************************************************************/

/**
* @file
*
* Auto-Generated stub implementations for functions defined in cfe_error header
*/

#include "cfe_error.h"
#include "utgenstub.h"

/*
* ----------------------------------------------------
* Generated stub function for CFE_ES_StatusToString()
* ----------------------------------------------------
*/
char *CFE_ES_StatusToString(CFE_Status_t status, CFE_StatusString_t *status_string)
{
UT_GenStub_SetupReturnBuffer(CFE_ES_StatusToString, char *);

UT_GenStub_AddParam(CFE_ES_StatusToString, CFE_Status_t, status);
UT_GenStub_AddParam(CFE_ES_StatusToString, CFE_StatusString_t *, status_string);

UT_GenStub_Execute(CFE_ES_StatusToString, Basic, NULL);

return UT_GenStub_GetReturnValue(CFE_ES_StatusToString, char *);
}
21 changes: 4 additions & 17 deletions modules/core_api/ut-stubs/src/cfe_es_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ CFE_Status_t CFE_ES_AppID_ToIndex(CFE_ES_AppId_t AppID, uint32 *Idx)
*/
void CFE_ES_BackgroundWakeup(void)
{

UT_GenStub_Execute(CFE_ES_BackgroundWakeup, Basic, NULL);
}

Expand Down Expand Up @@ -216,6 +217,7 @@ void CFE_ES_ExitApp(uint32 ExitStatus)
*/
void CFE_ES_ExitChildTask(void)
{

UT_GenStub_Execute(CFE_ES_ExitChildTask, Basic, NULL);
}

Expand Down Expand Up @@ -602,6 +604,7 @@ CFE_Status_t CFE_ES_IncrementGenCounter(CFE_ES_CounterId_t CounterId)
*/
void CFE_ES_IncrementTaskCounter(void)
{

UT_GenStub_Execute(CFE_ES_IncrementTaskCounter, Basic, NULL);
}

Expand Down Expand Up @@ -731,6 +734,7 @@ int32 CFE_ES_PoolDelete(CFE_ES_MemHandle_t PoolID)
*/
void CFE_ES_ProcessAsyncEvent(void)
{

UT_GenStub_Execute(CFE_ES_ProcessAsyncEvent, Basic, NULL);
}

Expand Down Expand Up @@ -950,20 +954,3 @@ CFE_Status_t CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...)

return UT_GenStub_GetReturnValue(CFE_ES_WriteToSysLog, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for CFE_ES_StatusToString()
* ----------------------------------------------------
*/
char *CFE_ES_StatusToString(CFE_Status_t status, CFE_StatusString_t *status_string)
{
UT_GenStub_SetupReturnBuffer(CFE_ES_StatusToString, char *);

UT_GenStub_AddParam(CFE_ES_StatusToString, CFE_Status_t, status);
UT_GenStub_AddParam(CFE_ES_StatusToString, CFE_StatusString_t *, status_string);

UT_GenStub_Execute(CFE_ES_StatusToString, Basic, NULL);

return UT_GenStub_GetReturnValue(CFE_ES_StatusToString, char *);
}
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 @@ -621,6 +621,23 @@ CFE_Status_t CFE_MSG_SetType(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Type_t Type)
return UT_GenStub_GetReturnValue(CFE_MSG_SetType, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for CFE_MSG_UpdateHeader()
* ----------------------------------------------------
*/
CFE_Status_t CFE_MSG_UpdateHeader(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt)
{
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_Execute(CFE_MSG_UpdateHeader, Basic, NULL);

return UT_GenStub_GetReturnValue(CFE_MSG_UpdateHeader, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for CFE_MSG_ValidateChecksum()
Expand Down
8 changes: 4 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 @@ -384,12 +384,12 @@ 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 IncrementSequenceCount)
CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool UpdateHeader)
{
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, IncrementSequenceCount);
UT_GenStub_AddParam(CFE_SB_TransmitBuffer, bool, UpdateHeader);

UT_GenStub_Execute(CFE_SB_TransmitBuffer, Basic, UT_DefaultHandler_CFE_SB_TransmitBuffer);

Expand All @@ -401,12 +401,12 @@ CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool IncrementSequen
* Generated stub function for CFE_SB_TransmitMsg()
* ----------------------------------------------------
*/
CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool IncrementSequenceCount)
CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool UpdateHeader)
{
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, IncrementSequenceCount);
UT_GenStub_AddParam(CFE_SB_TransmitMsg, bool, UpdateHeader);

UT_GenStub_Execute(CFE_SB_TransmitMsg, Basic, UT_DefaultHandler_CFE_SB_TransmitMsg);

Expand Down
2 changes: 2 additions & 0 deletions modules/core_api/ut-stubs/src/cfe_time_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void CFE_TIME_ExternalTime(CFE_TIME_SysTime_t NewTime)
*/
void CFE_TIME_ExternalTone(void)
{

UT_GenStub_Execute(CFE_TIME_ExternalTone, Basic, NULL);
}

Expand Down Expand Up @@ -263,6 +264,7 @@ CFE_TIME_SysTime_t CFE_TIME_GetUTC(void)
*/
void CFE_TIME_Local1HzISR(void)
{

UT_GenStub_Execute(CFE_TIME_Local1HzISR, Basic, NULL);
}

Expand Down
Loading

0 comments on commit b429d91

Please sign in to comment.