From 8786265d1cb81d6206507d2c956a2c951407bf35 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 18 May 2023 10:42:44 -0400 Subject: [PATCH 1/3] Fix #2337, add msg verify capability Adds a "verify" API to the msg module. This always returns success in the default implementation, because checksums were not historically enforced. However it can be made more strict in a custom implementation. --- modules/core_api/fsw/inc/cfe_msg.h | 26 ++++++++ modules/msg/CMakeLists.txt | 25 ++++---- modules/msg/fsw/src/cfe_msg_verify.c | 48 +++++++++++++++ modules/msg/ut-coverage/CMakeLists.txt | 38 +++++------- modules/msg/ut-coverage/msg_UT.c | 2 + modules/msg/ut-coverage/test_cfe_msg_verify.c | 59 +++++++++++++++++++ modules/msg/ut-coverage/test_cfe_msg_verify.h | 36 +++++++++++ 7 files changed, 200 insertions(+), 34 deletions(-) create mode 100644 modules/msg/fsw/src/cfe_msg_verify.c create mode 100644 modules/msg/ut-coverage/test_cfe_msg_verify.c create mode 100644 modules/msg/ut-coverage/test_cfe_msg_verify.h diff --git a/modules/core_api/fsw/inc/cfe_msg.h b/modules/core_api/fsw/inc/cfe_msg.h index ba91e77b8..0c1b9b949 100644 --- a/modules/core_api/fsw/inc/cfe_msg.h +++ b/modules/core_api/fsw/inc/cfe_msg.h @@ -700,4 +700,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 */ diff --git a/modules/msg/CMakeLists.txt b/modules/msg/CMakeLists.txt index 9018021a1..4cc69762c 100644 --- a/modules/msg/CMakeLists.txt +++ b/modules/msg/CMakeLists.txt @@ -16,35 +16,36 @@ # Add the basic set of files which are always built # Defined as absolute so this list can also be used to build unit tests set(${DEP}_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_ccsdspri.c - ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_init.c - ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_msgid_shared.c - ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_sechdr_checksum.c - ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_sechdr_fc.c - ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_sechdr_time.c + fsw/src/cfe_msg_ccsdspri.c + fsw/src/cfe_msg_init.c + fsw/src/cfe_msg_verify.c + fsw/src/cfe_msg_msgid_shared.c + fsw/src/cfe_msg_sechdr_checksum.c + fsw/src/cfe_msg_sechdr_fc.c + fsw/src/cfe_msg_sechdr_time.c ) # Source selection for if CCSDS extended header is included, and MsgId version use if (MISSION_INCLUDE_CCSDSEXT_HEADER) message(STATUS "CCSDS primary and extended header included in message header") list(APPEND ${DEP}_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_ccsdsext.c - ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_initdefaulthdr_priext.c) + fsw/src/cfe_msg_ccsdsext.c + fsw/src/cfe_msg_initdefaulthdr_priext.c) if (MISSION_MSGID_V2) # MsgId v2 or v1 can be used with extended headers message(STATUS "Message Id version 2 in use (MsgId V2)") list(APPEND ${DEP}_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_msgid_v2.c) + fsw/src/cfe_msg_msgid_v2.c) else (MISSION_MSGID_V2) message(STATUS "Message Id version 1 in use (MsgId V1)") list(APPEND ${DEP}_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_msgid_v1.c) + fsw/src/cfe_msg_msgid_v1.c) endif (MISSION_MSGID_V2) else (MISSION_INCLUDE_CCSDSEXT_HEADER) message(STATUS "CCSDS primary header included in message header (not including CCSDS extended header)") message(STATUS "Message Id version 1 in use (MsgId V1)") list(APPEND ${DEP}_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_initdefaulthdr_pri.c - ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_msgid_v1.c) + fsw/src/cfe_msg_initdefaulthdr_pri.c + fsw/src/cfe_msg_msgid_v1.c) if (MISSION_MSGID_V2) message(FATAL_ERROR "Message Id (MsgId) version 2 can only be used if MISSION_INCLUDE_CCSDSEXT_HEADER is set") endif (MISSION_MSGID_V2) diff --git a/modules/msg/fsw/src/cfe_msg_verify.c b/modules/msg/fsw/src/cfe_msg_verify.c new file mode 100644 index 000000000..b712ff3f6 --- /dev/null +++ b/modules/msg/fsw/src/cfe_msg_verify.c @@ -0,0 +1,48 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +#include "cfe_msg.h" +#include "cfe_msg_priv.h" +#include "cfe_msg_defaults.h" +#include "cfe_time.h" + +/*---------------------------------------------------------------- + * + * Implemented per public API + * See description in header file for argument/return detail + * + *-----------------------------------------------------------------*/ +CFE_Status_t CFE_MSG_Verify(const CFE_MSG_Message_t *MsgPtr, bool *VerifyStatus) +{ + if (MsgPtr == NULL || VerifyStatus == NULL) + { + return CFE_MSG_BAD_ARGUMENT; + } + + /* + * In the default implementation, there is not anything to check here. + * Only commands have a checksum, but the value of that checksum was historically + * not enforced by CFE. + * + * This is mainly a hook for user expansion, in case a custom implementation + * has message verification capability. + */ + *VerifyStatus = true; + + return CFE_SUCCESS; +} \ No newline at end of file diff --git a/modules/msg/ut-coverage/CMakeLists.txt b/modules/msg/ut-coverage/CMakeLists.txt index e7c509576..dd2c3bad1 100644 --- a/modules/msg/ut-coverage/CMakeLists.txt +++ b/modules/msg/ut-coverage/CMakeLists.txt @@ -7,23 +7,23 @@ # ################################################################## -# Unit test object library sources, options, and includes -add_library(ut_${DEP}_objs OBJECT ${${DEP}_SRC}) -target_compile_options(ut_${DEP}_objs PRIVATE ${UT_COVERAGE_COMPILE_FLAGS}) -target_include_directories(ut_${DEP}_objs PRIVATE - $) +set(UNIT_SRCS) +foreach(SRC ${${DEP}_SRC}) + get_filename_component(UNITNAME "${SRC}" NAME) + list(APPEND UNIT_SRCS "../${SRC}") +endforeach() set (ut_${DEP}_tests msg_UT.c test_msg_not.c test_msg_pri_not.c test_cfe_msg_init.c + test_cfe_msg_verify.c test_cfe_msg_ccsdspri.c test_cfe_msg_msgid_shared.c test_cfe_msg_checksum.c test_cfe_msg_fc.c - test_cfe_msg_time.c - $) + test_cfe_msg_time.c) # Add extended header tests if appropriate if (MISSION_INCLUDE_CCSDSEXT_HEADER) @@ -44,21 +44,15 @@ else (MISSION_MSGID_V2) test_cfe_msg_msgid_v1.c) endif (MISSION_MSGID_V2) -# Add executable -add_executable(${DEP}_UT ${ut_${DEP}_tests}) -# Add include to get private defaults -target_include_directories(${DEP}_UT PRIVATE ../fsw/src) +add_cfe_coverage_test(${DEP} ALL + "msg_UT.c;${ut_${DEP}_tests}" # This list needs to be passed as a single argument + "${UNIT_SRCS}" +) -# Also add the UT_COVERAGE_LINK_FLAGS to the link command -# This should enable coverage analysis on platforms that support this -target_link_libraries(${DEP}_UT - ${UT_COVERAGE_LINK_FLAGS} - ut_core_private_stubs - ut_core_api_stubs - ut_assert) +# This permits UT test cases to directly access private headers in the fsw/src dir +target_include_directories(coverage-${DEP}-ALL-testrunner PRIVATE + ../fsw/src +) -add_test(${DEP}_UT ${DEP}_UT) -foreach(TGT ${INSTALL_TARGET_LIST}) - install(TARGETS ${DEP}_UT DESTINATION ${TGT}/${UT_INSTALL_SUBDIR}) -endforeach() +target_link_libraries(coverage-${DEP}-ALL-testrunner ut_core_private_stubs) diff --git a/modules/msg/ut-coverage/msg_UT.c b/modules/msg/ut-coverage/msg_UT.c index ea83b5f8c..97bc8e662 100644 --- a/modules/msg/ut-coverage/msg_UT.c +++ b/modules/msg/ut-coverage/msg_UT.c @@ -28,6 +28,7 @@ #include "test_cfe_msg_init.h" #include "test_cfe_msg_ccsdspri.h" #include "test_cfe_msg_ccsdsext.h" +#include "test_cfe_msg_verify.h" #include "test_cfe_msg_msgid_shared.h" #include "test_cfe_msg_msgid.h" #include "test_cfe_msg_fc.h" @@ -46,6 +47,7 @@ void UtTest_Setup(void) Test_MSG_CCSDSPri(); Test_MSG_CCSDSExt(); Test_MSG_MsgId_Shared(); + UT_ADD_TEST(Test_MSG_Verify); UT_ADD_TEST(Test_MSG_MsgId); UT_ADD_TEST(Test_MSG_Checksum); UT_ADD_TEST(Test_MSG_FcnCode); diff --git a/modules/msg/ut-coverage/test_cfe_msg_verify.c b/modules/msg/ut-coverage/test_cfe_msg_verify.c new file mode 100644 index 000000000..87c5faa73 --- /dev/null +++ b/modules/msg/ut-coverage/test_cfe_msg_verify.c @@ -0,0 +1,59 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * Test message verify + */ + +/* + * Includes + */ +#include "utassert.h" +#include "ut_support.h" +#include "cfe_msg.h" +#include "test_cfe_msg_verify.h" +#include "cfe_error.h" +#include "cfe_msg_defaults.h" + +#include + +/* + * Test MSG Verify + */ +void Test_MSG_Verify(void) +{ + union + { + CFE_MSG_Message_t msg; + CFE_MSG_CommandHeader_t cmd; + CFE_MSG_TelemetryHeader_t tlm; + } LocalBuf; + bool Result; + + memset(&LocalBuf, 0, sizeof(LocalBuf)); + Result = false; + + /* bad buffer */ + UtAssert_INT32_EQ(CFE_MSG_Verify(NULL, &Result), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_Verify(&LocalBuf.msg, NULL), CFE_MSG_BAD_ARGUMENT); + + /* nominal */ + Result = false; + CFE_UtAssert_SUCCESS(CFE_MSG_Verify(&LocalBuf.msg, &Result)); + UtAssert_BOOL_TRUE(Result); +} diff --git a/modules/msg/ut-coverage/test_cfe_msg_verify.h b/modules/msg/ut-coverage/test_cfe_msg_verify.h new file mode 100644 index 000000000..f017560e2 --- /dev/null +++ b/modules/msg/ut-coverage/test_cfe_msg_verify.h @@ -0,0 +1,36 @@ +/************************************************************************ + * 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 + * + * cfe_msg_verify test header + */ +#ifndef TEST_CFE_MSG_VERIFY_H +#define TEST_CFE_MSG_VERIFY_H + +/* + * Includes + */ + +/* + * Functions + */ +void Test_MSG_Verify(void); + +#endif /* TEST_CFE_MSG_VERIFY_H */ From 393a0159895ee7c23ce8c9fec2c3fed68e4ee565 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 17 May 2023 16:15:09 -0400 Subject: [PATCH 2/3] Fix #2335, generalize update header parameter Expand the "Increment Sequence" boolean on transmit message functions to be a more general "Update Header" boolean, so it can be used for other fields like timestamps, checksums, or user-defined fields too. --- modules/cfe_testcase/src/sb_sendrecv_test.c | 13 +++--- modules/core_api/fsw/inc/cfe_msg.h | 25 +++++++++++ modules/core_api/fsw/inc/cfe_sb.h | 30 +++++++++---- .../core_api/ut-stubs/src/cfe_config_stubs.c | 4 +- .../core_api/ut-stubs/src/cfe_error_stubs.c | 43 +++++++++++++++++++ modules/core_api/ut-stubs/src/cfe_es_stubs.c | 21 ++------- modules/core_api/ut-stubs/src/cfe_msg_stubs.c | 17 ++++++++ modules/core_api/ut-stubs/src/cfe_sb_stubs.c | 8 ++-- .../core_api/ut-stubs/src/cfe_time_stubs.c | 2 + modules/msg/fsw/src/cfe_msg_init.c | 32 ++++++++++++++ modules/msg/ut-coverage/msg_UT.c | 1 + modules/msg/ut-coverage/test_cfe_msg_init.c | 37 ++++++++++++++++ modules/msg/ut-coverage/test_cfe_msg_init.h | 1 + modules/sb/fsw/src/cfe_sb_api.c | 22 +++++----- modules/sb/fsw/src/cfe_sb_priv.h | 2 +- modules/sb/ut-coverage/sb_UT.c | 24 +++++------ modules/sb/ut-coverage/sb_UT.h | 4 +- modules/tbl/fsw/src/cfe_tbl_internal.c | 2 +- modules/time/fsw/src/cfe_time_tone.c | 14 +++--- 19 files changed, 231 insertions(+), 71 deletions(-) create mode 100644 modules/core_api/ut-stubs/src/cfe_error_stubs.c diff --git a/modules/cfe_testcase/src/sb_sendrecv_test.c b/modules/cfe_testcase/src/sb_sendrecv_test.c index 81909d0e5..4f8be7ac2 100644 --- a/modules/cfe_testcase/src/sb_sendrecv_test.c +++ b/modules/cfe_testcase/src/sb_sendrecv_test.c @@ -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. @@ -157,7 +158,7 @@ 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); @@ -165,7 +166,7 @@ void TestBasicTransmitRecv(void) 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); @@ -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); @@ -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 */ diff --git a/modules/core_api/fsw/inc/cfe_msg.h b/modules/core_api/fsw/inc/cfe_msg.h index ba91e77b8..96a92d10b 100644 --- a/modules/core_api/fsw/inc/cfe_msg.h +++ b/modules/core_api/fsw/inc/cfe_msg.h @@ -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 diff --git a/modules/core_api/fsw/inc/cfe_sb.h b/modules/core_api/fsw/inc/cfe_sb.h index 99973882b..a670d0120 100644 --- a/modules/core_api/fsw/inc/cfe_sb.h +++ b/modules/core_api/fsw/inc/cfe_sb.h @@ -402,18 +402,26 @@ 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 @@ -421,7 +429,7 @@ CFE_Status_t CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeI ** \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); /*****************************************************************************/ /** @@ -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. @@ -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); /** @} */ diff --git a/modules/core_api/ut-stubs/src/cfe_config_stubs.c b/modules/core_api/ut-stubs/src/cfe_config_stubs.c index 6a90f1b93..1ac7943a8 100644 --- a/modules/core_api/ut-stubs/src/cfe_config_stubs.c +++ b/modules/core_api/ut-stubs/src/cfe_config_stubs.c @@ -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 *); /* * ---------------------------------------------------- diff --git a/modules/core_api/ut-stubs/src/cfe_error_stubs.c b/modules/core_api/ut-stubs/src/cfe_error_stubs.c new file mode 100644 index 000000000..540769933 --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_error_stubs.c @@ -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 *); +} diff --git a/modules/core_api/ut-stubs/src/cfe_es_stubs.c b/modules/core_api/ut-stubs/src/cfe_es_stubs.c index 9dfdf261b..d990609ed 100644 --- a/modules/core_api/ut-stubs/src/cfe_es_stubs.c +++ b/modules/core_api/ut-stubs/src/cfe_es_stubs.c @@ -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); } @@ -216,6 +217,7 @@ void CFE_ES_ExitApp(uint32 ExitStatus) */ void CFE_ES_ExitChildTask(void) { + UT_GenStub_Execute(CFE_ES_ExitChildTask, Basic, NULL); } @@ -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); } @@ -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); } @@ -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 *); -} diff --git a/modules/core_api/ut-stubs/src/cfe_msg_stubs.c b/modules/core_api/ut-stubs/src/cfe_msg_stubs.c index cf59efc6c..066f8e8d1 100644 --- a/modules/core_api/ut-stubs/src/cfe_msg_stubs.c +++ b/modules/core_api/ut-stubs/src/cfe_msg_stubs.c @@ -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() diff --git a/modules/core_api/ut-stubs/src/cfe_sb_stubs.c b/modules/core_api/ut-stubs/src/cfe_sb_stubs.c index f31ef71f8..3f541d54c 100644 --- a/modules/core_api/ut-stubs/src/cfe_sb_stubs.c +++ b/modules/core_api/ut-stubs/src/cfe_sb_stubs.c @@ -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); @@ -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); diff --git a/modules/core_api/ut-stubs/src/cfe_time_stubs.c b/modules/core_api/ut-stubs/src/cfe_time_stubs.c index 40519dfb1..999f06008 100644 --- a/modules/core_api/ut-stubs/src/cfe_time_stubs.c +++ b/modules/core_api/ut-stubs/src/cfe_time_stubs.c @@ -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); } @@ -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); } diff --git a/modules/msg/fsw/src/cfe_msg_init.c b/modules/msg/fsw/src/cfe_msg_init.c index 3c29432a4..ab988f4bb 100644 --- a/modules/msg/fsw/src/cfe_msg_init.c +++ b/modules/msg/fsw/src/cfe_msg_init.c @@ -22,6 +22,7 @@ #include "cfe_msg.h" #include "cfe_msg_priv.h" #include "cfe_msg_defaults.h" +#include "cfe_time.h" #include "string.h" /*---------------------------------------------------------------- @@ -52,3 +53,34 @@ CFE_Status_t CFE_MSG_Init(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId, CFE_M return status; } + +/*---------------------------------------------------------------- + * + * Implemented per public API + * 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) +{ + if (MsgPtr == NULL) + { + return CFE_MSG_BAD_ARGUMENT; + } + + /* Sequence count is in the basic CCSDS Primary Hdr, so all msgs have it */ + CFE_MSG_SetSequenceCount(MsgPtr, SeqCnt); + + /* + * TLM packets have a timestamp in the secondary header. + * This may fail if this is not a TLM packet (that is OK) + */ + CFE_MSG_SetMsgTime(MsgPtr, CFE_TIME_GetTime()); + + /* + * CMD packets have a checksum in the secondary header. + * This may fail if this is not a CMD packet (that is OK) + */ + CFE_MSG_GenerateChecksum(MsgPtr); + + return CFE_SUCCESS; +} \ No newline at end of file diff --git a/modules/msg/ut-coverage/msg_UT.c b/modules/msg/ut-coverage/msg_UT.c index ea83b5f8c..e0bd532ff 100644 --- a/modules/msg/ut-coverage/msg_UT.c +++ b/modules/msg/ut-coverage/msg_UT.c @@ -43,6 +43,7 @@ void UtTest_Setup(void) UtPrintf("Message header coverage test..."); UT_ADD_TEST(Test_MSG_Init); + UT_ADD_TEST(Test_MSG_UpdateHeader); Test_MSG_CCSDSPri(); Test_MSG_CCSDSExt(); Test_MSG_MsgId_Shared(); diff --git a/modules/msg/ut-coverage/test_cfe_msg_init.c b/modules/msg/ut-coverage/test_cfe_msg_init.c index a072566ae..a707c3618 100644 --- a/modules/msg/ut-coverage/test_cfe_msg_init.c +++ b/modules/msg/ut-coverage/test_cfe_msg_init.c @@ -124,3 +124,40 @@ void Test_MSG_Init(void) UtAssert_UINT32_EQ(Test_MSG_Pri_NotZero(CFE_MSG_PTR(cmd)) & ~MSG_HDRVER_FLAG, MSG_APID_FLAG | MSG_HASSEC_FLAG | MSG_TYPE_FLAG | MSG_LENGTH_FLAG | MSG_SEGMENT_FLAG); } + +/* + * Test MSG Update Header + */ +void Test_MSG_UpdateHeader(void) +{ + union + { + CFE_MSG_Message_t msg; + CFE_MSG_CommandHeader_t cmd; + CFE_MSG_TelemetryHeader_t tlm; + + } LocalBuf; + CFE_MSG_SequenceCount_t SeqCnt; + CFE_MSG_SequenceCount_t CheckCnt; + + memset(&LocalBuf, 0, sizeof(LocalBuf)); + SeqCnt = 1; + CheckCnt = 0; + + /* bad buffer */ + UtAssert_INT32_EQ(CFE_MSG_UpdateHeader(NULL, SeqCnt), 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_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_MSG_GetSequenceCount(&LocalBuf.msg, &CheckCnt); + UtAssert_UINT32_EQ(CheckCnt, SeqCnt); + ++SeqCnt; +} diff --git a/modules/msg/ut-coverage/test_cfe_msg_init.h b/modules/msg/ut-coverage/test_cfe_msg_init.h index a80362d03..3c5b25f62 100644 --- a/modules/msg/ut-coverage/test_cfe_msg_init.h +++ b/modules/msg/ut-coverage/test_cfe_msg_init.h @@ -33,5 +33,6 @@ */ /* Test extended header mission functionality */ void Test_MSG_Init(void); +void Test_MSG_UpdateHeader(void); #endif /* TEST_CFE_MSG_INIT_H */ diff --git a/modules/sb/fsw/src/cfe_sb_api.c b/modules/sb/fsw/src/cfe_sb_api.c index 674c20cca..1b9574260 100644 --- a/modules/sb/fsw/src/cfe_sb_api.c +++ b/modules/sb/fsw/src/cfe_sb_api.c @@ -1287,7 +1287,7 @@ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, uint8 * See description in header file for argument/return detail * *-----------------------------------------------------------------*/ -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) { int32 Status; CFE_MSG_Size_t Size = 0; @@ -1347,9 +1347,9 @@ CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool IncrementS { /* Copy actual message content into buffer and set its metadata */ memcpy(&BufDscPtr->Content, MsgPtr, Size); - BufDscPtr->MsgId = MsgId; - BufDscPtr->ContentSize = Size; - BufDscPtr->AutoSequence = IncrementSequenceCount; + BufDscPtr->MsgId = MsgId; + BufDscPtr->ContentSize = Size; + BufDscPtr->NeedsUpdate = UpdateHeader; CFE_MSG_GetType(MsgPtr, &BufDscPtr->ContentType); /* @@ -1551,13 +1551,15 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ if (CFE_SBR_IsValidRouteId(RouteId)) { /* Set the seq count if requested (while locked) before actually sending */ - /* For some reason this is only done for TLM types (historical, TBD) */ - if (BufDscPtr->AutoSequence && BufDscPtr->ContentType == CFE_MSG_Type_Tlm) + if (BufDscPtr->NeedsUpdate) { CFE_SBR_IncrementSequenceCounter(RouteId); - /* Write the sequence into the message header itself (overwrites whatever was there) */ - CFE_MSG_SetSequenceCount(&BufDscPtr->Content.Msg, CFE_SBR_GetSequenceCounter(RouteId)); + /* Update all MSG headers based on the current sequence */ + CFE_MSG_UpdateHeader(&BufDscPtr->Content.Msg, CFE_SBR_GetSequenceCounter(RouteId)); + + /* Clear the flag, just in case */ + BufDscPtr->NeedsUpdate = false; } /* Send the packet to all destinations */ @@ -2116,7 +2118,7 @@ CFE_Status_t CFE_SB_ReleaseMessageBuffer(CFE_SB_Buffer_t *BufPtr) * See description in header file for argument/return detail * *-----------------------------------------------------------------*/ -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) { int32 Status; CFE_SB_BufferD_t *BufDscPtr; @@ -2141,7 +2143,7 @@ CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool IncrementSequen */ if (Status == CFE_SUCCESS) { - BufDscPtr->AutoSequence = IncrementSequenceCount; + BufDscPtr->NeedsUpdate = UpdateHeader; CFE_MSG_GetType(&BufPtr->Msg, &BufDscPtr->ContentType); /* Now broadcast the message, which consumes the buffer */ diff --git a/modules/sb/fsw/src/cfe_sb_priv.h b/modules/sb/fsw/src/cfe_sb_priv.h index 9443c6094..737682936 100644 --- a/modules/sb/fsw/src/cfe_sb_priv.h +++ b/modules/sb/fsw/src/cfe_sb_priv.h @@ -150,7 +150,7 @@ typedef struct CFE_SB_BufferD size_t ContentSize; /**< Actual size of message content currently stored in the buffer */ CFE_MSG_Type_t ContentType; /**< Type of message content currently stored in the buffer */ - bool AutoSequence; /**< If message should get its sequence number assigned from the route */ + bool NeedsUpdate; /**< If message should get its header fields automatically updated */ uint16 UseCount; /**< Number of active references to this buffer in the system */ diff --git a/modules/sb/ut-coverage/sb_UT.c b/modules/sb/ut-coverage/sb_UT.c index ba6a3dded..78c89bab5 100644 --- a/modules/sb/ut-coverage/sb_UT.c +++ b/modules/sb/ut-coverage/sb_UT.c @@ -2850,7 +2850,7 @@ void Test_TransmitMsg_API(void) SB_UT_ADD_SUBTEST(Test_TransmitMsg_NoSubscribers); SB_UT_ADD_SUBTEST(Test_TransmitMsg_MaxMsgSizePlusOne); SB_UT_ADD_SUBTEST(Test_TransmitMsg_BasicSend); - SB_UT_ADD_SUBTEST(Test_TransmitMsg_SequenceCount); + SB_UT_ADD_SUBTEST(Test_TransmitMsg_UpdateHeader); SB_UT_ADD_SUBTEST(Test_TransmitMsg_QueuePutError); SB_UT_ADD_SUBTEST(Test_TransmitMsg_PipeFull); SB_UT_ADD_SUBTEST(Test_TransmitMsg_MsgLimitExceeded); @@ -2962,9 +2962,9 @@ static int32 UT_CheckSetSequenceCount(void *UserObj, int32 StubRetcode, uint32 C } /* -** Test successful send/receive for packet sequence count +** Test successful send with header update */ -void Test_TransmitMsg_SequenceCount(void) +void Test_TransmitMsg_UpdateHeader(void) { CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; @@ -2977,8 +2977,8 @@ void Test_TransmitMsg_SequenceCount(void) memset(&TlmPkt, 0, sizeof(TlmPkt)); - /* Set up hook for checking CFE_MSG_SetSequenceCount calls */ - UT_SetHookFunction(UT_KEY(CFE_MSG_SetSequenceCount), UT_CheckSetSequenceCount, &SeqCnt); + /* Set up hook for checking CFE_MSG_UpdateHeader calls */ + UT_SetHookFunction(UT_KEY(CFE_MSG_UpdateHeader), UT_CheckSetSequenceCount, &SeqCnt); CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "SeqCntTestPipe")); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -2991,7 +2991,7 @@ void Test_TransmitMsg_SequenceCount(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false); CFE_UtAssert_SETUP(CFE_SB_TransmitMsg(CFE_MSG_PTR(TlmPkt.TelemetryHeader), true)); - UtAssert_STUB_COUNT(CFE_MSG_SetSequenceCount, 1); + UtAssert_STUB_COUNT(CFE_MSG_UpdateHeader, 1); UtAssert_STUB_COUNT(CFE_MSG_GetNextSequenceCount, 1); UtAssert_INT32_EQ(SeqCnt, SeqCntExpected); @@ -3002,7 +3002,7 @@ void Test_TransmitMsg_SequenceCount(void) /* Assert sequence count wasn't set */ UtAssert_STUB_COUNT(CFE_MSG_GetNextSequenceCount, 1); - UtAssert_STUB_COUNT(CFE_MSG_SetSequenceCount, 1); + UtAssert_STUB_COUNT(CFE_MSG_UpdateHeader, 1); SeqCntExpected = 2; UT_SetDefaultReturnValue(UT_KEY(CFE_MSG_GetNextSequenceCount), SeqCntExpected); @@ -3011,7 +3011,7 @@ void Test_TransmitMsg_SequenceCount(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false); CFE_UtAssert_SUCCESS(CFE_SB_TransmitMsg(CFE_MSG_PTR(TlmPkt.TelemetryHeader), true)); UtAssert_INT32_EQ(SeqCnt, SeqCntExpected); - UtAssert_STUB_COUNT(CFE_MSG_SetSequenceCount, 2); + UtAssert_STUB_COUNT(CFE_MSG_UpdateHeader, 2); UtAssert_STUB_COUNT(CFE_MSG_GetNextSequenceCount, 2); CFE_UtAssert_EVENTCOUNT(2); @@ -3025,7 +3025,7 @@ void Test_TransmitMsg_SequenceCount(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false); CFE_UtAssert_SETUP(CFE_SB_TransmitMsg(CFE_MSG_PTR(TlmPkt.TelemetryHeader), true)); /* increment to 3 */ - UtAssert_STUB_COUNT(CFE_MSG_SetSequenceCount, 3); + UtAssert_STUB_COUNT(CFE_MSG_UpdateHeader, 3); UtAssert_STUB_COUNT(CFE_MSG_GetNextSequenceCount, 3); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId)); /* resubscribe so we can receive a msg */ @@ -3037,7 +3037,7 @@ void Test_TransmitMsg_SequenceCount(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false); CFE_UtAssert_SETUP(CFE_SB_TransmitMsg(CFE_MSG_PTR(TlmPkt.TelemetryHeader), true)); /* increment to 4 */ UtAssert_INT32_EQ(SeqCnt, SeqCntExpected); - UtAssert_STUB_COUNT(CFE_MSG_SetSequenceCount, 4); + UtAssert_STUB_COUNT(CFE_MSG_UpdateHeader, 4); UtAssert_STUB_COUNT(CFE_MSG_GetNextSequenceCount, 4); CFE_UtAssert_TEARDOWN(CFE_SB_DeletePipe(PipeId)); @@ -3288,8 +3288,8 @@ void Test_TransmitBuffer_IncrementSeqCnt(void) CFE_MSG_Size_t Size = sizeof(SB_UT_Test_Tlm_t); CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; - /* Set up hook for checking CFE_MSG_SetSequenceCount calls */ - UT_SetHookFunction(UT_KEY(CFE_MSG_SetSequenceCount), UT_CheckSetSequenceCount, &SeqCnt); + /* Set up hook for checking CFE_MSG_UpdateHeader calls */ + UT_SetHookFunction(UT_KEY(CFE_MSG_UpdateHeader), UT_CheckSetSequenceCount, &SeqCnt); CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "ZeroCpyTestPipe")); diff --git a/modules/sb/ut-coverage/sb_UT.h b/modules/sb/ut-coverage/sb_UT.h index ad510d305..6a4f59270 100644 --- a/modules/sb/ut-coverage/sb_UT.h +++ b/modules/sb/ut-coverage/sb_UT.h @@ -1854,7 +1854,7 @@ void Test_TransmitMsg_BasicSend(void); /*****************************************************************************/ /** -** \brief Test successful send/receive for packet sequence count +** \brief Test successful send of messages with header update ** ** \par Description ** This function tests successful send/receive for packet sequence @@ -1866,7 +1866,7 @@ void Test_TransmitMsg_BasicSend(void); ** \returns ** This function does not return a value. ******************************************************************************/ -void Test_TransmitMsg_SequenceCount(void); +void Test_TransmitMsg_UpdateHeader(void); /*****************************************************************************/ /** diff --git a/modules/tbl/fsw/src/cfe_tbl_internal.c b/modules/tbl/fsw/src/cfe_tbl_internal.c index bb72f3477..18991d96e 100644 --- a/modules/tbl/fsw/src/cfe_tbl_internal.c +++ b/modules/tbl/fsw/src/cfe_tbl_internal.c @@ -1379,7 +1379,7 @@ int32 CFE_TBL_SendNotificationMsg(CFE_TBL_RegistryRec_t *RegRecPtr) CFE_TBL_Global.NotifyMsg.Payload.Parameter = RegRecPtr->NotificationParam; CFE_SB_TimeStampMsg(CFE_MSG_PTR(CFE_TBL_Global.NotifyMsg.CommandHeader)); - Status = CFE_SB_TransmitMsg(CFE_MSG_PTR(CFE_TBL_Global.NotifyMsg.CommandHeader), false); + Status = CFE_SB_TransmitMsg(CFE_MSG_PTR(CFE_TBL_Global.NotifyMsg.CommandHeader), true); if (Status != CFE_SUCCESS) { diff --git a/modules/time/fsw/src/cfe_time_tone.c b/modules/time/fsw/src/cfe_time_tone.c index 9e8ca3a50..b3a431386 100644 --- a/modules/time/fsw/src/cfe_time_tone.c +++ b/modules/time/fsw/src/cfe_time_tone.c @@ -150,7 +150,7 @@ void CFE_TIME_ToneSend(void) /* ** Send "time at the tone" command data packet... */ - CFE_SB_TransmitMsg(CFE_MSG_PTR(CFE_TIME_Global.ToneDataCmd.CommandHeader), false); + CFE_SB_TransmitMsg(CFE_MSG_PTR(CFE_TIME_Global.ToneDataCmd.CommandHeader), true); /* ** Count of "time at the tone" commands sent with internal data... @@ -275,7 +275,7 @@ int32 CFE_TIME_ToneSendMET(CFE_TIME_SysTime_t NewMET) /* ** Send "time at the tone" command data packet... */ - CFE_SB_TransmitMsg(&CFE_TIME_Global.ToneDataCmd.CommandHeader.Msg, false); + CFE_SB_TransmitMsg(&CFE_TIME_Global.ToneDataCmd.CommandHeader.Msg, true); /* ** Count of "time at the tone" commands sent with external data... @@ -415,7 +415,7 @@ int32 CFE_TIME_ToneSendGPS(CFE_TIME_SysTime_t NewTime, int16 NewLeaps) /* ** Send "time at the tone" command data packet... */ - CFE_SB_TransmitMsg(&CFE_TIME_Global.ToneDataCmd.CommandHeader.Msg, false); + CFE_SB_TransmitMsg(&CFE_TIME_Global.ToneDataCmd.CommandHeader.Msg, true); /* ** Count of "time at the tone" commands sent with external data... @@ -555,7 +555,7 @@ int32 CFE_TIME_ToneSendTime(CFE_TIME_SysTime_t NewTime) /* ** Send "time at the tone" command data packet... */ - CFE_SB_TransmitMsg(&CFE_TIME_Global.ToneDataCmd.CommandHeader.Msg, false); + CFE_SB_TransmitMsg(&CFE_TIME_Global.ToneDataCmd.CommandHeader.Msg, true); /* ** Count of "time at the tone" commands sent with external data... @@ -1088,7 +1088,7 @@ void CFE_TIME_Tone1HzTask(void) /* ** Send tone signal command packet... */ - CFE_SB_TransmitMsg(CFE_MSG_PTR(CFE_TIME_Global.ToneSignalCmd.CommandHeader), false); + CFE_SB_TransmitMsg(CFE_MSG_PTR(CFE_TIME_Global.ToneSignalCmd.CommandHeader), true); #if (CFE_MISSION_TIME_CFG_FAKE_TONE == true) /* @@ -1096,7 +1096,7 @@ void CFE_TIME_Tone1HzTask(void) ** to send the tone to other time clients. ** (this is done by scheduler in non-fake mode) */ - CFE_SB_TransmitMsg(CFE_MSG_PTR(CFE_TIME_Global.ToneSendCmd.CommandHeader), false); + CFE_SB_TransmitMsg(CFE_MSG_PTR(CFE_TIME_Global.ToneSendCmd.CommandHeader), true); #endif /* @@ -1287,7 +1287,7 @@ void CFE_TIME_Local1HzTask(void) ** This used to be optional in previous CFE versions, but it is now required ** as TIME subscribes to this itself to do state machine tasks. */ - CFE_SB_TransmitMsg(CFE_MSG_PTR(CFE_TIME_Global.Local1HzCmd.CommandHeader), false); + CFE_SB_TransmitMsg(CFE_MSG_PTR(CFE_TIME_Global.Local1HzCmd.CommandHeader), true); CFE_TIME_Global.LocalTaskCounter++; From 57f4374ea002cb02622df0ed8cd0b729ad2f2189 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 22 May 2023 16:50:52 -0400 Subject: [PATCH 3/3] Bump to v7.0.0-rc4+dev318 --- CHANGELOG.md | 5 +++++ modules/core_api/fsw/inc/cfe_version.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59bc61b04..39367249b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Development Build: v7.0.0-rc4+dev318 +- generalize update header parameter +- add msg verify capability +- See and + ## Development Build: v7.0.0-rc4+dev312 - adjust UT pool buffer size for platform config - Remove unused CFE_PLATFORM_ES_RESET_AREA_SIZE diff --git a/modules/core_api/fsw/inc/cfe_version.h b/modules/core_api/fsw/inc/cfe_version.h index 6711cef17..da6fa34a5 100644 --- a/modules/core_api/fsw/inc/cfe_version.h +++ b/modules/core_api/fsw/inc/cfe_version.h @@ -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 */