From 5227decda67f4f1b3c0fd5a01e9afff38b58f4fe Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 16:14:33 -0700 Subject: [PATCH 01/34] Remove NATIVE_* types from FileUplink --- Svc/FileUplink/test/ut/FileUplinkTester.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Svc/FileUplink/test/ut/FileUplinkTester.cpp b/Svc/FileUplink/test/ut/FileUplinkTester.cpp index 1c03b430a3..d05e676bc2 100644 --- a/Svc/FileUplink/test/ut/FileUplinkTester.cpp +++ b/Svc/FileUplink/test/ut/FileUplinkTester.cpp @@ -713,7 +713,8 @@ namespace Svc { void FileUplinkTester :: removeFile(const char *const path) { - const NATIVE_INT_TYPE status = ::unlink(path); + // status from unlink is a platform integer + const PlatformIntType status = ::unlink(path); if (status != 0) { ASSERT_EQ(ENOENT, errno); } From 0f44b4c349707af73781718cd2bf54512c39971c Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 16:14:46 -0700 Subject: [PATCH 02/34] Remove NATIVE_* types from RateGroupDriver --- Svc/RateGroupDriver/RateGroupDriver.cpp | 18 +++++++++++------- Svc/RateGroupDriver/RateGroupDriver.hpp | 11 +++++------ Svc/RateGroupDriver/docs/sdd.md | 6 +++--- .../test/ut/RateGroupDriverImplTester.cpp | 17 ++++++----------- .../test/ut/RateGroupDriverImplTester.hpp | 4 +--- .../test/ut/RateGroupDriverTester.cpp | 4 ++-- 6 files changed, 28 insertions(+), 32 deletions(-) diff --git a/Svc/RateGroupDriver/RateGroupDriver.cpp b/Svc/RateGroupDriver/RateGroupDriver.cpp index 85a54ae4be..cb67f52c46 100644 --- a/Svc/RateGroupDriver/RateGroupDriver.cpp +++ b/Svc/RateGroupDriver/RateGroupDriver.cpp @@ -19,18 +19,22 @@ namespace Svc { FW_ASSERT(dividerSet.dividers); // verify port/table size matches FW_ASSERT(FW_NUM_ARRAY_ELEMENTS(this->m_dividers) == this->getNum_CycleOut_OutputPorts(), - static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_dividers)), - this->getNum_CycleOut_OutputPorts()); + static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_dividers)), + static_cast(this->getNum_CycleOut_OutputPorts())); // copy provided array of dividers - for (NATIVE_UINT_TYPE entry = 0; entry < RateGroupDriver::DIVIDER_SIZE; entry++) { + for (FwIndexType entry = 0; entry < RateGroupDriver::DIVIDER_SIZE; entry++) { // A port with an offset equal or bigger than the divisor is not accepted because it would never be called - FW_ASSERT((dividerSet.dividers[entry].offset==0)||(dividerSet.dividers[entry].offset < dividerSet.dividers[entry].divisor), - dividerSet.dividers[entry].offset, - dividerSet.dividers[entry].divisor); + FW_ASSERT((dividerSet.dividers[entry].offset==0) || (dividerSet.dividers[entry].offset < dividerSet.dividers[entry].divisor), + static_cast(dividerSet.dividers[entry].offset), + static_cast(dividerSet.dividers[entry].divisor)); this->m_dividers[entry] = dividerSet.dividers[entry]; // rollover value should be product of all dividers to make sure integer rollover doesn't jump cycles // only use non-zero dividers if (dividerSet.dividers[entry].divisor != 0) { + // Ensure that rollover will not overflow + FW_ASSERT((std::numeric_limits::max() / dividerSet.dividers[entry].divisor) >= this->m_rollover, + static_cast(this->m_rollover), + static_cast(dividerSet.dividers[entry].divisor)); this->m_rollover *= dividerSet.dividers[entry].divisor; } } @@ -50,7 +54,7 @@ namespace Svc { // Loop through each divider. For a given port, the port will be called when the divider value // divides evenly into the number of ticks. For example, if the divider value for a port is 4, // it would be called every fourth invocation of the CycleIn port. - for (NATIVE_UINT_TYPE entry = 0; entry < RateGroupDriver::DIVIDER_SIZE; entry++) { + for (FwIndexType entry = 0; entry < RateGroupDriver::DIVIDER_SIZE; entry++) { if (this->m_dividers[entry].divisor != 0) { if (this->isConnected_CycleOut_OutputPort(static_cast(entry))) { if ((this->m_ticks % this->m_dividers[entry].divisor) == this->m_dividers[entry].offset) { diff --git a/Svc/RateGroupDriver/RateGroupDriver.hpp b/Svc/RateGroupDriver/RateGroupDriver.hpp index e84ae0175c..d7d73d9d92 100644 --- a/Svc/RateGroupDriver/RateGroupDriver.hpp +++ b/Svc/RateGroupDriver/RateGroupDriver.hpp @@ -1,5 +1,4 @@ /** - * \file * \author T. Canham * \brief RateGroupDivider component implementation * @@ -43,13 +42,13 @@ namespace Svc { Divider() : divisor(0), offset(0) {} //! Initializes divisor and offset to passed-in pair - Divider(NATIVE_INT_TYPE divisorIn, NATIVE_INT_TYPE offsetIn) : + Divider(FwSizeType divisorIn, FwSizeType offsetIn) : divisor(divisorIn), offset(offsetIn) {} //! Divisor - NATIVE_INT_TYPE divisor; + FwSizeType divisor; //! Offset - NATIVE_INT_TYPE offset; + FwSizeType offset; }; //! \class DividerSet @@ -87,10 +86,10 @@ namespace Svc { Divider m_dividers[NUM_CYCLEOUT_OUTPUT_PORTS]; //! tick counter - NATIVE_INT_TYPE m_ticks; + FwSizeType m_ticks; //! rollover counter - NATIVE_INT_TYPE m_rollover; + FwSizeType m_rollover; //! has the configure method been called bool m_configured; diff --git a/Svc/RateGroupDriver/docs/sdd.md b/Svc/RateGroupDriver/docs/sdd.md index a5bc2d6ec6..8501f24aab 100644 --- a/Svc/RateGroupDriver/docs/sdd.md +++ b/Svc/RateGroupDriver/docs/sdd.md @@ -38,13 +38,13 @@ Port Data Type | Name | Direction | Kind | Usage The Svc::RateGroupDriver component has one input port that receives a system tick. -The `configure()` function is passed an array of integer arguments that specifies the divisors for each output port. This should be called after the constructor but before any port calls are made. The contents of the array are copied during the call, so the array can be a temporary variable. +The `configure()` function is passed a divider set specifies the divisors and offsets for each output port. This should be called after the constructor but before any port calls are made. The contents of the structure are copied during the call, so the array can be a temporary variable. ``` - RateGroupDriverImpl::configure(NATIVE_INT_TYPE dividers[], NATIVE_INT_TYPE numDividers); + RateGroupDriverImpl::configure(const DividerSet& dividerSet); ``` -The input rate for each output port will be divided down by the value in the `dividers[]` array corresponding to the output port number. +The input rate for each output port will be divided down by the value in the `divider` field corresponding to the output port number. The implementation will be ISR compliant by avoiding the following: diff --git a/Svc/RateGroupDriver/test/ut/RateGroupDriverImplTester.cpp b/Svc/RateGroupDriver/test/ut/RateGroupDriverImplTester.cpp index 22969ae774..f5fef7bb9d 100644 --- a/Svc/RateGroupDriver/test/ut/RateGroupDriverImplTester.cpp +++ b/Svc/RateGroupDriver/test/ut/RateGroupDriverImplTester.cpp @@ -14,11 +14,6 @@ #include namespace Svc { - - void RateGroupDriverImplTester::init(NATIVE_INT_TYPE instance) { - RateGroupDriverGTestBase::init(); - } - RateGroupDriverImplTester::RateGroupDriverImplTester(Svc::RateGroupDriver& inst) : RateGroupDriverGTestBase("testerbase",100), m_impl(inst) { @@ -37,7 +32,7 @@ namespace Svc { this->m_portCalls[portNum] = true; } - void RateGroupDriverImplTester::runSchedNominal(Svc::RateGroupDriver::DividerSet dividersSet, NATIVE_INT_TYPE numDividers) { + void RateGroupDriverImplTester::runSchedNominal(Svc::RateGroupDriver::DividerSet dividersSet, FwIndexType numDividers) { TEST_CASE(106.1.1,"Nominal Execution"); COMMENT( @@ -45,26 +40,26 @@ namespace Svc { "Verify that the output ports are being called correctly.\n" ); - NATIVE_INT_TYPE expected_rollover = 1; + FwSizeType expected_rollover = 1; - for (NATIVE_INT_TYPE div = 0; div < numDividers; div++) { + for (FwIndexType div = 0; div < numDividers; div++) { expected_rollover *= dividersSet.dividers[div].divisor; } ASSERT_EQ(expected_rollover,this->m_impl.m_rollover); - NATIVE_INT_TYPE iters = expected_rollover*10; + FwSizeType iters = expected_rollover*10; REQUIREMENT("RGD-001"); - for (NATIVE_INT_TYPE cycle = 0; cycle < iters; cycle++) { + for (FwSizeType cycle = 0; cycle < iters; cycle++) { this->clearPortCalls(); Os::RawTime t; this->invoke_to_CycleIn(0,t); // make sure ticks are counting correctly ASSERT_EQ((cycle+1)%expected_rollover,this->m_impl.m_ticks); // check for various intervals - for (NATIVE_INT_TYPE div = 0; div < numDividers; div++) { + for (FwIndexType div = 0; div < numDividers; div++) { if (cycle % dividersSet.dividers[div].divisor == dividersSet.dividers[div].offset) { EXPECT_TRUE(this->m_portCalls[div]); } else { diff --git a/Svc/RateGroupDriver/test/ut/RateGroupDriverImplTester.hpp b/Svc/RateGroupDriver/test/ut/RateGroupDriverImplTester.hpp index be5defc12e..2efadc66af 100644 --- a/Svc/RateGroupDriver/test/ut/RateGroupDriverImplTester.hpp +++ b/Svc/RateGroupDriver/test/ut/RateGroupDriverImplTester.hpp @@ -18,9 +18,7 @@ namespace Svc { RateGroupDriverImplTester(Svc::RateGroupDriver& inst); virtual ~RateGroupDriverImplTester(); - void init(NATIVE_INT_TYPE instance = 0); - - void runSchedNominal(Svc::RateGroupDriver::DividerSet dividersSet, NATIVE_INT_TYPE numDividers); + void runSchedNominal(Svc::RateGroupDriver::DividerSet dividersSet, FwIndexType numDividers); private: diff --git a/Svc/RateGroupDriver/test/ut/RateGroupDriverTester.cpp b/Svc/RateGroupDriver/test/ut/RateGroupDriverTester.cpp index 1e31e71c8b..259c49a709 100644 --- a/Svc/RateGroupDriver/test/ut/RateGroupDriverTester.cpp +++ b/Svc/RateGroupDriver/test/ut/RateGroupDriverTester.cpp @@ -17,7 +17,7 @@ static Fw::SimpleObjRegistry simpleReg; void connectPorts(Svc::RateGroupDriver& impl, Svc::RateGroupDriverImplTester& tester) { - for(NATIVE_UINT_TYPE i=0; i(Svc::RateGroupDriver::DIVIDER_SIZE); i++) { - dividersSet.dividers[i] = {i+1, i%2}; + dividersSet.dividers[i] = {static_cast(i+1), static_cast(i%2)}; } Svc::RateGroupDriver impl("RateGroupDriver"); From c86b6a2da3b10c7419f1d6e8dc55347b71ec951e Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 16:15:07 -0700 Subject: [PATCH 03/34] Remove NATIVE_* types from ComLogger --- Svc/ComLogger/ComLogger.cpp | 2 +- Svc/ComLogger/test/ut/ComLoggerTester.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Svc/ComLogger/ComLogger.cpp b/Svc/ComLogger/ComLogger.cpp index 3bc2192d03..6a1256b728 100644 --- a/Svc/ComLogger/ComLogger.cpp +++ b/Svc/ComLogger/ComLogger.cpp @@ -244,7 +244,7 @@ namespace Svc { { FwSignedSizeType size = length; Os::File::Status ret = m_file.write(reinterpret_cast(data), size); - if( Os::File::OP_OK != ret || size != static_cast(length) ) { + if( Os::File::OP_OK != ret || size != static_cast(length) ) { if( !this->m_writeErrorOccurred ) { // throttle this event, otherwise a positive // feedback event loop can occur! this->log_WARNING_HI_FileWriteError(ret, static_cast(size), length, this->m_fileName); diff --git a/Svc/ComLogger/test/ut/ComLoggerTester.cpp b/Svc/ComLogger/test/ut/ComLoggerTester.cpp index 6c42180516..0da5dd06d4 100644 --- a/Svc/ComLogger/test/ut/ComLoggerTester.cpp +++ b/Svc/ComLogger/test/ut/ComLoggerTester.cpp @@ -165,7 +165,7 @@ namespace Svc { FwSignedSizeType length = sizeof(U16); ret = file.read(buf, length); ASSERT_EQ(Os::File::OP_OK, ret); - ASSERT_EQ(length, static_cast(sizeof(U16))); + ASSERT_EQ(length, static_cast(sizeof(U16))); Fw::SerialBuffer comBuffLength(buf, length); comBuffLength.fill(); stat = comBuffLength.deserialize(bufferSize); @@ -176,7 +176,7 @@ namespace Svc { length = bufferSize; ret = file.read(buf, length); ASSERT_EQ(Os::File::OP_OK,ret); - ASSERT_EQ(length, static_cast(bufferSize)); + ASSERT_EQ(length, static_cast(bufferSize)); ASSERT_EQ(memcmp(buf, data, COM_BUFFER_LENGTH), 0); //for(int k=0; k < 4; k++) @@ -185,7 +185,7 @@ namespace Svc { } // Make sure we reached the end of the file: - FwSignedSizeType length = sizeof(NATIVE_INT_TYPE); + FwSignedSizeType length = static_cast(sizeof(FwSignedSizeType)); ret = file.read(buf, length); ASSERT_EQ(Os::File::OP_OK,ret); ASSERT_EQ(length, 0); @@ -296,7 +296,7 @@ namespace Svc { } // Make sure we reached the end of the file: - FwSignedSizeType length = sizeof(NATIVE_INT_TYPE); + FwSignedSizeType length = sizeof(FwSignedSizeType); ret = file.read(buf, length); ASSERT_EQ(Os::File::OP_OK,ret); ASSERT_EQ(length, 0); @@ -652,7 +652,7 @@ namespace Svc { FwSignedSizeType length = sizeof(U16); ret = file.read(buf, length); ASSERT_EQ(Os::File::OP_OK, ret); - ASSERT_EQ(length, static_cast(sizeof(U16))); + ASSERT_EQ(length, static_cast(sizeof(U16))); Fw::SerialBuffer comBuffLength(buf, length); comBuffLength.fill(); stat = comBuffLength.deserialize(bufferSize); @@ -663,12 +663,12 @@ namespace Svc { length = bufferSize; ret = file.read(buf, length); ASSERT_EQ(Os::File::OP_OK,ret); - ASSERT_EQ(length, static_cast(bufferSize)); + ASSERT_EQ(length, static_cast(bufferSize)); ASSERT_EQ(memcmp(buf, data, COM_BUFFER_LENGTH), 0); } // Make sure we reached the end of the file: - FwSignedSizeType length = sizeof(NATIVE_INT_TYPE); + FwSignedSizeType length = sizeof(FwSignedSizeType); ret = file.read(buf, length); ASSERT_EQ(Os::File::OP_OK,ret); ASSERT_EQ(length, 0); From 76241c5ed0e5b2f5724541661a34286fb82ce266 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 16:24:56 -0700 Subject: [PATCH 04/34] Addressing init function usage of NATIVE_ types --- Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.cpp | 4 ---- Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.hpp | 2 -- Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.cpp | 5 ----- Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.hpp | 2 -- Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp | 5 ----- Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.hpp | 2 -- Svc/Health/HealthComponentImpl.cpp | 2 +- Svc/Health/HealthComponentImpl.hpp | 2 +- Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.cpp | 4 ---- Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.hpp | 2 -- Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.hpp | 2 -- Svc/PrmDb/test/ut/PrmDbImplTester.cpp | 4 ---- Svc/PrmDb/test/ut/PrmDbImplTester.hpp | 3 --- 13 files changed, 2 insertions(+), 37 deletions(-) diff --git a/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.cpp b/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.cpp index 25f3d183f5..133dedc04b 100644 --- a/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.cpp +++ b/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.cpp @@ -19,10 +19,6 @@ namespace Svc { typedef ActiveLogger_Enabled Enabled; typedef ActiveLogger_FilterSeverity FilterSeverity; - void ActiveLoggerImplTester::init(NATIVE_INT_TYPE instance) { - Svc::ActiveLoggerGTestBase::init(); - } - ActiveLoggerImplTester::ActiveLoggerImplTester(Svc::ActiveLoggerImpl& inst) : Svc::ActiveLoggerGTestBase("testerbase",100), m_impl(inst), diff --git a/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.hpp b/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.hpp index 0d6ad8535d..b06c8ecb0a 100644 --- a/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.hpp +++ b/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.hpp @@ -19,8 +19,6 @@ namespace Svc { ActiveLoggerImplTester(Svc::ActiveLoggerImpl& inst); virtual ~ActiveLoggerImplTester(); - void init(NATIVE_INT_TYPE instance = 0) override; - void runEventNominal(); void runFilterEventNominal(); void runFilterIdNominal(); diff --git a/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.cpp b/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.cpp index 863e830056..b399898958 100644 --- a/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.cpp +++ b/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.cpp @@ -22,11 +22,6 @@ #include namespace Svc { - - void ActiveRateGroupImplTester::init(NATIVE_INT_TYPE instance) { - ActiveRateGroupGTestBase::init(); - } - ActiveRateGroupImplTester::ActiveRateGroupImplTester(Svc::ActiveRateGroup& inst) : ActiveRateGroupGTestBase("testerbase",100), m_impl(inst),m_causeOverrun(false),m_callOrder(0) { diff --git a/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.hpp b/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.hpp index 19b3003536..a62e86902a 100644 --- a/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.hpp +++ b/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.hpp @@ -26,8 +26,6 @@ namespace Svc { ActiveRateGroupImplTester(Svc::ActiveRateGroup& inst); virtual ~ActiveRateGroupImplTester(); - void init(NATIVE_INT_TYPE instance = 0); - void runNominal(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts, NATIVE_INT_TYPE instance); void runCycleOverrun(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts, NATIVE_INT_TYPE instance); void runPingTest(); diff --git a/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp b/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp index c5e565717b..934a7e4ffc 100644 --- a/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp +++ b/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp @@ -17,11 +17,6 @@ namespace Svc { - - void CommandDispatcherImplTester::init(NATIVE_INT_TYPE instance) { - CommandDispatcherGTestBase::init(); - } - CommandDispatcherImplTester::CommandDispatcherImplTester(Svc::CommandDispatcherImpl& inst) : CommandDispatcherGTestBase("testerbase",100), m_impl(inst) { diff --git a/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.hpp b/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.hpp index d7ab42c58f..756c9cb11a 100644 --- a/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.hpp +++ b/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.hpp @@ -18,8 +18,6 @@ namespace Svc { CommandDispatcherImplTester(Svc::CommandDispatcherImpl& inst); virtual ~CommandDispatcherImplTester(); - void init(NATIVE_INT_TYPE instance = 0); - void runNominalDispatch(); void runInvalidOpcodeDispatch(); void runCommandReregister(); diff --git a/Svc/Health/HealthComponentImpl.cpp b/Svc/Health/HealthComponentImpl.cpp index 347c25690f..fb4b51c1ef 100644 --- a/Svc/Health/HealthComponentImpl.cpp +++ b/Svc/Health/HealthComponentImpl.cpp @@ -36,7 +36,7 @@ namespace Svc { } } - void HealthImpl::init(const FwSizeType queueDepth, const NATIVE_INT_TYPE instance) { + void HealthImpl::init(const FwSizeType queueDepth, const FwEnumStoreType instance) { HealthComponentBase::init(queueDepth, instance); this->queue_depth = queueDepth; diff --git a/Svc/Health/HealthComponentImpl.hpp b/Svc/Health/HealthComponentImpl.hpp index 3d98cdb365..4b3eae04fe 100644 --- a/Svc/Health/HealthComponentImpl.hpp +++ b/Svc/Health/HealthComponentImpl.hpp @@ -61,7 +61,7 @@ namespace Svc { //! //! \param queueDepth Depth of queue //! \param instance The instance number - void init(const FwSizeType queueDepth, const NATIVE_INT_TYPE instance); + void init(const FwSizeType queueDepth, const FwEnumStoreType instance); //! \brief Set ping entry tables //! diff --git a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.cpp b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.cpp index b7574bb37a..58c8006c89 100644 --- a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.cpp +++ b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.cpp @@ -22,10 +22,6 @@ namespace Svc { -void PassiveRateGroupTester::init(NATIVE_INT_TYPE instance) { - PassiveRateGroupGTestBase::init(); -} - PassiveRateGroupTester::PassiveRateGroupTester(Svc::PassiveRateGroup& inst) : PassiveRateGroupGTestBase("testerbase", 100), m_impl(inst), m_callOrder(0) { this->clearPortCalls(); diff --git a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.hpp b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.hpp index c497ee53b8..3261f22961 100644 --- a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.hpp +++ b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.hpp @@ -25,8 +25,6 @@ namespace Svc { PassiveRateGroupTester(Svc::PassiveRateGroup& inst); virtual ~PassiveRateGroupTester(); - void init(NATIVE_INT_TYPE instance = 0); - void runNominal(U32 contexts[], U32 numContexts, NATIVE_INT_TYPE instance); private: diff --git a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.hpp b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.hpp index aba9bcda9f..9c69cf2852 100644 --- a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.hpp +++ b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.hpp @@ -25,8 +25,6 @@ namespace Svc { PassiveRateGroupTester(Svc::PassiveRateGroup& inst); virtual ~PassiveRateGroupTester(); - void init(NATIVE_INT_TYPE instance = 0); - void runNominal(NATIVE_INT_TYPE contexts[], U32 numContexts, NATIVE_INT_TYPE instance); private: diff --git a/Svc/PrmDb/test/ut/PrmDbImplTester.cpp b/Svc/PrmDb/test/ut/PrmDbImplTester.cpp index 8037c3018e..2643f97175 100644 --- a/Svc/PrmDb/test/ut/PrmDbImplTester.cpp +++ b/Svc/PrmDb/test/ut/PrmDbImplTester.cpp @@ -349,10 +349,6 @@ namespace Svc { } - void PrmDbImplTester::init(NATIVE_INT_TYPE instance) { - PrmDbGTestBase::init(); - } - PrmDbImplTester* PrmDbImplTester::PrmDbTestFile::s_tester = nullptr; void PrmDbImplTester::PrmDbTestFile::setTester(Svc::PrmDbImplTester *tester) { diff --git a/Svc/PrmDb/test/ut/PrmDbImplTester.hpp b/Svc/PrmDb/test/ut/PrmDbImplTester.hpp index 823e54bf60..1f3f8fe41b 100644 --- a/Svc/PrmDb/test/ut/PrmDbImplTester.hpp +++ b/Svc/PrmDb/test/ut/PrmDbImplTester.hpp @@ -28,9 +28,6 @@ namespace Svc { void runFileWriteError(); void runRefPrmFile(); - - void init(NATIVE_INT_TYPE instance = 0); - private: //! Handler for from_pingOut //! From 65e772154fd84f74db74dc1b7de39f2043363db0 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 16:43:07 -0700 Subject: [PATCH 05/34] NATIVE_ types from command dispatcher --- Svc/CmdDispatcher/CommandDispatcherImpl.cpp | 8 +++-- Svc/CmdDispatcher/CommandDispatcherImpl.hpp | 4 +-- .../test/ut/CommandDispatcherImplTester.cpp | 33 ++++++++++--------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Svc/CmdDispatcher/CommandDispatcherImpl.cpp b/Svc/CmdDispatcher/CommandDispatcherImpl.cpp index 770593033e..9a24786dd0 100644 --- a/Svc/CmdDispatcher/CommandDispatcherImpl.cpp +++ b/Svc/CmdDispatcher/CommandDispatcherImpl.cpp @@ -10,6 +10,10 @@ #include #include +// Check the CMD_DISPATCHER_DISPATCH_TABLE_SIZE and CMD_DISPATCHER_SEQUENCER_TABLE_SIZE for overflow +static_assert(CMD_DISPATCHER_DISPATCH_TABLE_SIZE <= std::numeric_limits::max(), "Opcode table limited to opcode range: 0 - 0xFFFFFFFF"); +static_assert(CMD_DISPATCHER_SEQUENCER_TABLE_SIZE <= std::numeric_limits::max(), "Sequencer table limited to range of U32"); + namespace Svc { CommandDispatcherImpl::CommandDispatcherImpl(const char* name) : CommandDispatcherComponentBase(name), @@ -58,7 +62,7 @@ namespace Svc { this->log_COMMAND_OpCodeError(opCode,response); } // look for command source - NATIVE_INT_TYPE portToCall = -1; + FwIndexType portToCall = -1; U32 context; for (U32 pending = 0; pending < FW_NUM_ARRAY_ELEMENTS(this->m_sequenceTracker); pending++) { if ( @@ -180,7 +184,7 @@ namespace Svc { void CommandDispatcherImpl::CMD_CLEAR_TRACKING_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { // clear tracking table - for (NATIVE_INT_TYPE entry = 0; entry < CMD_DISPATCHER_SEQUENCER_TABLE_SIZE; entry++) { + for (U32 entry = 0; entry < CMD_DISPATCHER_SEQUENCER_TABLE_SIZE; entry++) { this->m_sequenceTracker[entry].used = false; } this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK); diff --git a/Svc/CmdDispatcher/CommandDispatcherImpl.hpp b/Svc/CmdDispatcher/CommandDispatcherImpl.hpp index 77d355da4b..7426fc9eb8 100644 --- a/Svc/CmdDispatcher/CommandDispatcherImpl.hpp +++ b/Svc/CmdDispatcher/CommandDispatcherImpl.hpp @@ -133,7 +133,7 @@ namespace Svc { struct DispatchEntry { bool used; //!< if entry has been used yet U32 opcode; //!< opcode of entry - NATIVE_INT_TYPE port; //!< which port the entry invokes + FwIndexType port; //!< which port the entry invokes } m_entryTable[CMD_DISPATCHER_DISPATCH_TABLE_SIZE]; //!< table of dispatch entries //! \struct SequenceTracker @@ -154,7 +154,7 @@ namespace Svc { U32 seq; //!< command sequence number FwOpcodeType opCode; //!< opcode being tracked U32 context; //!< context passed by user - NATIVE_INT_TYPE callerPort; //!< port command source port + FwIndexType callerPort; //!< port command source port } m_sequenceTracker[CMD_DISPATCHER_SEQUENCER_TABLE_SIZE]; //!< sequence tracking port for command completions; U32 m_seq; //!< current command sequence number diff --git a/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp b/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp index 934a7e4ffc..e0643a6751 100644 --- a/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp +++ b/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp @@ -15,6 +15,7 @@ #include #include +static_assert(CMD_DISPATCHER_SEQUENCER_TABLE_SIZE + 1 <= std::numeric_limits::max(), "Unit test depends on CMD_DISPATCHER_SEQUENCER_TABLE_SIZE + 1 fiting int U32"); namespace Svc { CommandDispatcherImplTester::CommandDispatcherImplTester(Svc::CommandDispatcherImpl& inst) : @@ -42,13 +43,13 @@ namespace Svc { void CommandDispatcherImplTester::runNominalDispatch() { // verify dispatch table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } // verify sequence tracker table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { ASSERT_TRUE(this->m_impl.m_sequenceTracker[entry].used == false); } // clear reg events @@ -163,13 +164,13 @@ namespace Svc { void CommandDispatcherImplTester::runNopCommands() { // verify dispatch table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } // verify sequence tracker table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { ASSERT_TRUE(this->m_impl.m_sequenceTracker[entry].used == false); } @@ -325,13 +326,13 @@ namespace Svc { void CommandDispatcherImplTester::runInvalidOpcodeDispatch() { // verify dispatch table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } // verify sequence tracker table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { ASSERT_TRUE(this->m_impl.m_sequenceTracker[entry].used == false); } // clear reg events @@ -407,13 +408,13 @@ namespace Svc { void CommandDispatcherImplTester::runFailedCommand() { // verify dispatch table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } // verify sequence tracker table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { ASSERT_TRUE(this->m_impl.m_sequenceTracker[entry].used == false); } // clear reg events @@ -626,13 +627,13 @@ namespace Svc { void CommandDispatcherImplTester::runInvalidCommand() { // verify dispatch table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } // verify sequence tracker table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { ASSERT_TRUE(this->m_impl.m_sequenceTracker[entry].used == false); } // clear reg events @@ -661,13 +662,13 @@ namespace Svc { void CommandDispatcherImplTester::runOverflowCommands() { // verify dispatch table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } // verify sequence tracker table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { ASSERT_TRUE(this->m_impl.m_sequenceTracker[entry].used == false); } // clear reg events @@ -713,7 +714,7 @@ namespace Svc { ASSERT_EVENTS_OpCodeRegistered_SIZE(1); ASSERT_EVENTS_OpCodeRegistered(0,testOpCode,0,4); - for (NATIVE_UINT_TYPE disp = 0; disp < CMD_DISPATCHER_SEQUENCER_TABLE_SIZE + 1; disp++) { + for (U32 disp = 0; disp < CMD_DISPATCHER_SEQUENCER_TABLE_SIZE + 1; disp++) { // dispatch a test command U32 testCmdArg = 100; U32 testContext = 13; @@ -759,12 +760,12 @@ namespace Svc { void CommandDispatcherImplTester::runClearCommandTracking() { // verify dispatch table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } // verify sequence tracker table is empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { ASSERT_TRUE(this->m_impl.m_sequenceTracker[entry].used == false); } // clear reg events @@ -862,7 +863,7 @@ namespace Svc { // dispatch command from dispatcher to command handler ASSERT_EQ(Fw::QueuedComponentBase::MSG_DISPATCH_OK,this->m_impl.doDispatch()); // verify tracking table empty - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { + for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_sequenceTracker); entry++) { ASSERT_TRUE(this->m_impl.m_sequenceTracker[entry].used == false); } From 1ef205c3437c8ac9cb5e1208190739c10ea8b732 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 16:55:26 -0700 Subject: [PATCH 06/34] NATIVE_ types from ComQueue --- Svc/ComQueue/ComQueue.cpp | 7 +++++-- Svc/ComQueue/test/ut/ComQueueTester.cpp | 10 +++++----- Svc/ComQueue/test/ut/ComQueueTester.hpp | 6 +++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Svc/ComQueue/ComQueue.cpp b/Svc/ComQueue/ComQueue.cpp index 3a32e80315..4fa409a208 100644 --- a/Svc/ComQueue/ComQueue.cpp +++ b/Svc/ComQueue/ComQueue.cpp @@ -15,7 +15,8 @@ namespace Svc { // ---------------------------------------------------------------------- ComQueue ::QueueConfigurationTable ::QueueConfigurationTable() { - for (NATIVE_UINT_TYPE i = 0; i < FW_NUM_ARRAY_ELEMENTS(this->entries); i++) { + static_assert(std::numeric_limits::max() >= FW_NUM_ARRAY_ELEMENTS(this->entries), "Number of entries must fit into FwIndexType"); + for (FwIndexType i = 0; i < static_cast(FW_NUM_ARRAY_ELEMENTS(this->entries)); i++) { this->entries[i].priority = 0; this->entries[i].depth = 0; } @@ -82,7 +83,9 @@ void ComQueue::configure(QueueConfigurationTable queueConfig, // Message size is determined by the type of object being stored, which in turn is determined by the // index of the entry. Those lower than COM_PORT_COUNT are Fw::ComBuffers and those larger Fw::Buffer. entry.msgSize = (entryIndex < COM_PORT_COUNT) ? sizeof(Fw::ComBuffer) : sizeof(Fw::Buffer); - totalAllocation += static_cast(entry.depth * entry.msgSize); + // Overflow check + FW_ASSERT(std::numeric_limits::max() - (entry.depth * entry.msgSize) >= totalAllocation); + totalAllocation += entry.depth * entry.msgSize; currentPriorityIndex++; } } diff --git a/Svc/ComQueue/test/ut/ComQueueTester.cpp b/Svc/ComQueue/test/ut/ComQueueTester.cpp index ade2af127f..2d00bd8953 100644 --- a/Svc/ComQueue/test/ut/ComQueueTester.cpp +++ b/Svc/ComQueue/test/ut/ComQueueTester.cpp @@ -42,8 +42,8 @@ void ComQueueTester ::configure() { } void ComQueueTester ::sendByQueueNumber(Fw::Buffer& buffer, - NATIVE_INT_TYPE queueNum, - NATIVE_INT_TYPE& portNum, + FwIndexType queueNum, + FwIndexType& portNum, QueueType& queueType) { if (queueNum < ComQueue::COM_PORT_COUNT) { Fw::ComBuffer comBuffer(buffer.getData(), buffer.getSize()); @@ -63,7 +63,7 @@ void ComQueueTester ::emitOne() { dispatchAll(); } -void ComQueueTester ::emitOneAndCheck(NATIVE_UINT_TYPE expectedIndex, +void ComQueueTester ::emitOneAndCheck(FwIndexType expectedIndex, QueueType expectedType, Fw::ComBuffer& expectedCom, Fw::Buffer& expectedBuff) { @@ -213,7 +213,7 @@ void ComQueueTester::testExternalQueueOverflow() { QueueType overflow_type; FwIndexType portNum; // queue[portNum].depth + 2 to deliberately cause overflow and check throttle of exactly 1 - for (NATIVE_UINT_TYPE msgCount = 0; msgCount < configurationTable.entries[queueNum].depth + 2; msgCount++) { + for (FwSizeType msgCount = 0; msgCount < configurationTable.entries[queueNum].depth + 2; msgCount++) { sendByQueueNumber(buffer, queueNum, portNum, overflow_type); dispatchAll(); } @@ -244,7 +244,7 @@ void ComQueueTester::testExternalQueueOverflow() { ASSERT_EVENTS_QueueOverflow(1, overflow_type, portNum); // Drain the queue again such that we have a clean slate before the next queue - for (NATIVE_UINT_TYPE msgCount = 0; msgCount < configurationTable.entries[queueNum].depth; msgCount++) { + for (FwSizeType msgCount = 0; msgCount < configurationTable.entries[queueNum].depth; msgCount++) { emitOne(); } clearEvents(); diff --git a/Svc/ComQueue/test/ut/ComQueueTester.hpp b/Svc/ComQueue/test/ut/ComQueueTester.hpp index 3f742a48cf..9895bb8c0a 100644 --- a/Svc/ComQueue/test/ut/ComQueueTester.hpp +++ b/Svc/ComQueue/test/ut/ComQueueTester.hpp @@ -52,13 +52,13 @@ class ComQueueTester : public ComQueueGTestBase { void configure(); void sendByQueueNumber(Fw::Buffer& buffer, - NATIVE_INT_TYPE queueNumber, - NATIVE_INT_TYPE& portNum, + FwIndexType queueNumber, + FwIndexType& portNum, QueueType& queueType); void emitOne(); - void emitOneAndCheck(NATIVE_UINT_TYPE expectedIndex, + void emitOneAndCheck(FwIndexType expectedIndex, QueueType expectedType, Fw::ComBuffer& expectedCom, Fw::Buffer& expectedBuff); From 987cac894cd49dfd65dc8d28f103a6b99026b412 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 16:57:52 -0700 Subject: [PATCH 07/34] NATIVE_ types from CmdSplitter --- Svc/CmdSplitter/test/ut/CmdSplitterTester.cpp | 8 ++++---- Svc/CmdSplitter/test/ut/CmdSplitterTester.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Svc/CmdSplitter/test/ut/CmdSplitterTester.cpp b/Svc/CmdSplitter/test/ut/CmdSplitterTester.cpp index 2ca5493bf5..d948097cbf 100644 --- a/Svc/CmdSplitter/test/ut/CmdSplitterTester.cpp +++ b/Svc/CmdSplitter/test/ut/CmdSplitterTester.cpp @@ -67,7 +67,7 @@ void CmdSplitterTester ::test_local_routing() { Fw::ComBuffer testBuffer = this->build_command_around_opcode(local_opcode); U32 context = static_cast(STest::Pick::any()); - this->active_command_source = static_cast(STest::Pick::lowerUpper( + this->active_command_source = static_cast(STest::Pick::lowerUpper( 0, CmdSplitterPorts)); this->invoke_to_CmdBuff(this->active_command_source, testBuffer, context); ASSERT_from_RemoteCmd_SIZE(0); @@ -84,7 +84,7 @@ void CmdSplitterTester ::test_remote_routing() { Fw::ComBuffer testBuffer = this->build_command_around_opcode(remote_opcode); U32 context = static_cast(STest::Pick::any()); - this->active_command_source = static_cast(STest::Pick::lowerUpper( + this->active_command_source = static_cast(STest::Pick::lowerUpper( 0, CmdSplitterPorts)); this->invoke_to_CmdBuff(this->active_command_source, testBuffer, context); ASSERT_from_LocalCmd_SIZE(0); @@ -98,7 +98,7 @@ void CmdSplitterTester ::test_error_routing() { REQUIREMENT("SVC-CMD-SPLITTER-004"); Fw::ComBuffer testBuffer; // Intentionally left empty U32 context = static_cast(STest::Pick::any()); - this->active_command_source = static_cast(STest::Pick::lowerUpper( + this->active_command_source = static_cast(STest::Pick::lowerUpper( 0, CmdDispatcherSequencePorts)); this->invoke_to_CmdBuff(this->active_command_source, testBuffer, context); ASSERT_from_RemoteCmd_SIZE(0); @@ -116,7 +116,7 @@ void CmdSplitterTester ::test_response_forwarding() { Fw::CmdResponse response; response.e = static_cast(STest::Pick::lowerUpper(0, Fw::CmdResponse::NUM_CONSTANTS)); U32 cmdSeq = static_cast(STest::Pick::any()); - this->active_command_source = static_cast(STest::Pick::startLength( + this->active_command_source = static_cast(STest::Pick::startLength( 0, CmdDispatcherSequencePorts)); this->invoke_to_seqCmdStatus(this->active_command_source, opcode, cmdSeq, response); diff --git a/Svc/CmdSplitter/test/ut/CmdSplitterTester.hpp b/Svc/CmdSplitter/test/ut/CmdSplitterTester.hpp index 333409a89a..7a7c29cd3f 100644 --- a/Svc/CmdSplitter/test/ut/CmdSplitterTester.hpp +++ b/Svc/CmdSplitter/test/ut/CmdSplitterTester.hpp @@ -108,7 +108,7 @@ class CmdSplitterTester : public CmdSplitterGTestBase { //! The component under test //! CmdSplitter component; - NATIVE_INT_TYPE active_command_source; + FwIndexType active_command_source; }; } // end namespace Svc From a65403990b2f5360a5f9240bd5d4730f2366c486 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 17:01:21 -0700 Subject: [PATCH 08/34] U32 -> FwOpcodeType in CmdDispatcher --- Svc/CmdDispatcher/CommandDispatcherImpl.cpp | 8 ++++---- Svc/CmdDispatcher/CommandDispatcherImpl.hpp | 2 +- .../test/ut/CommandDispatcherImplTester.cpp | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Svc/CmdDispatcher/CommandDispatcherImpl.cpp b/Svc/CmdDispatcher/CommandDispatcherImpl.cpp index 9a24786dd0..e6413189d2 100644 --- a/Svc/CmdDispatcher/CommandDispatcherImpl.cpp +++ b/Svc/CmdDispatcher/CommandDispatcherImpl.cpp @@ -11,7 +11,7 @@ #include // Check the CMD_DISPATCHER_DISPATCH_TABLE_SIZE and CMD_DISPATCHER_SEQUENCER_TABLE_SIZE for overflow -static_assert(CMD_DISPATCHER_DISPATCH_TABLE_SIZE <= std::numeric_limits::max(), "Opcode table limited to opcode range: 0 - 0xFFFFFFFF"); +static_assert(CMD_DISPATCHER_DISPATCH_TABLE_SIZE <= std::numeric_limits::max(), "Opcode table limited to opcode range"); static_assert(CMD_DISPATCHER_SEQUENCER_TABLE_SIZE <= std::numeric_limits::max(), "Sequencer table limited to range of U32"); namespace Svc { @@ -31,7 +31,7 @@ namespace Svc { void CommandDispatcherImpl::compCmdReg_handler(FwIndexType portNum, FwOpcodeType opCode) { // search for an empty slot bool slotFound = false; - for (U32 slot = 0; slot < FW_NUM_ARRAY_ELEMENTS(this->m_entryTable); slot++) { + for (FwOpcodeType slot = 0; slot < FW_NUM_ARRAY_ELEMENTS(this->m_entryTable); slot++) { if ((not this->m_entryTable[slot].used) and (not slotFound)) { this->m_entryTable[slot].opcode = opCode; this->m_entryTable[slot].port = portNum; @@ -101,7 +101,7 @@ namespace Svc { } // search for opcode in dispatch table - U32 entry; + FwOpcodeType entry; bool entryFound = false; for (entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_entryTable); entry++) { @@ -184,7 +184,7 @@ namespace Svc { void CommandDispatcherImpl::CMD_CLEAR_TRACKING_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { // clear tracking table - for (U32 entry = 0; entry < CMD_DISPATCHER_SEQUENCER_TABLE_SIZE; entry++) { + for (FwOpcodeType entry = 0; entry < CMD_DISPATCHER_SEQUENCER_TABLE_SIZE; entry++) { this->m_sequenceTracker[entry].used = false; } this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK); diff --git a/Svc/CmdDispatcher/CommandDispatcherImpl.hpp b/Svc/CmdDispatcher/CommandDispatcherImpl.hpp index 7426fc9eb8..12c18d15f0 100644 --- a/Svc/CmdDispatcher/CommandDispatcherImpl.hpp +++ b/Svc/CmdDispatcher/CommandDispatcherImpl.hpp @@ -132,7 +132,7 @@ namespace Svc { struct DispatchEntry { bool used; //!< if entry has been used yet - U32 opcode; //!< opcode of entry + FwOpcodeType opcode; //!< opcode of entry FwIndexType port; //!< which port the entry invokes } m_entryTable[CMD_DISPATCHER_DISPATCH_TABLE_SIZE]; //!< table of dispatch entries diff --git a/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp b/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp index e0643a6751..34e23c365a 100644 --- a/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp +++ b/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp @@ -43,7 +43,7 @@ namespace Svc { void CommandDispatcherImplTester::runNominalDispatch() { // verify dispatch table is empty - for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (FwOpcodeType entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } @@ -164,7 +164,7 @@ namespace Svc { void CommandDispatcherImplTester::runNopCommands() { // verify dispatch table is empty - for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (FwOpcodeType entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } @@ -326,7 +326,7 @@ namespace Svc { void CommandDispatcherImplTester::runInvalidOpcodeDispatch() { // verify dispatch table is empty - for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (FwOpcodeType entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } @@ -408,7 +408,7 @@ namespace Svc { void CommandDispatcherImplTester::runFailedCommand() { // verify dispatch table is empty - for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (FwOpcodeType entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } @@ -627,7 +627,7 @@ namespace Svc { void CommandDispatcherImplTester::runInvalidCommand() { // verify dispatch table is empty - for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (FwOpcodeType entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } @@ -662,7 +662,7 @@ namespace Svc { void CommandDispatcherImplTester::runOverflowCommands() { // verify dispatch table is empty - for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (FwOpcodeType entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } @@ -760,7 +760,7 @@ namespace Svc { void CommandDispatcherImplTester::runClearCommandTracking() { // verify dispatch table is empty - for (U32 entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { + for (FwOpcodeType entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_entryTable); entry++) { ASSERT_TRUE(this->m_impl.m_entryTable[entry].used == false); } From 0f9188370ccc5158e3575e93b62eb75fab3cd1cb Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 17:24:55 -0700 Subject: [PATCH 09/34] NATIVE_ types in BufferManager --- .../BufferManagerComponentImpl.cpp | 24 +++++---- .../BufferManagerComponentImpl.hpp | 14 +++--- .../test/ut/BufferManagerTester.cpp | 50 +++++++++---------- config/BufferManagerComponentImplCfg.hpp | 4 +- 4 files changed, 47 insertions(+), 45 deletions(-) diff --git a/Svc/BufferManager/BufferManagerComponentImpl.cpp b/Svc/BufferManager/BufferManagerComponentImpl.cpp index 159be56eaf..7be32b5758 100644 --- a/Svc/BufferManager/BufferManagerComponentImpl.cpp +++ b/Svc/BufferManager/BufferManagerComponentImpl.cpp @@ -58,7 +58,7 @@ namespace Svc { if (not this->m_cleaned) { // walk through Fw::Buffer instances and delete them - for (NATIVE_UINT_TYPE entry = 0; entry < this->m_numStructs; entry++) { + for (U16 entry = 0; entry < this->m_numStructs; entry++) { this->m_buffers[entry].buff.~Buffer(); } this->m_cleaned = true; @@ -130,14 +130,14 @@ namespace Svc { Fw::Buffer BufferManagerComponentImpl :: bufferGetCallee_handler( const FwIndexType portNum, - U32 size + Fw::Buffer::SizeType size ) { // make sure component has been set up FW_ASSERT(this->m_setup); FW_ASSERT(m_buffers); // find smallest buffer based on size. - for (NATIVE_UINT_TYPE buff = 0; buff < this->m_numStructs; buff++) { + for (U16 buff = 0; buff < this->m_numStructs; buff++) { if ((not this->m_buffers[buff].allocated) and (size <= this->m_buffers[buff].size)) { this->m_buffers[buff].allocated = true; this->m_currBuffs++; @@ -159,7 +159,7 @@ namespace Svc { } void BufferManagerComponentImpl::setup( - NATIVE_UINT_TYPE mgrId, //!< manager ID + U16 mgrId, //!< manager ID FwEnumStoreType memId, //!< Memory segment identifier Fw::MemAllocator& allocator, //!< memory allocator const BufferBins& bins //!< Set of user bins @@ -174,14 +174,16 @@ namespace Svc { this->m_bufferBins = bins; // compute the amount of memory needed - NATIVE_UINT_TYPE memorySize = 0; // track needed memory + FwSizeType memorySize = 0; // track needed memory this->m_numStructs = 0; // size the number of tracking structs // walk through bins and add up the sizes - for (NATIVE_UINT_TYPE bin = 0; bin < BUFFERMGR_MAX_NUM_BINS; bin++) { + for (U16 bin = 0; bin < BUFFERMGR_MAX_NUM_BINS; bin++) { if (this->m_bufferBins.bins[bin].numBuffers) { memorySize += (this->m_bufferBins.bins[bin].bufferSize * this->m_bufferBins.bins[bin].numBuffers) + // allocate each set of buffer memory - (static_cast(sizeof(AllocatedBuffer)) * this->m_bufferBins.bins[bin].numBuffers); // allocate the structs to track the buffers + (static_cast(sizeof(AllocatedBuffer)) * this->m_bufferBins.bins[bin].numBuffers); // allocate the structs to track the buffers + // Total structures is bounded by U16 maximum value to fit in half of context (U32) + FW_ASSERT((std::numeric_limits::max() - this->m_numStructs) >= this->m_bufferBins.bins[bin].numBuffers); this->m_numStructs += this->m_bufferBins.bins[bin].numBuffers; } } @@ -205,13 +207,13 @@ namespace Svc { U8* bufferMem = reinterpret_cast(&this->m_buffers[this->m_numStructs]); // walk through entries and initialize them - NATIVE_UINT_TYPE currStruct = 0; - for (NATIVE_UINT_TYPE bin = 0; bin < BUFFERMGR_MAX_NUM_BINS; bin++) { + U16 currStruct = 0; + for (U16 bin = 0; bin < BUFFERMGR_MAX_NUM_BINS; bin++) { if (this->m_bufferBins.bins[bin].numBuffers) { - for (NATIVE_UINT_TYPE binEntry = 0; binEntry < this->m_bufferBins.bins[bin].numBuffers; binEntry++) { + for (U16 binEntry = 0; binEntry < this->m_bufferBins.bins[bin].numBuffers; binEntry++) { // placement new for Fw::Buffer instance. We don't need the new() return value, // because we know where the Fw::Buffer instance is - U32 context = (this->m_mgrId << 16) | currStruct; + U32 context = (static_cast(this->m_mgrId) << 16) | static_cast(currStruct); (void) new(&this->m_buffers[currStruct].buff) Fw::Buffer(bufferMem,this->m_bufferBins.bins[bin].bufferSize,context); this->m_buffers[currStruct].allocated = false; this->m_buffers[currStruct].memory = bufferMem; diff --git a/Svc/BufferManager/BufferManagerComponentImpl.hpp b/Svc/BufferManager/BufferManagerComponentImpl.hpp index dae6e86b8b..b0b91d2193 100644 --- a/Svc/BufferManager/BufferManagerComponentImpl.hpp +++ b/Svc/BufferManager/BufferManagerComponentImpl.hpp @@ -71,8 +71,8 @@ namespace Svc // Defines a buffer bin struct BufferBin { - NATIVE_UINT_TYPE bufferSize; //!< size of the buffers in this bin. Set to zero for unused bins. - NATIVE_UINT_TYPE numBuffers; //!< number of buffers in this bin. Set to zero for unused bins. + Fw::Buffer::SizeType bufferSize; //!< size of the buffers in this bin. Set to zero for unused bins. + U16 numBuffers; //!< number of buffers in this bin. Set to zero for unused bins. }; // Set of bins for the BufferManager @@ -84,7 +84,7 @@ namespace Svc //! set up configuration void setup( - NATIVE_UINT_TYPE mgrID, //!< ID of manager for buffer checking + U16 mgrID, //!< ID of manager for buffer checking FwEnumStoreType memID, //!< Memory segment identifier Fw::MemAllocator &allocator, //!< memory allocator. MUST be persistent for later deallocation. //! MUST persist past destructor if cleanup() not called explicitly. @@ -115,7 +115,7 @@ namespace Svc //! Fw::Buffer bufferGetCallee_handler( const FwIndexType portNum, /*!< The port number*/ - U32 size); + Fw::Buffer::SizeType size); //! Handler implementation for schedIn //! @@ -127,7 +127,7 @@ namespace Svc bool m_setup; //!< flag to indicate component has been setup bool m_cleaned; //!< flag to indicate memory has been cleaned up - NATIVE_UINT_TYPE m_mgrId; //!< stored manager ID for buffer checking + U16 m_mgrId; //!< stored manager ID for buffer checking BufferBins m_bufferBins; //!< copy of bins supplied by user @@ -135,14 +135,14 @@ namespace Svc { Fw::Buffer buff; //!< Buffer class to give to user U8 *memory; //!< pointer to memory buffer - U32 size; //!< size of the buffer + Fw::Buffer::SizeType size; //!< size of the buffer bool allocated; //!< this buffer has been allocated }; AllocatedBuffer *m_buffers; //!< pointer to allocated buffer space Fw::MemAllocator *m_allocator; //!< allocator for memory FwEnumStoreType m_memId; //!< identifier for allocator - NATIVE_UINT_TYPE m_numStructs; //!< number of allocated structs + U16 m_numStructs; //!< number of allocated structs // stats U32 m_highWater; //!< high watermark for allocations diff --git a/Svc/BufferManager/test/ut/BufferManagerTester.cpp b/Svc/BufferManager/test/ut/BufferManagerTester.cpp index 62a8991e92..e8995e91b1 100644 --- a/Svc/BufferManager/test/ut/BufferManagerTester.cpp +++ b/Svc/BufferManager/test/ut/BufferManagerTester.cpp @@ -20,16 +20,16 @@ // Bin buffer sizes/numbers -static const NATIVE_UINT_TYPE BIN0_BUFFER_SIZE = 10; -static const NATIVE_UINT_TYPE BIN0_NUM_BUFFERS = 2; -static const NATIVE_UINT_TYPE BIN1_BUFFER_SIZE = 12; -static const NATIVE_UINT_TYPE BIN1_NUM_BUFFERS = 4; -static const NATIVE_UINT_TYPE BIN2_BUFFER_SIZE = 100; -static const NATIVE_UINT_TYPE BIN2_NUM_BUFFERS = 3; +static const Fw::Buffer::SizeType BIN0_BUFFER_SIZE = 10; +static const U16 BIN0_NUM_BUFFERS = 2; +static const Fw::Buffer::SizeType BIN1_BUFFER_SIZE = 12; +static const U16 BIN1_NUM_BUFFERS = 4; +static const Fw::Buffer::SizeType BIN2_BUFFER_SIZE = 100; +static const U16 BIN2_NUM_BUFFERS = 3; // Other constants -static const NATIVE_UINT_TYPE MEM_ID = 49; -static const NATIVE_UINT_TYPE MGR_ID = 32; +static const FwEnumStoreType MEM_ID = 49; +static const U16 MGR_ID = 32; // Define our own instrumented allocator for testing class TestAllocator: public Fw::MemAllocator { @@ -63,11 +63,11 @@ class TestAllocator: public Fw::MemAllocator { this->m_alloc.deallocate(identifier,ptr); } - NATIVE_UINT_TYPE getId() { + FwEnumStoreType getId() { return this->m_reqId; } - NATIVE_UINT_TYPE getSize() { + FwSizeType getSize() { return this->m_reqSize; } @@ -142,7 +142,7 @@ namespace Svc { REQUIREMENT("FPRIME-BM-005"); // check that enough memory was requested - NATIVE_UINT_TYPE memSize = + FwSizeType memSize = (BIN0_NUM_BUFFERS + BIN1_NUM_BUFFERS + BIN2_NUM_BUFFERS)*sizeof(Svc::BufferManagerComponentImpl::AllocatedBuffer) + (BIN0_NUM_BUFFERS*BIN0_BUFFER_SIZE + BIN1_NUM_BUFFERS*BIN1_BUFFER_SIZE + BIN2_NUM_BUFFERS*BIN2_BUFFER_SIZE); ASSERT_EQ(memSize,alloc.getSize()); @@ -154,7 +154,7 @@ namespace Svc { U8 *mem = reinterpret_cast(alloc.getMem()) + this->component.m_numStructs*sizeof(Svc::BufferManagerComponentImpl::AllocatedBuffer); ; // check the buffer properties - for (NATIVE_UINT_TYPE entry = 0; entry < this->component.m_numStructs; entry++) { + for (U16 entry = 0; entry < this->component.m_numStructs; entry++) { // check context ID ASSERT_EQ(this->component.m_buffers[entry].buff.getContext(),((MGR_ID << 16)| entry)); // check allocation state @@ -199,7 +199,7 @@ namespace Svc { Fw::Buffer buffs[BIN1_NUM_BUFFERS]; - for (NATIVE_UINT_TYPE b=0; binvoke_to_bufferGetCallee(0,BIN1_BUFFER_SIZE); // check allocation state @@ -240,8 +240,8 @@ namespace Svc { bool returned[BIN1_NUM_BUFFERS] = {false}; - for (NATIVE_UINT_TYPE b=0; bcomponent.m_numStructs; b++) { + for (U16 b=0; bcomponent.m_numStructs; b++) { ASSERT_FALSE(this->component.m_buffers[b].allocated); } @@ -304,7 +304,7 @@ namespace Svc { // BufferManager should be able to provide the whole pool worth of buffers // for a requested size smaller than the smallest bin. - for (NATIVE_UINT_TYPE b=0; binvoke_to_bufferGetCallee(0,BIN0_BUFFER_SIZE); // check allocation state @@ -339,7 +339,7 @@ namespace Svc { this->clearHistory(); - for (NATIVE_UINT_TYPE b=0; binvoke_to_bufferSendIn(0,buffs[b]); // check allocation state @@ -368,7 +368,7 @@ namespace Svc { this->clearHistory(); // all buffers should be deallocated - for (NATIVE_UINT_TYPE b=0; bcomponent.m_numStructs; b++) { + for (U16 b=0; bcomponent.m_numStructs; b++) { ASSERT_FALSE(this->component.m_buffers[b].allocated); } @@ -378,7 +378,7 @@ namespace Svc { // BufferManager should be able to provide the BIN1 and BIN2 worth of buffers // for a requested size just smaller than the BIN1 size - for (NATIVE_UINT_TYPE b=0; binvoke_to_bufferGetCallee(0,BIN1_BUFFER_SIZE); // check allocation state - should be allocating from bin 1 @@ -404,7 +404,7 @@ namespace Svc { // clear histories this->clearHistory(); - for (NATIVE_UINT_TYPE b=0; binvoke_to_bufferSendIn(0,buffs[b]); // check allocation state - should be freeing from bin 1 @@ -430,14 +430,14 @@ namespace Svc { this->clearHistory(); // all buffers should be deallocated - for (NATIVE_UINT_TYPE b=0; bcomponent.m_numStructs; b++) { + for (U16 b=0; bcomponent.m_numStructs; b++) { ASSERT_FALSE(this->component.m_buffers[b].allocated); } // BufferManager should be able to provide the BIN2 worth of buffers // for a requested size just smaller than the BIN2 size - for (NATIVE_UINT_TYPE b=0; binvoke_to_bufferGetCallee(0,BIN2_BUFFER_SIZE); // check allocation state - should be allocating from bin 1 @@ -464,7 +464,7 @@ namespace Svc { this->clearHistory(); - for (NATIVE_UINT_TYPE b=0; binvoke_to_bufferSendIn(0,buffs[b]); // check allocation state - should be freeing from bin 1 @@ -487,7 +487,7 @@ namespace Svc { ASSERT_TLM_EmptyBuffs(0,3); // all buffers should be deallocated - for (NATIVE_UINT_TYPE b=0; bcomponent.m_numStructs; b++) { + for (U16 b=0; bcomponent.m_numStructs; b++) { ASSERT_FALSE(this->component.m_buffers[b].allocated); } diff --git a/config/BufferManagerComponentImplCfg.hpp b/config/BufferManagerComponentImplCfg.hpp index c3b4277953..7c74bf621e 100644 --- a/config/BufferManagerComponentImplCfg.hpp +++ b/config/BufferManagerComponentImplCfg.hpp @@ -4,8 +4,8 @@ #include namespace Svc { - static const NATIVE_UINT_TYPE BUFFERMGR_MAX_NUM_BINS = 10; + static const U16 BUFFERMGR_MAX_NUM_BINS = 10; } -#endif // __BUFFERMANAGERCOMPONENTIMPLCFG_HPP__ \ No newline at end of file +#endif // __BUFFERMANAGERCOMPONENTIMPLCFG_HPP__ From 6986c6b6bec796d409dbe177885de8d62a4563a8 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 17:31:54 -0700 Subject: [PATCH 10/34] NATIVE_ types in LinuxTimer --- Svc/LinuxTimer/LinuxTimerComponentImpl.hpp | 2 +- Svc/LinuxTimer/LinuxTimerComponentImplTaskDelay.cpp | 3 ++- Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp | 2 +- Svc/LinuxTimer/test/ut/LinuxTimerTester.hpp | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Svc/LinuxTimer/LinuxTimerComponentImpl.hpp b/Svc/LinuxTimer/LinuxTimerComponentImpl.hpp index 193bb6daa5..bb81a6cd39 100644 --- a/Svc/LinuxTimer/LinuxTimerComponentImpl.hpp +++ b/Svc/LinuxTimer/LinuxTimerComponentImpl.hpp @@ -39,7 +39,7 @@ namespace Svc { ~LinuxTimerComponentImpl(); //! Start timer - void startTimer(NATIVE_INT_TYPE interval); //!< interval in milliseconds + void startTimer(FwSizeType interval); //!< interval in milliseconds //! Quit timer void quit(); diff --git a/Svc/LinuxTimer/LinuxTimerComponentImplTaskDelay.cpp b/Svc/LinuxTimer/LinuxTimerComponentImplTaskDelay.cpp index f67355b461..f2ff6cbf40 100644 --- a/Svc/LinuxTimer/LinuxTimerComponentImplTaskDelay.cpp +++ b/Svc/LinuxTimer/LinuxTimerComponentImplTaskDelay.cpp @@ -17,7 +17,8 @@ namespace Svc { - void LinuxTimerComponentImpl::startTimer(NATIVE_INT_TYPE interval) { + void LinuxTimerComponentImpl::startTimer(FwSizeType interval) { + FW_ASSERT(std::numeric_limits::max()/1000 >= interval); // Overflow while (true) { Os::Task::delay(Fw::TimeInterval(static_cast(interval/1000), static_cast((interval % 1000) * 1000))); this->m_mutex.lock(); diff --git a/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp b/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp index d4a3923e5c..2d027d0066 100644 --- a/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp +++ b/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp @@ -20,7 +20,7 @@ namespace Svc { - void LinuxTimerComponentImpl::startTimer(NATIVE_INT_TYPE interval) { + void LinuxTimerComponentImpl::startTimer(FwSizeType interval) { int fd; struct itimerspec itval; diff --git a/Svc/LinuxTimer/test/ut/LinuxTimerTester.hpp b/Svc/LinuxTimer/test/ut/LinuxTimerTester.hpp index bc6bec548c..0299610737 100644 --- a/Svc/LinuxTimer/test/ut/LinuxTimerTester.hpp +++ b/Svc/LinuxTimer/test/ut/LinuxTimerTester.hpp @@ -83,7 +83,7 @@ namespace Svc { //! LinuxTimerComponentImpl component; - NATIVE_INT_TYPE m_numCalls; + U32 m_numCalls; }; From 61481eb57336766c8c1b61156877704ef279b3e5 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 17:55:51 -0700 Subject: [PATCH 11/34] NATIVE_ types from BufferAccumulator and renabling UT --- Svc/BufferAccumulator/ArrayFIFOBuffer.cpp | 8 ++--- Svc/BufferAccumulator/BufferAccumulator.cpp | 20 ++++++------- Svc/BufferAccumulator/BufferAccumulator.hpp | 20 ++++++------- Svc/BufferAccumulator/CMakeLists.txt | 2 +- Svc/BufferAccumulator/test/ut/Accumulate.cpp | 6 ++-- .../test/ut/BufferAccumulatorTester.cpp | 4 +-- Svc/BufferAccumulator/test/ut/Drain.cpp | 14 ++++----- Svc/BufferAccumulator/test/ut/Errors.cpp | 30 +++++++++---------- 8 files changed, 52 insertions(+), 52 deletions(-) diff --git a/Svc/BufferAccumulator/ArrayFIFOBuffer.cpp b/Svc/BufferAccumulator/ArrayFIFOBuffer.cpp index 53a3d660e3..8d3d619305 100644 --- a/Svc/BufferAccumulator/ArrayFIFOBuffer.cpp +++ b/Svc/BufferAccumulator/ArrayFIFOBuffer.cpp @@ -37,12 +37,12 @@ BufferAccumulator::ArrayFIFOBuffer ::~ArrayFIFOBuffer() {} // ---------------------------------------------------------------------- void BufferAccumulator::ArrayFIFOBuffer ::init(Fw::Buffer* const elements, - NATIVE_UINT_TYPE capacity) { + FwSizeType capacity) { this->m_elements = elements; this->m_capacity = capacity; // Construct all elements - for (NATIVE_UINT_TYPE idx = 0; idx < capacity; idx++) { + for (FwSizeType idx = 0; idx < capacity; idx++) { new (&this->m_elements[idx]) Fw::Buffer; } } @@ -91,11 +91,11 @@ bool BufferAccumulator::ArrayFIFOBuffer ::dequeue(Fw::Buffer& e) { return status; } -U32 BufferAccumulator::ArrayFIFOBuffer ::getSize() const { +FwSizeType BufferAccumulator::ArrayFIFOBuffer ::getSize() const { return this->m_size; } -U32 BufferAccumulator::ArrayFIFOBuffer ::getCapacity() const { +FwSizeType BufferAccumulator::ArrayFIFOBuffer ::getCapacity() const { return this->m_capacity; } diff --git a/Svc/BufferAccumulator/BufferAccumulator.cpp b/Svc/BufferAccumulator/BufferAccumulator.cpp index c977a6b979..8a905faf49 100644 --- a/Svc/BufferAccumulator/BufferAccumulator.cpp +++ b/Svc/BufferAccumulator/BufferAccumulator.cpp @@ -47,7 +47,7 @@ BufferAccumulator ::~BufferAccumulator() {} void BufferAccumulator ::allocateQueue( FwEnumStoreType identifier, Fw::MemAllocator& allocator, - NATIVE_UINT_TYPE maxNumBuffers //!< The maximum number of buffers + FwSizeType maxNumBuffers //!< The maximum number of buffers ) { this->m_allocatorId = identifier; @@ -90,7 +90,7 @@ void BufferAccumulator ::bufferSendInFill_handler(const FwIndexType portNum, this->sendStoredBuffer(); } - this->tlmWrite_BA_NumQueuedBuffers(this->m_bufferQueue.getSize()); + this->tlmWrite_BA_NumQueuedBuffers(static_cast(this->m_bufferQueue.getSize())); } void BufferAccumulator ::bufferSendInReturn_handler( @@ -145,7 +145,7 @@ void BufferAccumulator ::BA_DrainBuffers_cmdHandler( BufferAccumulator_BlockMode blockMode) { if (this->m_numDrained < this->m_numToDrain) { - this->log_WARNING_HI_BA_StillDraining(this->m_numDrained, this->m_numToDrain); + this->log_WARNING_HI_BA_StillDraining(static_cast(this->m_numDrained), static_cast(this->m_numToDrain)); this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::BUSY); return; } @@ -165,14 +165,14 @@ void BufferAccumulator ::BA_DrainBuffers_cmdHandler( this->m_opCode = opCode; this->m_cmdSeq = cmdSeq; this->m_numDrained = 0; - this->m_numToDrain = numToDrain; + this->m_numToDrain = static_cast(numToDrain); if (blockMode == BufferAccumulator_BlockMode::NOBLOCK) { - U32 numBuffers = this->m_bufferQueue.getSize(); + FwSizeType numBuffers = this->m_bufferQueue.getSize(); - if (numBuffers < numToDrain) { + if (numBuffers < static_cast(numToDrain)) { this->m_numToDrain = numBuffers; - this->log_WARNING_LO_BA_NonBlockDrain(this->m_numToDrain, numToDrain); + this->log_WARNING_LO_BA_NonBlockDrain(static_cast(this->m_numToDrain), numToDrain); } /* OK if there were 0 buffers queued, and we @@ -210,7 +210,7 @@ void BufferAccumulator ::sendStoredBuffer() { this->m_waitForBuffer = true; this->m_send = false; } else if (this->m_numToDrain > 0) { - this->log_WARNING_HI_BA_DrainStalled(this->m_numDrained, this->m_numToDrain); + this->log_WARNING_HI_BA_DrainStalled(static_cast(this->m_numDrained), static_cast(this->m_numToDrain)); } } @@ -221,7 +221,7 @@ void BufferAccumulator ::sendStoredBuffer() { if ((this->m_numToDrain > 0) && // we are doing a partial drain (this->m_numDrained == this->m_numToDrain)) { // AND we just finished draining // - this->log_ACTIVITY_HI_BA_PartialDrainDone(this->m_numDrained); + this->log_ACTIVITY_HI_BA_PartialDrainDone(static_cast(this->m_numDrained)); // reset counters for partial buffer drain this->m_numToDrain = 0; this->m_numDrained = 0; @@ -229,7 +229,7 @@ void BufferAccumulator ::sendStoredBuffer() { this->cmdResponse_out(this->m_opCode, this->m_cmdSeq, Fw::CmdResponse::OK); } - this->tlmWrite_BA_NumQueuedBuffers(this->m_bufferQueue.getSize()); + this->tlmWrite_BA_NumQueuedBuffers(static_cast(this->m_bufferQueue.getSize())); } } // namespace Svc diff --git a/Svc/BufferAccumulator/BufferAccumulator.hpp b/Svc/BufferAccumulator/BufferAccumulator.hpp index 1c7e2e686b..2b5368e453 100644 --- a/Svc/BufferAccumulator/BufferAccumulator.hpp +++ b/Svc/BufferAccumulator/BufferAccumulator.hpp @@ -37,7 +37,7 @@ namespace Svc { ~ArrayFIFOBuffer(); void init(Fw::Buffer* const elements, //!< The array elements - NATIVE_UINT_TYPE capacity //!< The capacity + FwSizeType capacity //!< The capacity ); //! Enqueue an index. @@ -53,11 +53,11 @@ namespace Svc { //! Get the size of the queue //! \return The size - U32 getSize() const; + FwSizeType getSize() const; //! Get the capacity of the queue //! \return The capacity - U32 getCapacity() const; + FwSizeType getCapacity() const; PRIVATE: @@ -69,16 +69,16 @@ namespace Svc { Fw::Buffer* m_elements; //! The capacity of the queue - NATIVE_UINT_TYPE m_capacity; + FwSizeType m_capacity; //! The enqueue index - NATIVE_UINT_TYPE m_enqueueIndex; + FwSizeType m_enqueueIndex; //! The dequeue index - NATIVE_UINT_TYPE m_dequeueIndex; + FwSizeType m_dequeueIndex; //! The size of the queue - NATIVE_UINT_TYPE m_size; + FwSizeType m_size; }; // class ArrayFIFOBuffer public: @@ -104,7 +104,7 @@ namespace Svc { //! and init, but before task is spawned. void allocateQueue( FwEnumStoreType identifier, Fw::MemAllocator& allocator, - NATIVE_UINT_TYPE maxNumBuffers //!< The maximum number of buffers + FwSizeType maxNumBuffers //!< The maximum number of buffers ); //! Return allocated queue. Should be done during shutdown @@ -192,10 +192,10 @@ namespace Svc { U32 m_numWarnings; //! The number of buffers drained in a partial drain command - U32 m_numDrained; + FwSizeType m_numDrained; //! The number of buffers TO drain in a partial drain command - U32 m_numToDrain; + FwSizeType m_numToDrain; //! The DrainBuffers opcode to respond to FwOpcodeType m_opCode; diff --git a/Svc/BufferAccumulator/CMakeLists.txt b/Svc/BufferAccumulator/CMakeLists.txt index 095b75d9b5..eb56ed9298 100644 --- a/Svc/BufferAccumulator/CMakeLists.txt +++ b/Svc/BufferAccumulator/CMakeLists.txt @@ -26,5 +26,5 @@ set(UT_SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/test/ut/Health.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/BufferAccumulatorMain.cpp" ) -#register_fprime_ut() +register_fprime_ut() diff --git a/Svc/BufferAccumulator/test/ut/Accumulate.cpp b/Svc/BufferAccumulator/test/ut/Accumulate.cpp index e0ce7f017b..b78f917091 100644 --- a/Svc/BufferAccumulator/test/ut/Accumulate.cpp +++ b/Svc/BufferAccumulator/test/ut/Accumulate.cpp @@ -21,10 +21,10 @@ namespace Accumulate { // ---------------------------------------------------------------------- void BufferAccumulatorTester ::OK() { - ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.m_mode.e); this->sendCmd_BA_SetMode(0, 0, BufferAccumulator_OpState::ACCUMULATE); this->component.doDispatch(); - ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.m_mode.e); ASSERT_FROM_PORT_HISTORY_SIZE(0); Fw::Buffer buffers[MAX_NUM_BUFFERS]; @@ -41,7 +41,7 @@ void BufferAccumulatorTester ::OK() { this->sendCmd_BA_SetMode(0, 0, BufferAccumulator_OpState::DRAIN); this->component.doDispatch(); - ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.m_mode.e); ASSERT_FROM_PORT_HISTORY_SIZE(1); ASSERT_from_bufferSendOutDrain_SIZE(1); ASSERT_from_bufferSendOutDrain(0, buffers[0]); diff --git a/Svc/BufferAccumulator/test/ut/BufferAccumulatorTester.cpp b/Svc/BufferAccumulator/test/ut/BufferAccumulatorTester.cpp index 4f5231e1f9..ab9a807bbc 100644 --- a/Svc/BufferAccumulator/test/ut/BufferAccumulatorTester.cpp +++ b/Svc/BufferAccumulator/test/ut/BufferAccumulatorTester.cpp @@ -41,8 +41,8 @@ BufferAccumulatorTester ::BufferAccumulatorTester(bool doAllocateQueue) // Witch to BufferAccumulator_OpState::DRAIN at start so we don't have to // change ut - component.mode = BufferAccumulator_OpState::DRAIN; - component.send = true; + component.m_mode = BufferAccumulator_OpState::DRAIN; + component.m_send = true; if (this->doAllocateQueue) { Fw::MallocAllocator buffAccumMallocator; diff --git a/Svc/BufferAccumulator/test/ut/Drain.cpp b/Svc/BufferAccumulator/test/ut/Drain.cpp index b24065e3a4..d96d2ad36a 100644 --- a/Svc/BufferAccumulator/test/ut/Drain.cpp +++ b/Svc/BufferAccumulator/test/ut/Drain.cpp @@ -24,7 +24,7 @@ namespace Drain { // ---------------------------------------------------------------------- void BufferAccumulatorTester ::OK() { - ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.m_mode.e); Fw::Buffer buffers[MAX_NUM_BUFFERS]; // Buffer needs a valid pointer U8* data = new U8[10]; @@ -52,7 +52,7 @@ void BufferAccumulatorTester ::PartialDrainOK() { ASSERT_CMD_RESPONSE_SIZE(1); ASSERT_CMD_RESPONSE(0, BufferAccumulator::OPCODE_BA_SETMODE, 0, Fw::CmdResponse::OK); - ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.m_mode.e); ASSERT_FROM_PORT_HISTORY_SIZE(0); Fw::Buffer buffers[MAX_NUM_BUFFERS]; @@ -144,10 +144,10 @@ void BufferAccumulatorTester ::PartialDrainOK() { ASSERT_FROM_PORT_HISTORY_SIZE(0); } - ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.m_mode.e); ASSERT_FROM_PORT_HISTORY_SIZE(0); - ASSERT_EQ(0u, this->component.numDrained); - ASSERT_EQ(0u, this->component.numToDrain); + ASSERT_EQ(0u, this->component.m_numDrained); + ASSERT_EQ(0u, this->component.m_numToDrain); ASSERT_EVENTS_BA_PartialDrainDone_SIZE(0); this->sendCmd_BA_DrainBuffers(0, 0, MAX_NUM_BUFFERS, @@ -161,8 +161,8 @@ void BufferAccumulatorTester ::PartialDrainOK() { buffers[i] = b; if (i + 1 < MAX_NUM_BUFFERS) { - ASSERT_EQ(i + 1, this->component.numDrained); - ASSERT_EQ(MAX_NUM_BUFFERS, this->component.numToDrain); + ASSERT_EQ(i + 1, this->component.m_numDrained); + ASSERT_EQ(MAX_NUM_BUFFERS, this->component.m_numToDrain); ASSERT_EVENTS_BA_PartialDrainDone_SIZE(0); } diff --git a/Svc/BufferAccumulator/test/ut/Errors.cpp b/Svc/BufferAccumulator/test/ut/Errors.cpp index 5d8047ebcf..275028c007 100644 --- a/Svc/BufferAccumulator/test/ut/Errors.cpp +++ b/Svc/BufferAccumulator/test/ut/Errors.cpp @@ -21,32 +21,32 @@ namespace Errors { // ---------------------------------------------------------------------- void BufferAccumulatorTester ::PartialDrain() { - ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.m_mode.e); this->sendCmd_BA_DrainBuffers(0, 0, 1, BufferAccumulator_BlockMode::BLOCK); this->component.doDispatch(); // will fail - we are still in // BufferAccumulator_OpState::DRAIN mode - ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.m_mode.e); ASSERT_FROM_PORT_HISTORY_SIZE(0); ASSERT_EVENTS_BA_AlreadyDraining_SIZE(1); - ASSERT_EQ(0u, this->component.numDrained); - ASSERT_EQ(0u, this->component.numToDrain); + ASSERT_EQ(0u, this->component.m_numDrained); + ASSERT_EQ(0u, this->component.m_numToDrain); this->sendCmd_BA_SetMode(0, 0, BufferAccumulator_OpState::ACCUMULATE); this->component.doDispatch(); - ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.m_mode.e); ASSERT_FROM_PORT_HISTORY_SIZE(0); this->sendCmd_BA_DrainBuffers(0, 0, 10, BufferAccumulator_BlockMode::BLOCK); this->component.doDispatch(); // will succeed - now we are in ACCUMULATE - ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.m_mode.e); ASSERT_FROM_PORT_HISTORY_SIZE( 0); // would be first buffer out, but we are empty ASSERT_EVENTS_BA_DrainStalled_SIZE(1); ASSERT_EVENTS_BA_DrainStalled(0, 0u, 10u); ASSERT_EVENTS_BA_PartialDrainDone_SIZE(0); // partial drain not done - ASSERT_EQ(true, this->component.send); - ASSERT_EQ(0u, this->component.numDrained); - ASSERT_EQ(10u, this->component.numToDrain); + ASSERT_EQ(true, this->component.m_send); + ASSERT_EQ(0u, this->component.m_numDrained); + ASSERT_EQ(10u, this->component.m_numToDrain); this->sendCmd_BA_DrainBuffers(0, 0, 1, BufferAccumulator_BlockMode::BLOCK); this->component @@ -54,11 +54,11 @@ void BufferAccumulatorTester ::PartialDrain() { ASSERT_EVENTS_BA_StillDraining_SIZE(1); ASSERT_EVENTS_BA_StillDraining(0, 0u, 10u); ASSERT_EVENTS_BA_PartialDrainDone_SIZE(0); // partial drain not done - ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.m_mode.e); ASSERT_FROM_PORT_HISTORY_SIZE(0); - ASSERT_EQ(true, this->component.send); - ASSERT_EQ(0u, this->component.numDrained); - ASSERT_EQ(10u, this->component.numToDrain); + ASSERT_EQ(true, this->component.m_send); + ASSERT_EQ(0u, this->component.m_numDrained); + ASSERT_EQ(10u, this->component.m_numToDrain); } void BufferAccumulatorTester ::QueueFull() { @@ -67,10 +67,10 @@ void BufferAccumulatorTester ::QueueFull() { Fw::Buffer buffer(data, size); // Go to Accumulate mode - ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.m_mode.e); this->sendCmd_BA_SetMode(0, 0, BufferAccumulator_OpState::ACCUMULATE); this->component.doDispatch(); - ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.mode.e); + ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.m_mode.e); ASSERT_FROM_PORT_HISTORY_SIZE(0); // Fill up the buffer queue From 985a2c381541d082ffd94e2dc06dae53f2044997 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 18:07:53 -0700 Subject: [PATCH 12/34] NATIVE_ types from TlmChan --- Svc/TlmChan/TlmChan.cpp | 19 +++++++++------ Svc/TlmChan/TlmChan.hpp | 6 ++--- Svc/TlmChan/test/ut/TlmChanTester.cpp | 34 +++++++++++++-------------- Svc/TlmChan/test/ut/TlmChanTester.hpp | 4 ++-- 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/Svc/TlmChan/TlmChan.cpp b/Svc/TlmChan/TlmChan.cpp index 03445c8cd4..8a876f9e65 100644 --- a/Svc/TlmChan/TlmChan.cpp +++ b/Svc/TlmChan/TlmChan.cpp @@ -16,14 +16,19 @@ namespace Svc { +// Definition of TLMCHAN_HASH_BUCKETS is >= number of telemetry ids +static_assert(std::numeric_limits::max() >= TLMCHAN_HASH_BUCKETS, "Cannot have more hash buckets than maximum telemetry ids in the system"); +// TLMCHAN_HASH_BUCKETS >= TLMCHAN_NUM_TLM_HASH_SLOTS >= 0 +static_assert(std::numeric_limits::max() >= TLMCHAN_NUM_TLM_HASH_SLOTS, "Cannot have more hash slots than maximum telemetry ids in the system"); + TlmChan::TlmChan(const char* name) : TlmChanComponentBase(name), m_activeBuffer(0) { // clear slot pointers - for (NATIVE_UINT_TYPE entry = 0; entry < TLMCHAN_NUM_TLM_HASH_SLOTS; entry++) { + for (FwChanIdType entry = 0; entry < TLMCHAN_NUM_TLM_HASH_SLOTS; entry++) { this->m_tlmEntries[0].slots[entry] = nullptr; this->m_tlmEntries[1].slots[entry] = nullptr; } // clear buckets - for (NATIVE_UINT_TYPE entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) { + for (FwChanIdType entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) { this->m_tlmEntries[0].buckets[entry].used = false; this->m_tlmEntries[0].buckets[entry].updated = false; this->m_tlmEntries[0].buckets[entry].bucketNo = entry; @@ -42,7 +47,7 @@ TlmChan::TlmChan(const char* name) : TlmChanComponentBase(name), m_activeBuffer( TlmChan::~TlmChan() {} -NATIVE_UINT_TYPE TlmChan::doHash(FwChanIdType id) { +FwChanIdType TlmChan::doHash(FwChanIdType id) { return (id % TLMCHAN_HASH_MOD_VALUE) % TLMCHAN_NUM_TLM_HASH_SLOTS; } @@ -54,11 +59,11 @@ void TlmChan::pingIn_handler(const FwIndexType portNum, U32 key) { void TlmChan::TlmGet_handler(FwIndexType portNum, FwChanIdType id, Fw::Time& timeTag, Fw::TlmBuffer& val) { // Compute index for entry - NATIVE_UINT_TYPE index = this->doHash(id); + FwChanIdType index = this->doHash(id); // Search to see if channel has been stored TlmEntry* entryToUse = this->m_tlmEntries[this->m_activeBuffer].slots[index]; - for (NATIVE_UINT_TYPE bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { + for (FwChanIdType bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { if (entryToUse) { // If bucket exists, check id if (entryToUse->id == id) { break; @@ -81,14 +86,14 @@ void TlmChan::TlmGet_handler(FwIndexType portNum, FwChanIdType id, Fw::Time& tim void TlmChan::TlmRecv_handler(FwIndexType portNum, FwChanIdType id, Fw::Time& timeTag, Fw::TlmBuffer& val) { // Compute index for entry - NATIVE_UINT_TYPE index = this->doHash(id); + FwChanIdType index = this->doHash(id); TlmEntry* entryToUse = nullptr; TlmEntry* prevEntry = nullptr; // Search to see if channel has already been stored or a bucket needs to be added if (this->m_tlmEntries[this->m_activeBuffer].slots[index]) { entryToUse = this->m_tlmEntries[this->m_activeBuffer].slots[index]; - for (NATIVE_UINT_TYPE bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { + for (FwChanIdType bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { if (entryToUse) { if (entryToUse->id == id) { // found the matching entry break; diff --git a/Svc/TlmChan/TlmChan.hpp b/Svc/TlmChan/TlmChan.hpp index 47df17b1cc..c4f6fb2bbf 100644 --- a/Svc/TlmChan/TlmChan.hpp +++ b/Svc/TlmChan/TlmChan.hpp @@ -26,7 +26,7 @@ class TlmChan final : public TlmChanComponentBase { PROTECTED: // can be overridden for alternate algorithms - virtual NATIVE_UINT_TYPE doHash(FwChanIdType id); + virtual FwChanIdType doHash(FwChanIdType id); PRIVATE: // Port functions @@ -46,13 +46,13 @@ class TlmChan final : public TlmChanComponentBase { Fw::TlmBuffer buffer; //!< buffer to store serialized telemetry tlmEntry* next; //!< pointer to next bucket in table bool used; //!< if entry has been used - NATIVE_UINT_TYPE bucketNo; //!< for testing + FwChanIdType bucketNo; //!< for testing } TlmEntry; struct TlmSet { TlmEntry* slots[TLMCHAN_NUM_TLM_HASH_SLOTS]; //!< set of hash slots in hash table TlmEntry buckets[TLMCHAN_HASH_BUCKETS]; //!< set of buckets used in hash table - NATIVE_INT_TYPE free; //!< next free bucket + FwChanIdType free; //!< next free bucket } m_tlmEntries[2]; U32 m_activeBuffer; // !< which buffer is active for storing telemetry diff --git a/Svc/TlmChan/test/ut/TlmChanTester.cpp b/Svc/TlmChan/test/ut/TlmChanTester.cpp index 44f5059f4d..87c1fcdd86 100644 --- a/Svc/TlmChan/test/ut/TlmChanTester.cpp +++ b/Svc/TlmChan/test/ut/TlmChanTester.cpp @@ -11,8 +11,8 @@ #define MAX_HISTORY_SIZE 10 #define QUEUE_DEPTH 10 -static const NATIVE_UINT_TYPE TEST_CHAN_SIZE = sizeof(FwChanIdType) + Fw::Time::SERIALIZED_SIZE + sizeof(U32); -static const NATIVE_UINT_TYPE CHANS_PER_COMBUFFER = +static const FwChanIdType TEST_CHAN_SIZE = sizeof(FwChanIdType) + Fw::Time::SERIALIZED_SIZE + sizeof(U32); +static const FwChanIdType CHANS_PER_COMBUFFER = (FW_COM_BUFFER_MAX_SIZE - sizeof(FwPacketDescriptorType)) / TEST_CHAN_SIZE; static constexpr FwSizeType INTEGER_DIVISION_ROUNDED_UP(FwSizeType a, FwSizeType b) { return ((a % b) == 0) ? (a / b) : (a / b) + 1; @@ -69,7 +69,7 @@ void TlmChanTester::runMultiChannel() { this->clearBuffs(); // send all updates - for (NATIVE_UINT_TYPE n = 0; n < FW_NUM_ARRAY_ELEMENTS(ID_0); n++) { + for (FwChanIdType n = 0; n < FW_NUM_ARRAY_ELEMENTS(ID_0); n++) { this->sendBuff(ID_0[n], n); } @@ -82,7 +82,7 @@ void TlmChanTester::runMultiChannel() { ASSERT_EQ(1, this->component.m_activeBuffer); // verify packets - for (NATIVE_UINT_TYPE n = 0; n < FW_NUM_ARRAY_ELEMENTS(ID_0); n++) { + for (FwChanIdType n = 0; n < FW_NUM_ARRAY_ELEMENTS(ID_0); n++) { // printf("#: %d\n",n); this->checkBuff(n, FW_NUM_ARRAY_ELEMENTS(ID_0), ID_0[n], n); } @@ -96,7 +96,7 @@ void TlmChanTester::runMultiChannel() { this->clearBuffs(); // send all updates - for (NATIVE_UINT_TYPE n = 0; n < FW_NUM_ARRAY_ELEMENTS(ID_1); n++) { + for (FwChanIdType n = 0; n < FW_NUM_ARRAY_ELEMENTS(ID_1); n++) { this->sendBuff(ID_1[n], n); } @@ -109,7 +109,7 @@ void TlmChanTester::runMultiChannel() { ASSERT_EQ(0, this->component.m_activeBuffer); // verify packets - for (NATIVE_UINT_TYPE n = 0; n < FW_NUM_ARRAY_ELEMENTS(ID_1); n++) { + for (FwChanIdType n = 0; n < FW_NUM_ARRAY_ELEMENTS(ID_1); n++) { // printf("#: %d\n",n); this->checkBuff(n, FW_NUM_ARRAY_ELEMENTS(ID_1), ID_1[n], n); } @@ -163,7 +163,7 @@ bool TlmChanTester::doRun(bool check) { return this->m_bufferRecv; } -void TlmChanTester::checkBuff(NATIVE_UINT_TYPE chanNum, NATIVE_UINT_TYPE totalChan, FwChanIdType id, U32 val) { +void TlmChanTester::checkBuff(FwChanIdType chanNum, FwChanIdType totalChan, FwChanIdType id, U32 val) { Fw::Time timeTag; // deserialize packet Fw::SerializeStatus stat; @@ -175,10 +175,10 @@ void TlmChanTester::checkBuff(NATIVE_UINT_TYPE chanNum, NATIVE_UINT_TYPE totalCh tlc004 = true; } - NATIVE_UINT_TYPE currentChan = 0; + FwChanIdType currentChan = 0; // Search for channel ID - for (NATIVE_UINT_TYPE packet = 0; packet < this->m_numBuffs; packet++) { + for (FwChanIdType packet = 0; packet < this->m_numBuffs; packet++) { // Look at packet descriptor for current packet this->m_rcvdBuffer[packet].resetDeser(); // first piece should be tlm packet descriptor @@ -187,7 +187,7 @@ void TlmChanTester::checkBuff(NATIVE_UINT_TYPE chanNum, NATIVE_UINT_TYPE totalCh ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat); ASSERT_EQ(desc, static_cast(Fw::ComPacket::FW_PACKET_TELEM)); - for (NATIVE_UINT_TYPE chan = 0; chan < CHANS_PER_COMBUFFER; chan++) { + for (FwChanIdType chan = 0; chan < CHANS_PER_COMBUFFER; chan++) { // decode channel ID FwEventIdType sentId; stat = this->m_rcvdBuffer[packet].deserialize(sentId); @@ -258,7 +258,7 @@ void TlmChanTester::sendBuff(FwChanIdType id, U32 val) { void TlmChanTester::clearBuffs() { this->m_numBuffs = 0; - for (NATIVE_INT_TYPE n = 0; n < TLMCHAN_HASH_BUCKETS; n++) { + for (FwChanIdType n = 0; n < TLMCHAN_HASH_BUCKETS; n++) { this->m_rcvdBuffer[n].resetSer(); } } @@ -275,11 +275,11 @@ void TlmChanTester::dumpTlmEntry(TlmChan::TlmEntry* entry) { void TlmChanTester::dumpHash() { // printf("**Buffer 0\n"); - for (NATIVE_INT_TYPE slot = 0; slot < TLMCHAN_NUM_TLM_HASH_SLOTS; slot++) { + for (FwChanIdType slot = 0; slot < TLMCHAN_NUM_TLM_HASH_SLOTS; slot++) { printf("Slot: %d\n", slot); if (this->component.m_tlmEntries[0].slots[slot]) { TlmChan::TlmEntry* entry = component.m_tlmEntries[0].slots[slot]; - for (NATIVE_INT_TYPE bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { + for (FwChanIdType bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { dumpTlmEntry(entry); if (entry->next == nullptr) { break; @@ -292,16 +292,16 @@ void TlmChanTester::dumpHash() { } } printf("\n"); - // for (NATIVE_INT_TYPE bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { + // for (FwChanIdType bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { // printf("Bucket: %d ",bucket); // dumpTlmEntry(&m_impl.m_tlmEntries[0].buckets[bucket]); // } // printf("**Buffer 1\n"); - // for (NATIVE_INT_TYPE slot = 0; slot < TLMCHAN_NUM_TLM_HASH_SLOTS; slot++) { + // for (FwChanIdType slot = 0; slot < TLMCHAN_NUM_TLM_HASH_SLOTS; slot++) { // printf("Slot: %d\n",slot); // if (m_impl.m_tlmEntries[1].slots[slot]) { // TlmChanImpl::TlmEntry* entry = m_impl.m_tlmEntries[1].slots[slot]; - // for (NATIVE_INT_TYPE bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { + // for (FwChanIdType bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { // dumpTlmEntry(entry); // if (entry->next == 0) { // break; @@ -314,7 +314,7 @@ void TlmChanTester::dumpHash() { // } // } // printf("\n"); - // for (NATIVE_INT_TYPE bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { + // for (FwChanIdType bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) { // printf("Bucket: %d\n",bucket); // dumpTlmEntry(&m_impl.m_tlmEntries[1].buckets[bucket]); // } diff --git a/Svc/TlmChan/test/ut/TlmChanTester.hpp b/Svc/TlmChan/test/ut/TlmChanTester.hpp index 1fc79a5456..b0dc4c88e7 100644 --- a/Svc/TlmChan/test/ut/TlmChanTester.hpp +++ b/Svc/TlmChan/test/ut/TlmChanTester.hpp @@ -68,7 +68,7 @@ class TlmChanTester : public TlmChanGTestBase { void sendBuff(FwChanIdType id, U32 val); bool doRun(bool check); - void checkBuff(NATIVE_UINT_TYPE chanNum, NATIVE_UINT_TYPE totalChan, FwChanIdType id, U32 val); + void checkBuff(FwChanIdType chanNum, FwChanIdType totalChan, FwChanIdType id, U32 val); void clearBuffs(); @@ -85,7 +85,7 @@ class TlmChanTester : public TlmChanGTestBase { //! TlmChan component; // Keep a history - NATIVE_UINT_TYPE m_numBuffs; + FwChanIdType m_numBuffs; Fw::ComBuffer m_rcvdBuffer[TLMCHAN_HASH_BUCKETS]; bool m_bufferRecv; }; From febf47e52cbb94f472fb1bb46527964b142f7e1e Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 18:11:21 -0700 Subject: [PATCH 13/34] NATIVE_ types from BufferRepeater --- Svc/BufferRepeater/test/ut/BufferRepeaterTester.cpp | 6 +++--- Svc/BufferRepeater/test/ut/BufferRepeaterTester.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Svc/BufferRepeater/test/ut/BufferRepeaterTester.cpp b/Svc/BufferRepeater/test/ut/BufferRepeaterTester.cpp index 7c0a6e2879..460de2107d 100644 --- a/Svc/BufferRepeater/test/ut/BufferRepeaterTester.cpp +++ b/Svc/BufferRepeater/test/ut/BufferRepeaterTester.cpp @@ -44,8 +44,8 @@ void BufferRepeaterTester ::testRepeater() { ASSERT_EVENTS_AllocationSoftFailure_SIZE(0); ASSERT_from_portOut_SIZE(this->component.getNum_portOut_OutputPorts()); ASSERT_EQ(fromPortHistory_portOut->size(), this->m_port_index_history.size()); - for (NATIVE_INT_TYPE i = 0; i < this->component.getNum_portOut_OutputPorts(); i++) { - NATIVE_INT_TYPE port_index = this->m_port_index_history.at(i); + for (FwIndexType i = 0; i < this->component.getNum_portOut_OutputPorts(); i++) { + FwIndexType port_index = this->m_port_index_history.at(i); ASSERT_EQ(i, port_index); Fw::Buffer buffer_under_test = this->fromPortHistory_portOut->at(i).fwBuffer; ASSERT_EQ(buffer_under_test.getSize(), m_initial_buffer.getSize()); @@ -153,7 +153,7 @@ void BufferRepeaterTester ::connectPorts() { this->component.set_deallocate_OutputPort(0, this->get_from_deallocate(0)); // portOut - for (NATIVE_INT_TYPE i = 0; i < this->component.getNum_portOut_OutputPorts(); ++i) { + for (FwIndexType i = 0; i < this->component.getNum_portOut_OutputPorts(); ++i) { this->component.set_portOut_OutputPort(i, this->get_from_portOut(i)); } } diff --git a/Svc/BufferRepeater/test/ut/BufferRepeaterTester.hpp b/Svc/BufferRepeater/test/ut/BufferRepeaterTester.hpp index efb8a4a67f..07e452c96e 100644 --- a/Svc/BufferRepeater/test/ut/BufferRepeaterTester.hpp +++ b/Svc/BufferRepeater/test/ut/BufferRepeaterTester.hpp @@ -86,7 +86,7 @@ class BufferRepeaterTester : public BufferRepeaterGTestBase { //! The component under test //! BufferRepeater component; - History m_port_index_history; + History m_port_index_history; Fw::Buffer m_initial_buffer; bool m_failure; }; From f5f3743d3bb09aac13bcb79a69e5cd969d0d93cc Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 18:25:46 -0700 Subject: [PATCH 14/34] NATIVE_ types from Active/Passive Rate Group --- Svc/ActiveRateGroup/ActiveRateGroup.cpp | 6 ++-- Svc/ActiveRateGroup/ActiveRateGroup.hpp | 8 +++--- .../test/ut/ActiveRateGroupImplTester.cpp | 28 +++++++++---------- .../test/ut/ActiveRateGroupImplTester.hpp | 8 +++--- .../test/ut/ActiveRateGroupTester.cpp | 14 +++++----- Svc/PassiveRateGroup/PassiveRateGroup.cpp | 6 ++-- Svc/PassiveRateGroup/PassiveRateGroup.hpp | 4 +-- .../test/ut/PassiveRateGroupImplTester.cpp | 12 ++++---- .../test/ut/PassiveRateGroupImplTester.hpp | 6 ++-- .../test/ut/PassiveRateGroupTester.cpp | 6 ++-- .../test/ut/PassiveRateGroupTester.hpp | 6 ++-- 11 files changed, 52 insertions(+), 52 deletions(-) diff --git a/Svc/ActiveRateGroup/ActiveRateGroup.cpp b/Svc/ActiveRateGroup/ActiveRateGroup.cpp index 43b06b6e43..e82f8a52dd 100644 --- a/Svc/ActiveRateGroup/ActiveRateGroup.cpp +++ b/Svc/ActiveRateGroup/ActiveRateGroup.cpp @@ -30,7 +30,7 @@ namespace Svc { m_cycleSlips(0) { } - void ActiveRateGroup::configure( NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts) { + void ActiveRateGroup::configure(U32 contexts[], FwIndexType numContexts) { FW_ASSERT(contexts); FW_ASSERT(numContexts == this->getNum_RateGroupMemberOut_OutputPorts(),numContexts,this->getNum_RateGroupMemberOut_OutputPorts()); FW_ASSERT(FW_NUM_ARRAY_ELEMENTS(this->m_contexts) == this->getNum_RateGroupMemberOut_OutputPorts(), @@ -39,7 +39,7 @@ namespace Svc { this->m_numContexts = numContexts; // copy context values - for (NATIVE_INT_TYPE entry = 0; entry < this->m_numContexts; entry++) { + for (FwIndexType entry = 0; entry < this->m_numContexts; entry++) { this->m_contexts[entry] = contexts[entry]; } } @@ -62,7 +62,7 @@ namespace Svc { this->m_cycleStarted = false; // invoke any members of the rate group - for (NATIVE_INT_TYPE port = 0; port < this->m_numContexts; port++) { + for (FwIndexType port = 0; port < this->m_numContexts; port++) { if (this->isConnected_RateGroupMemberOut_OutputPort(port)) { this->RateGroupMemberOut_out(port, static_cast(this->m_contexts[port])); } diff --git a/Svc/ActiveRateGroup/ActiveRateGroup.hpp b/Svc/ActiveRateGroup/ActiveRateGroup.hpp index f4fa549427..a0716faea9 100644 --- a/Svc/ActiveRateGroup/ActiveRateGroup.hpp +++ b/Svc/ActiveRateGroup/ActiveRateGroup.hpp @@ -50,7 +50,7 @@ namespace Svc { //! output port number. //! \param numContexts The number of elements in the context array. - void configure(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts); + void configure(U32 contexts[], FwIndexType numContexts); //! \brief ActiveRateGroup destructor //! @@ -101,9 +101,9 @@ namespace Svc { U32 m_cycles; //!< cycles executed U32 m_maxTime; //!< maximum execution time in microseconds volatile bool m_cycleStarted; //!< indicate that cycle has started. Used to detect overruns. - NATIVE_INT_TYPE m_contexts[CONNECTION_COUNT_MAX]; //!< Must match number of output ports - NATIVE_INT_TYPE m_numContexts; //!< Number of contexts passed in by user - NATIVE_INT_TYPE m_overrunThrottle; //!< throttle value for overrun events + U32 m_contexts[CONNECTION_COUNT_MAX]; //!< Must match number of output ports + FwIndexType m_numContexts; //!< Number of contexts passed in by user + FwIndexType m_overrunThrottle; //!< throttle value for overrun events U32 m_cycleSlips; //!< tracks number of cycle slips }; diff --git a/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.cpp b/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.cpp index b399898958..f0ae7dc52a 100644 --- a/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.cpp +++ b/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.cpp @@ -38,7 +38,7 @@ namespace Svc { } void ActiveRateGroupImplTester::from_RateGroupMemberOut_handler(FwIndexType portNum, U32 context) { - ASSERT_TRUE(portNum < static_cast(FW_NUM_ARRAY_ELEMENTS(m_impl.m_RateGroupMemberOut_OutputPort))); + ASSERT_TRUE(portNum < static_cast(FW_NUM_ARRAY_ELEMENTS(m_impl.m_RateGroupMemberOut_OutputPort))); this->m_callLog[portNum].portCalled = true; this->m_callLog[portNum].contextVal = context; this->m_callLog[portNum].order = this->m_callOrder++; @@ -60,7 +60,7 @@ namespace Svc { this->pushFromPortEntry_PingOut(key); } - void ActiveRateGroupImplTester::runNominal(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts, NATIVE_INT_TYPE instance) { + void ActiveRateGroupImplTester::runNominal(U32 contexts[], FwIndexType numContexts, FwEnumStoreType instance) { TEST_CASE(101.1.1,"Run nominal rate group execution"); @@ -91,8 +91,8 @@ namespace Svc { ASSERT_FALSE(this->m_impl.m_cycleStarted); // check calls REQUIREMENT("ARG-002"); - for (NATIVE_UINT_TYPE portNum = 0; portNum < - static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_RateGroupMemberOut_OutputPort)); portNum++) { + for (FwIndexType portNum = 0; portNum < + static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_RateGroupMemberOut_OutputPort)); portNum++) { ASSERT_TRUE(this->m_callLog[portNum].portCalled); ASSERT_EQ(this->m_callLog[portNum].contextVal,contexts[portNum]); ASSERT_EQ(this->m_callLog[portNum].order,portNum); @@ -109,7 +109,7 @@ namespace Svc { } - void ActiveRateGroupImplTester::runCycleOverrun(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts, NATIVE_INT_TYPE instance) { + void ActiveRateGroupImplTester::runCycleOverrun(U32 contexts[], FwIndexType numContexts, FwEnumStoreType instance) { TEST_CASE(101.2.1,"Run cycle slip scenario"); // call the preamble @@ -122,7 +122,7 @@ namespace Svc { Os::RawTime zero_time; // run some more cycles to verify that event is sent and telemetry is updated - for (NATIVE_INT_TYPE cycle = 0; cycle < ACTIVE_RATE_GROUP_OVERRUN_THROTTLE; cycle++) { + for (FwIndexType cycle = 0; cycle < ACTIVE_RATE_GROUP_OVERRUN_THROTTLE; cycle++) { // clear events this->clearEvents(); // clear port call log @@ -149,8 +149,8 @@ namespace Svc { ASSERT_EQ(this->m_impl.m_cycles,static_cast(cycle)+1); // check calls - for (NATIVE_UINT_TYPE portNum = 0; portNum < - static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_RateGroupMemberOut_OutputPort)); portNum++) { + for (FwIndexType portNum = 0; portNum < + static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_RateGroupMemberOut_OutputPort)); portNum++) { ASSERT_TRUE(this->m_callLog[portNum].portCalled == true); } REQUIREMENT("ARG-004"); @@ -195,8 +195,8 @@ namespace Svc { // verify cycle count ASSERT_EQ(this->m_impl.m_cycles, static_cast(ACTIVE_RATE_GROUP_OVERRUN_THROTTLE)+1); // check calls - for (NATIVE_UINT_TYPE portNum = 0; portNum < - static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_RateGroupMemberOut_OutputPort)); portNum++) { + for (FwIndexType portNum = 0; portNum < + static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_RateGroupMemberOut_OutputPort)); portNum++) { ASSERT_TRUE(this->m_callLog[portNum].portCalled == true); } // verify overrun event is NOT sent since throttled @@ -239,8 +239,8 @@ namespace Svc { // verify cycle count ASSERT_EQ(this->m_impl.m_cycles,static_cast(ACTIVE_RATE_GROUP_OVERRUN_THROTTLE)+2); // check calls - for (NATIVE_UINT_TYPE portNum = 0; portNum < - static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_RateGroupMemberOut_OutputPort)); portNum++) { + for (FwIndexType portNum = 0; portNum < + static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_RateGroupMemberOut_OutputPort)); portNum++) { ASSERT_TRUE(this->m_callLog[portNum].portCalled == true); } @@ -277,8 +277,8 @@ namespace Svc { // verify cycle count ASSERT_EQ(this->m_impl.m_cycles,static_cast(ACTIVE_RATE_GROUP_OVERRUN_THROTTLE)+3); // check calls - for (NATIVE_UINT_TYPE portNum = 0; portNum < - static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_RateGroupMemberOut_OutputPort)); portNum++) { + for (FwIndexType portNum = 0; portNum < + static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_RateGroupMemberOut_OutputPort)); portNum++) { ASSERT_TRUE(this->m_callLog[portNum].portCalled == true); } // verify overrun event is sent diff --git a/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.hpp b/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.hpp index a62e86902a..bea2fdbef4 100644 --- a/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.hpp +++ b/Svc/ActiveRateGroup/test/ut/ActiveRateGroupImplTester.hpp @@ -26,8 +26,8 @@ namespace Svc { ActiveRateGroupImplTester(Svc::ActiveRateGroup& inst); virtual ~ActiveRateGroupImplTester(); - void runNominal(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts, NATIVE_INT_TYPE instance); - void runCycleOverrun(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts, NATIVE_INT_TYPE instance); + void runNominal(U32 contexts[], FwIndexType numContexts, FwEnumStoreType instance); + void runCycleOverrun(U32 contexts[], FwIndexType numContexts, FwEnumStoreType instance); void runPingTest(); private: @@ -48,11 +48,11 @@ namespace Svc { struct { bool portCalled; U32 contextVal; - NATIVE_UINT_TYPE order; + FwIndexType order; } m_callLog[Svc::ActiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS]; bool m_causeOverrun; //!< flag to cause an overrun during a rate group member port call - NATIVE_UINT_TYPE m_callOrder; //!< tracks order of port call. + FwIndexType m_callOrder; //!< tracks order of port call. }; diff --git a/Svc/ActiveRateGroup/test/ut/ActiveRateGroupTester.cpp b/Svc/ActiveRateGroup/test/ut/ActiveRateGroupTester.cpp index 4737865b21..672aa446a5 100644 --- a/Svc/ActiveRateGroup/test/ut/ActiveRateGroupTester.cpp +++ b/Svc/ActiveRateGroup/test/ut/ActiveRateGroupTester.cpp @@ -27,7 +27,7 @@ void connectPorts(Svc::ActiveRateGroup& impl, Svc::ActiveRateGroupImplTester& te tester.connect_to_CycleIn(0,impl.get_CycleIn_InputPort(0)); - for (NATIVE_UINT_TYPE portNum = 0; portNum < static_cast(FW_NUM_ARRAY_ELEMENTS(impl.m_RateGroupMemberOut_OutputPort)); portNum++) { + for (FwIndexType portNum = 0; portNum < static_cast(FW_NUM_ARRAY_ELEMENTS(impl.m_RateGroupMemberOut_OutputPort)); portNum++) { impl.set_RateGroupMemberOut_OutputPort(portNum,tester.get_from_RateGroupMemberOut(portNum)); } @@ -49,9 +49,9 @@ void connectPorts(Svc::ActiveRateGroup& impl, Svc::ActiveRateGroupImplTester& te TEST(ActiveRateGroupTest,NominalSchedule) { - for (NATIVE_INT_TYPE inst = 0; inst < 3; inst++) { + for (FwEnumStoreType inst = 0; inst < 3; inst++) { - NATIVE_INT_TYPE contexts[Svc::ActiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS]; + U32 contexts[Svc::ActiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS]; for (U32 i = 0; i < Svc::ActiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS; i++) { contexts[i] = i + 1; } @@ -75,9 +75,9 @@ TEST(ActiveRateGroupTest,NominalSchedule) { TEST(ActiveRateGroupTest,CycleOverrun) { - for (NATIVE_INT_TYPE inst = 0; inst < 3; inst++) { + for (FwEnumStoreType inst = 0; inst < 3; inst++) { - NATIVE_INT_TYPE contexts[Svc::ActiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS]; + U32 contexts[Svc::ActiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS]; for (U32 i = 0; i < Svc::ActiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS; i++) { contexts[i] = i + 1; } @@ -100,8 +100,8 @@ TEST(ActiveRateGroupTest,CycleOverrun) { TEST(ActiveRateGroupTest,PingPort) { - NATIVE_INT_TYPE contexts[Svc::ActiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS]; - for (U32 i = 0; i < Svc::ActiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS; i++) { + U32 contexts[Svc::ActiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS]; + for (FwIndexType i = 0; i < Svc::ActiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS; i++) { contexts[i] = i + 1; } diff --git a/Svc/PassiveRateGroup/PassiveRateGroup.cpp b/Svc/PassiveRateGroup/PassiveRateGroup.cpp index 19b086b683..04bd27aa16 100644 --- a/Svc/PassiveRateGroup/PassiveRateGroup.cpp +++ b/Svc/PassiveRateGroup/PassiveRateGroup.cpp @@ -23,7 +23,7 @@ PassiveRateGroup::PassiveRateGroup(const char* compName) PassiveRateGroup::~PassiveRateGroup() {} -void PassiveRateGroup::configure(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts) { +void PassiveRateGroup::configure(U32 contexts[], FwIndexType numContexts) { FW_ASSERT(contexts); FW_ASSERT(numContexts == this->getNum_RateGroupMemberOut_OutputPorts(),numContexts,this->getNum_RateGroupMemberOut_OutputPorts()); FW_ASSERT(FW_NUM_ARRAY_ELEMENTS(this->m_contexts) == this->getNum_RateGroupMemberOut_OutputPorts(), @@ -32,7 +32,7 @@ void PassiveRateGroup::configure(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE num this->m_numContexts = numContexts; // copy context values - for (NATIVE_INT_TYPE entry = 0; entry < this->m_numContexts; entry++) { + for (FwIndexType entry = 0; entry < this->m_numContexts; entry++) { this->m_contexts[entry] = static_cast(contexts[entry]); } } @@ -43,7 +43,7 @@ void PassiveRateGroup::CycleIn_handler(FwIndexType portNum, Os::RawTime& cycleSt FW_ASSERT(this->m_numContexts); // invoke any members of the rate group - for (NATIVE_INT_TYPE port = 0; port < this->getNum_RateGroupMemberOut_OutputPorts(); port++) { + for (FwIndexType port = 0; port < this->getNum_RateGroupMemberOut_OutputPorts(); port++) { if (this->isConnected_RateGroupMemberOut_OutputPort(port)) { this->RateGroupMemberOut_out(port, this->m_contexts[port]); } diff --git a/Svc/PassiveRateGroup/PassiveRateGroup.hpp b/Svc/PassiveRateGroup/PassiveRateGroup.hpp index 0776365e73..1496ceeb3c 100644 --- a/Svc/PassiveRateGroup/PassiveRateGroup.hpp +++ b/Svc/PassiveRateGroup/PassiveRateGroup.hpp @@ -46,7 +46,7 @@ class PassiveRateGroup final : public PassiveRateGroupComponentBase { //! to each member component. The index of the array corresponds to the //! output port number. //! \param numContexts The number of elements in the context array. - void configure(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts); + void configure(U32 contexts[], FwIndexType numContexts); //! \brief PassiveRateGroupImpl destructor //! @@ -66,7 +66,7 @@ class PassiveRateGroup final : public PassiveRateGroupComponentBase { U32 m_cycles; //!< cycles executed U32 m_maxTime; //!< maximum execution time in microseconds - NATIVE_INT_TYPE m_numContexts; //!< number of contexts + FwIndexType m_numContexts; //!< number of contexts U32 m_contexts[NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS]; //!< Must match number of output ports }; diff --git a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.cpp b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.cpp index 58c8006c89..b68cd8b567 100644 --- a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.cpp +++ b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.cpp @@ -35,7 +35,7 @@ void PassiveRateGroupTester::clearPortCalls() { PassiveRateGroupTester::~PassiveRateGroupTester() {} void PassiveRateGroupTester::from_RateGroupMemberOut_handler(FwIndexType portNum, U32 context) { - ASSERT_TRUE(portNum < static_cast(FW_NUM_ARRAY_ELEMENTS(m_impl.m_RateGroupMemberOut_OutputPort))); + ASSERT_TRUE(portNum < static_cast(FW_NUM_ARRAY_ELEMENTS(m_impl.m_RateGroupMemberOut_OutputPort))); this->m_callLog[portNum].portCalled = true; this->m_callLog[portNum].contextVal = context; this->m_callLog[portNum].order = this->m_callOrder++; @@ -43,9 +43,9 @@ void PassiveRateGroupTester::from_RateGroupMemberOut_handler(FwIndexType portNum usleep(1); } -void PassiveRateGroupTester::runNominal(NATIVE_INT_TYPE contexts[], - NATIVE_UINT_TYPE numContexts, - NATIVE_INT_TYPE instance) { +void PassiveRateGroupTester::runNominal(U32 contexts[], + FwIndexType numContexts, + FwEnumStoreType instance) { TEST_CASE(101.1.1, "Run nominal rate group execution"); // clear events @@ -64,8 +64,8 @@ void PassiveRateGroupTester::runNominal(NATIVE_INT_TYPE contexts[], // check calls REQUIREMENT("FPRIME-PRG-002"); - for (NATIVE_UINT_TYPE portNum = 0; - portNum < static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_RateGroupMemberOut_OutputPort)); portNum++) { + for (FwIndexType portNum = 0; + portNum < static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_impl.m_RateGroupMemberOut_OutputPort)); portNum++) { ASSERT_TRUE(this->m_callLog[portNum].portCalled); ASSERT_EQ(this->m_callLog[portNum].contextVal, contexts[portNum]); ASSERT_EQ(this->m_callLog[portNum].order, portNum); diff --git a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.hpp b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.hpp index 3261f22961..04aaeb6c0c 100644 --- a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.hpp +++ b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupImplTester.hpp @@ -25,7 +25,7 @@ namespace Svc { PassiveRateGroupTester(Svc::PassiveRateGroup& inst); virtual ~PassiveRateGroupTester(); - void runNominal(U32 contexts[], U32 numContexts, NATIVE_INT_TYPE instance); + void runNominal(U32 contexts[], U32 numContexts, FwEnumStoreType instance); private: @@ -38,11 +38,11 @@ namespace Svc { struct { bool portCalled; U32 contextVal; - NATIVE_UINT_TYPE order; + FwIndexType order; } m_callLog[Svc::PassiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS]; bool m_causeOverrun; //!< flag to cause an overrun during a rate group member port call - NATIVE_UINT_TYPE m_callOrder; //!< tracks order of port call. + FwIndexType m_callOrder; //!< tracks order of port call. }; diff --git a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.cpp b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.cpp index cde465fdba..914f899fe7 100644 --- a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.cpp +++ b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.cpp @@ -23,7 +23,7 @@ void connectPorts(Svc::PassiveRateGroup& impl, Svc::PassiveRateGroupTester& test tester.connect_to_CycleIn(0, impl.get_CycleIn_InputPort(0)); for (FwIndexType portNum = 0; - portNum < static_cast(FW_NUM_ARRAY_ELEMENTS(impl.m_RateGroupMemberOut_OutputPort)); portNum++) { + portNum < static_cast(FW_NUM_ARRAY_ELEMENTS(impl.m_RateGroupMemberOut_OutputPort)); portNum++) { impl.set_RateGroupMemberOut_OutputPort(portNum, tester.get_from_RateGroupMemberOut(portNum)); } @@ -32,8 +32,8 @@ void connectPorts(Svc::PassiveRateGroup& impl, Svc::PassiveRateGroupTester& test } TEST(PassiveRateGroupTest, NominalSchedule) { - for (NATIVE_INT_TYPE inst = 0; inst < 3; inst++) { - NATIVE_INT_TYPE contexts[FppConstant_PassiveRateGroupOutputPorts::PassiveRateGroupOutputPorts] = {1, 2, 3, 4, 5}; + for (FwEnumStoreType inst = 0; inst < 3; inst++) { + U32 contexts[FppConstant_PassiveRateGroupOutputPorts::PassiveRateGroupOutputPorts] = {1, 2, 3, 4, 5}; Svc::PassiveRateGroup impl("PassiveRateGroup"); impl.configure(contexts, FW_NUM_ARRAY_ELEMENTS(contexts)); diff --git a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.hpp b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.hpp index 9c69cf2852..ef63812f17 100644 --- a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.hpp +++ b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTester.hpp @@ -25,7 +25,7 @@ namespace Svc { PassiveRateGroupTester(Svc::PassiveRateGroup& inst); virtual ~PassiveRateGroupTester(); - void runNominal(NATIVE_INT_TYPE contexts[], U32 numContexts, NATIVE_INT_TYPE instance); + void runNominal(U32 contexts[], FwIndexType numContexts, FwEnumStoreType instance); private: @@ -38,10 +38,10 @@ namespace Svc { struct { bool portCalled; U32 contextVal; - NATIVE_UINT_TYPE order; + FwIndexType order; } m_callLog[Svc::PassiveRateGroupComponentBase::NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS]; - U32 m_callOrder; //!< tracks order of port call. + FwIndexType m_callOrder; //!< tracks order of port call. }; From 4c0576c4b36410177f73717eedcfef8cd80cee0c Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 18:29:21 -0700 Subject: [PATCH 15/34] NATIVE_ types from ComSplitter and ComStub --- Svc/ComSplitter/ComSplitter.cpp | 4 ++-- Svc/ComSplitter/test/ut/ComSplitterTester.cpp | 2 +- Svc/ComStub/ComStub.cpp | 2 +- Svc/ComStub/ComStub.hpp | 2 +- Svc/PrmDb/PrmDbImpl.cpp | 14 ++++++++------ 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Svc/ComSplitter/ComSplitter.cpp b/Svc/ComSplitter/ComSplitter.cpp index 6fe5169854..abefff0aad 100644 --- a/Svc/ComSplitter/ComSplitter.cpp +++ b/Svc/ComSplitter/ComSplitter.cpp @@ -39,10 +39,10 @@ namespace Svc { { FW_ASSERT(portNum == 0); - NATIVE_INT_TYPE numPorts = getNum_comOut_OutputPorts(); + FwIndexType numPorts = getNum_comOut_OutputPorts(); FW_ASSERT(numPorts > 0); - for(NATIVE_INT_TYPE i = 0; i < numPorts; i++) { + for(FwIndexType i = 0; i < numPorts; i++) { if( isConnected_comOut_OutputPort(i) ) { // Need to make a copy because we are passing by reference!: Fw::ComBuffer dataToSend = data; diff --git a/Svc/ComSplitter/test/ut/ComSplitterTester.cpp b/Svc/ComSplitter/test/ut/ComSplitterTester.cpp index 4f7118324f..372f3536bf 100644 --- a/Svc/ComSplitter/test/ut/ComSplitterTester.cpp +++ b/Svc/ComSplitter/test/ut/ComSplitterTester.cpp @@ -106,7 +106,7 @@ namespace Svc { // Just connect 3 of 5: // comOut - for (NATIVE_INT_TYPE i = 0; i < 3; ++i) { + for (FwIndexType i = 0; i < 3; ++i) { this->component.set_comOut_OutputPort( i, this->get_from_comOut(i) diff --git a/Svc/ComStub/ComStub.cpp b/Svc/ComStub/ComStub.cpp index 8f8a3f5a88..eb9713439b 100644 --- a/Svc/ComStub/ComStub.cpp +++ b/Svc/ComStub/ComStub.cpp @@ -25,7 +25,7 @@ ComStub::~ComStub() {} Drv::SendStatus ComStub::comDataIn_handler(const FwIndexType portNum, Fw::Buffer& sendBuffer) { FW_ASSERT(!this->m_reinitialize || !this->isConnected_comStatus_OutputPort(0)); // A message should never get here if we need to reinitialize is needed Drv::SendStatus driverStatus = Drv::SendStatus::SEND_RETRY; - for (NATIVE_UINT_TYPE i = 0; driverStatus == Drv::SendStatus::SEND_RETRY && i < RETRY_LIMIT; i++) { + for (FwIndexType i = 0; driverStatus == Drv::SendStatus::SEND_RETRY && i < RETRY_LIMIT; i++) { driverStatus = this->drvDataOut_out(0, sendBuffer); } FW_ASSERT(driverStatus != Drv::SendStatus::SEND_RETRY); // If it is still in retry state, there is no good answer diff --git a/Svc/ComStub/ComStub.hpp b/Svc/ComStub/ComStub.hpp index 41dd9b2288..95d672881c 100644 --- a/Svc/ComStub/ComStub.hpp +++ b/Svc/ComStub/ComStub.hpp @@ -13,7 +13,7 @@ namespace Svc { class ComStub final : public ComStubComponentBase { public: - const NATIVE_UINT_TYPE RETRY_LIMIT = 10; + const FwIndexType RETRY_LIMIT = 10; // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- diff --git a/Svc/PrmDb/PrmDbImpl.cpp b/Svc/PrmDb/PrmDbImpl.cpp index 01041451c8..cb900a7855 100644 --- a/Svc/PrmDb/PrmDbImpl.cpp +++ b/Svc/PrmDb/PrmDbImpl.cpp @@ -13,6 +13,8 @@ #include #include +static_assert(std::numeric_limits::max() >= PRMDB_NUM_DB_ENTRIES, "PRMDB_NUM_DB_ENTRIES must fit within range of FwSizeType"); + namespace Svc { @@ -51,7 +53,7 @@ namespace Svc { } void PrmDbImpl::clearDb() { - for (I32 entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) { + for (FwSizeType entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) { this->m_db[entry].used = false; this->m_db[entry].id = 0; } @@ -64,7 +66,7 @@ namespace Svc { // search for entry Fw::ParamValid stat = Fw::ParamValid::INVALID; - for (I32 entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) { + for (FwSizeType entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) { if (this->m_db[entry].used) { if (this->m_db[entry].id == id) { val = this->m_db[entry].val; @@ -91,7 +93,7 @@ namespace Svc { bool existingEntry = false; bool noSlots = true; - for (NATIVE_INT_TYPE entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) { + for (FwSizeType entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) { if ((this->m_db[entry].used) && (id == this->m_db[entry].id)) { this->m_db[entry].val = val; existingEntry = true; @@ -101,7 +103,7 @@ namespace Svc { // if there is no existing entry, add one if (!existingEntry) { - for (I32 entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) { + for (FwSizeType entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) { if (!(this->m_db[entry].used)) { this->m_db[entry].val = val; this->m_db[entry].id = id; @@ -142,7 +144,7 @@ namespace Svc { U32 numRecords = 0; - for (NATIVE_UINT_TYPE entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_db); entry++) { + for (FwSizeType entry = 0; entry < FW_NUM_ARRAY_ELEMENTS(this->m_db); entry++) { if (this->m_db[entry].used) { // write delimiter static const U8 delim = PRMDB_ENTRY_DELIMITER; @@ -268,7 +270,7 @@ namespace Svc { this->clearDb(); - for (NATIVE_INT_TYPE entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) { + for (FwSizeType entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) { U8 delimiter; FwSignedSizeType readSize = static_cast(sizeof(delimiter)); From da4c88441085ec5dd1ff2408afab1223b7e61f62 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 18:38:54 -0700 Subject: [PATCH 16/34] NATIVE_ types from ActiveLogger and fixed ActiveRateGroup sdd --- Svc/ActiveLogger/ActiveLoggerImpl.cpp | 12 ++++++------ Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.cpp | 6 +++--- Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.hpp | 13 +------------ Svc/ActiveRateGroup/docs/sdd.md | 2 +- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/Svc/ActiveLogger/ActiveLoggerImpl.cpp b/Svc/ActiveLogger/ActiveLoggerImpl.cpp index f330a988e3..f90f011836 100644 --- a/Svc/ActiveLogger/ActiveLoggerImpl.cpp +++ b/Svc/ActiveLogger/ActiveLoggerImpl.cpp @@ -12,7 +12,7 @@ #include namespace Svc { - + static_assert(std::numeric_limits::max() >= TELEM_ID_FILTER_SIZE, "TELEM_ID_FILTER_SIZE must fit within range of FwSizeType"); typedef ActiveLogger_Enabled Enabled; typedef ActiveLogger_FilterSeverity FilterSeverity; @@ -84,7 +84,7 @@ namespace Svc { } // check ID filters - for (NATIVE_INT_TYPE entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) { + for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) { if ( (m_filteredIDs[entry] == id) && (severity != Fw::LogSeverity::FATAL) @@ -133,7 +133,7 @@ namespace Svc { if (Enabled::ENABLED == idEnabled.e) { // add ID // search list for existing entry - for (NATIVE_INT_TYPE entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) { + for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) { if (this->m_filteredIDs[entry] == ID) { this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK); this->log_ACTIVITY_HI_ID_FILTER_ENABLED(ID); @@ -141,7 +141,7 @@ namespace Svc { } } // if not already a match, search for an open slot - for (NATIVE_INT_TYPE entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) { + for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) { if (this->m_filteredIDs[entry] == 0) { this->m_filteredIDs[entry] = ID; this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK); @@ -154,7 +154,7 @@ namespace Svc { this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); } else { // remove ID // search list for existing entry - for (NATIVE_INT_TYPE entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) { + for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) { if (this->m_filteredIDs[entry] == ID) { this->m_filteredIDs[entry] = 0; // zero entry this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK); @@ -184,7 +184,7 @@ namespace Svc { } // iterate through ID filter - for (NATIVE_INT_TYPE entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) { + for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) { if (this->m_filteredIDs[entry] != 0) { this->log_ACTIVITY_HI_ID_FILTER_ENABLED(this->m_filteredIDs[entry]); } diff --git a/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.cpp b/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.cpp index 133dedc04b..5701168a50 100644 --- a/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.cpp +++ b/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.cpp @@ -225,7 +225,7 @@ namespace Svc { REQUIREMENT("AL-003"); - for (NATIVE_INT_TYPE filterID = 1; filterID <= TELEM_ID_FILTER_SIZE; filterID++) { + for (FwSizeType filterID = 1; filterID <= TELEM_ID_FILTER_SIZE; filterID++) { this->clearHistory(); this->clearEvents(); this->sendCmd_SET_ID_FILTER(0,cmdSeq,filterID,Enabled::ENABLED); @@ -261,7 +261,7 @@ namespace Svc { } // Try to send the IDs that are filtered - for (NATIVE_INT_TYPE filterID = 1; filterID <= TELEM_ID_FILTER_SIZE; filterID++) { + for (FwSizeType filterID = 1; filterID <= TELEM_ID_FILTER_SIZE; filterID++) { this->clearHistory(); this->clearEvents(); @@ -321,7 +321,7 @@ namespace Svc { // Now clear them - for (NATIVE_INT_TYPE filterID = 1; filterID <= TELEM_ID_FILTER_SIZE; filterID++) { + for (FwSizeType filterID = 1; filterID <= TELEM_ID_FILTER_SIZE; filterID++) { this->clearHistory(); this->clearEvents(); this->sendCmd_SET_ID_FILTER(0,cmdSeq,filterID,Enabled::DISABLED); diff --git a/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.hpp b/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.hpp index b06c8ecb0a..55fadd8d0e 100644 --- a/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.hpp +++ b/Svc/ActiveLogger/test/ut/ActiveLoggerImplTester.hpp @@ -53,24 +53,13 @@ namespace Svc { void writeEvent(FwEventIdType id, Fw::LogSeverity severity, U32 value); void readEvent(FwEventIdType id, Fw::LogSeverity severity, U32 value, Os::File& file); - // open call modifiers - - static bool OpenInterceptor(Os::File::Status &stat, const char* fileName, Os::File::Mode mode, void* ptr); - Os::File::Status m_testOpenStatus; - - // write call modifiers - - static bool WriteInterceptor(Os::File::Status &status, const void * buffer, NATIVE_INT_TYPE &size, bool waitForDone, void* ptr); - Os::File::Status m_testWriteStatus; - // How many read calls to let pass before modifying - NATIVE_INT_TYPE m_writesToWait; // enumeration to tell what kind of error to inject typedef enum { FILE_WRITE_WRITE_ERROR, // return a bad read status FILE_WRITE_SIZE_ERROR, // return a bad size } FileWriteTestType; FileWriteTestType m_writeTestType; - NATIVE_INT_TYPE m_writeSize; + FwSizeType m_writeSize; void textLogIn(const FwEventIdType id, //!< The event ID const Fw::Time& timeTag, //!< The time diff --git a/Svc/ActiveRateGroup/docs/sdd.md b/Svc/ActiveRateGroup/docs/sdd.md index 86b7f4ad6a..a0083f3c5e 100644 --- a/Svc/ActiveRateGroup/docs/sdd.md +++ b/Svc/ActiveRateGroup/docs/sdd.md @@ -44,7 +44,7 @@ The `Svc::ActiveRateGroup` component has one input port that is called to wake u A set of context values are passed in as an array to the configure function: ``` -void configure(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts); +void configure(U32 contexts[], FwIndexType numContexts); ``` A context value can be used by a component to discriminate between more than one call in the rate group. From 255d568b55d1ad8f7286ea4b40209bb51d85d5b8 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 18:43:42 -0700 Subject: [PATCH 17/34] NATIVE_ types from Dp* --- Svc/DpCatalog/docs/sdd.md | 2 +- Svc/DpCatalog/test/ut/DpCatalogTester.cpp | 2 +- Svc/DpCatalog/test/ut/DpCatalogTester.hpp | 2 +- Svc/DpManager/test/ut/Rules/CLEAR_EVENT_THROTTLE.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Svc/DpCatalog/docs/sdd.md b/Svc/DpCatalog/docs/sdd.md index 8fcd49dc90..4b3b9c93f0 100644 --- a/Svc/DpCatalog/docs/sdd.md +++ b/Svc/DpCatalog/docs/sdd.md @@ -92,7 +92,7 @@ During initialization, the configuration function takes a set of parameters: Fw::FileNameString directories[DP_MAX_DIRECTORIES], FwSizeType numDirs, Fw::FileNameString& stateFile, - NATIVE_UINT_TYPE memId, + FwEnumStoreType memId, Fw::MemAllocator& allocator ); ``` diff --git a/Svc/DpCatalog/test/ut/DpCatalogTester.cpp b/Svc/DpCatalog/test/ut/DpCatalogTester.cpp index e5dfcd5c63..f773837e10 100644 --- a/Svc/DpCatalog/test/ut/DpCatalogTester.cpp +++ b/Svc/DpCatalog/test/ut/DpCatalogTester.cpp @@ -54,7 +54,7 @@ namespace Svc { void DpCatalogTester::testTree( DpCatalog::DpStateEntry* input, DpCatalog::DpStateEntry* output, - NATIVE_INT_TYPE numEntries) { + FwSizeType numEntries) { ASSERT_TRUE(input != nullptr); ASSERT_TRUE(output != nullptr); ASSERT_TRUE(numEntries > 0); diff --git a/Svc/DpCatalog/test/ut/DpCatalogTester.hpp b/Svc/DpCatalog/test/ut/DpCatalogTester.hpp index 74706e94e3..164d202850 100644 --- a/Svc/DpCatalog/test/ut/DpCatalogTester.hpp +++ b/Svc/DpCatalog/test/ut/DpCatalogTester.hpp @@ -56,7 +56,7 @@ namespace Svc { void testTree( DpCatalog::DpStateEntry* list, DpCatalog::DpStateEntry* output, - NATIVE_INT_TYPE numEntries); + FwSizeType numEntries); struct DpSet { FwDpIdType id; diff --git a/Svc/DpManager/test/ut/Rules/CLEAR_EVENT_THROTTLE.cpp b/Svc/DpManager/test/ut/Rules/CLEAR_EVENT_THROTTLE.cpp index 970f101804..e1da13717a 100644 --- a/Svc/DpManager/test/ut/Rules/CLEAR_EVENT_THROTTLE.cpp +++ b/Svc/DpManager/test/ut/Rules/CLEAR_EVENT_THROTTLE.cpp @@ -27,7 +27,7 @@ void TestState::action__CLEAR_EVENT_THROTTLE__OK() { // Clear history this->clearHistory(); // Send the command - const NATIVE_INT_TYPE instance = static_cast(STest::Pick::any()); + const FwOpcodeType instance = static_cast(STest::Pick::any()); const U32 cmdSeq = STest::Pick::any(); this->sendCmd_CLEAR_EVENT_THROTTLE(instance, cmdSeq); this->component.doDispatch(); From bb7d0654ddd52329d1c0ebe4a17eac3c32469e7a Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Mar 2025 18:45:41 -0700 Subject: [PATCH 18/34] NATIVE_ types from FileManager and ActiveLogger (missed) --- Svc/ActiveLogger/ActiveLoggerImpl.cpp | 2 +- Svc/FileManager/FileManager.cpp | 4 ++-- Svc/FileManager/FileManager.hpp | 2 +- Svc/FileManager/test/ut/FileManagerTester.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Svc/ActiveLogger/ActiveLoggerImpl.cpp b/Svc/ActiveLogger/ActiveLoggerImpl.cpp index f90f011836..3be0b42bcd 100644 --- a/Svc/ActiveLogger/ActiveLoggerImpl.cpp +++ b/Svc/ActiveLogger/ActiveLoggerImpl.cpp @@ -175,7 +175,7 @@ namespace Svc { ) { // first, iterate through severity filters - for (NATIVE_UINT_TYPE filter = 0; filter < FilterSeverity::NUM_CONSTANTS; filter++) { + for (FwEnumStoreType filter = 0; filter < FilterSeverity::NUM_CONSTANTS; filter++) { FilterSeverity filterState(static_cast(filter)); this->log_ACTIVITY_LO_SEVERITY_FILTER_STATE( filterState, diff --git a/Svc/FileManager/FileManager.cpp b/Svc/FileManager/FileManager.cpp index 89be73f4df..9248653f32 100644 --- a/Svc/FileManager/FileManager.cpp +++ b/Svc/FileManager/FileManager.cpp @@ -165,7 +165,7 @@ namespace Svc { this->log_ACTIVITY_HI_ShellCommandStarted( logStringCommand ); - NATIVE_INT_TYPE status = + PlatformIntType status = this->systemCall(command, logFileName); if (status == 0) { this->log_ACTIVITY_HI_ShellCommandSucceeded( @@ -256,7 +256,7 @@ namespace Svc { // Helper methods // ---------------------------------------------------------------------- - NATIVE_INT_TYPE FileManager :: + PlatformIntType FileManager :: systemCall( const Fw::CmdStringArg& command, const Fw::CmdStringArg& logFileName diff --git a/Svc/FileManager/FileManager.hpp b/Svc/FileManager/FileManager.hpp index 1dfbed36a2..53d5f8b580 100644 --- a/Svc/FileManager/FileManager.hpp +++ b/Svc/FileManager/FileManager.hpp @@ -119,7 +119,7 @@ namespace Svc { //! A system command with no arguments //! - NATIVE_INT_TYPE systemCall( + PlatformIntType systemCall( const Fw::CmdStringArg& command, //!< The command const Fw::CmdStringArg& logFileName //!< The log file name ) const; diff --git a/Svc/FileManager/test/ut/FileManagerTester.cpp b/Svc/FileManager/test/ut/FileManagerTester.cpp index 1ea982dc21..6b8f83caf8 100644 --- a/Svc/FileManager/test/ut/FileManagerTester.cpp +++ b/Svc/FileManager/test/ut/FileManagerTester.cpp @@ -528,8 +528,8 @@ namespace Svc { void FileManagerTester :: system(const char *const cmd) { - const NATIVE_INT_TYPE status = ::system(cmd); - ASSERT_EQ(static_cast(0), status); + const PlatformIntType status = ::system(cmd); + ASSERT_EQ(static_cast(0), status); } void FileManagerTester :: From 29ddfafcdcc0c8d076140560d0159bb9bed34359 Mon Sep 17 00:00:00 2001 From: M Starch Date: Thu, 13 Mar 2025 09:57:24 -0700 Subject: [PATCH 19/34] NATIVE_ types from BufferLogger, FileDownlink, StaticMemory --- Svc/BufferLogger/BufferLogger.hpp | 2 +- Svc/BufferLogger/BufferLoggerFile.cpp | 4 ++-- Svc/FileDownlink/FileDownlink.cpp | 2 +- Svc/FileDownlink/test/ut/FileDownlinkTester.cpp | 2 +- Svc/StaticMemory/StaticMemoryComponentImpl.cpp | 12 +++++++----- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Svc/BufferLogger/BufferLogger.hpp b/Svc/BufferLogger/BufferLogger.hpp index 0519971bac..9bdb995e29 100644 --- a/Svc/BufferLogger/BufferLogger.hpp +++ b/Svc/BufferLogger/BufferLogger.hpp @@ -128,7 +128,7 @@ namespace Svc { Fw::String m_baseName; //! The counter to use for the same file name - NATIVE_UINT_TYPE m_fileCounter; + FwSizeType m_fileCounter; //! The maximum file size FwSizeType m_maxSize; diff --git a/Svc/BufferLogger/BufferLoggerFile.cpp b/Svc/BufferLogger/BufferLoggerFile.cpp index 4dbef4118e..048e6a3ad5 100644 --- a/Svc/BufferLogger/BufferLoggerFile.cpp +++ b/Svc/BufferLogger/BufferLoggerFile.cpp @@ -140,7 +140,7 @@ namespace Svc { } else { this->m_name.format( - "%s%s%d%s", + "%s%s%" PRI_FwSizeType "%s", this->m_prefix.toChar(), this->m_baseName.toChar(), this->m_fileCounter, @@ -205,7 +205,7 @@ namespace Svc { FwSignedSizeType size = static_cast(length); const Os::File::Status fileStatus = this->m_osFile.write(reinterpret_cast(data), size); bool status; - if (fileStatus == Os::File::OP_OK && size == static_cast(length)) { + if (fileStatus == Os::File::OP_OK && size == static_cast(length)) { this->m_bytesWritten += length; status = true; } diff --git a/Svc/FileDownlink/FileDownlink.cpp b/Svc/FileDownlink/FileDownlink.cpp index 7b0707729e..8d43b94b2a 100644 --- a/Svc/FileDownlink/FileDownlink.cpp +++ b/Svc/FileDownlink/FileDownlink.cpp @@ -318,7 +318,7 @@ namespace Svc { if(this->m_curEntry.source == FileDownlink::COMMAND) { this->cmdResponse_out(this->m_curEntry.opCode, this->m_curEntry.cmdSeq, statusToCmdResp(resp)); } else { - for(NATIVE_INT_TYPE i = 0; i < this->getNum_FileComplete_OutputPorts(); i++) { + for(FwIndexType i = 0; i < this->getNum_FileComplete_OutputPorts(); i++) { if(this->isConnected_FileComplete_OutputPort(i)) { this->FileComplete_out(i, Svc::SendFileResponse(resp, this->m_curEntry.context)); } diff --git a/Svc/FileDownlink/test/ut/FileDownlinkTester.cpp b/Svc/FileDownlink/test/ut/FileDownlinkTester.cpp index 86304d1390..56fc85c060 100644 --- a/Svc/FileDownlink/test/ut/FileDownlinkTester.cpp +++ b/Svc/FileDownlink/test/ut/FileDownlinkTester.cpp @@ -602,7 +602,7 @@ namespace Svc { void FileDownlinkTester :: removeFile(const char *const name) { - const NATIVE_INT_TYPE status = ::unlink(name); + const PlatformIntType status = ::unlink(name); if (status != 0) { // OK if file is not there ASSERT_EQ(ENOENT, errno); diff --git a/Svc/StaticMemory/StaticMemoryComponentImpl.cpp b/Svc/StaticMemory/StaticMemoryComponentImpl.cpp index 0d545d1a6d..3e89447f37 100644 --- a/Svc/StaticMemory/StaticMemoryComponentImpl.cpp +++ b/Svc/StaticMemory/StaticMemoryComponentImpl.cpp @@ -15,14 +15,16 @@ #include "Fw/Types/Assert.hpp" namespace Svc { - +static_assert((NUM_BUFFERALLOCATE_INPUT_PORTS >= 0) && + (NUM_BUFFERALLOCATE_INPUT_PORTS <= std::numeric_limits::max()), + "NUM_BUFFERALLOCATE_INPUT_PORTS must fit in the positive range of FwIndexType"); // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- StaticMemoryComponentImpl ::StaticMemoryComponentImpl(const char* const compName) : StaticMemoryComponentBase(compName) { - for (U32 i = 0; i < FW_NUM_ARRAY_ELEMENTS(m_allocated); i++) { + for (FwIndexType i = 0; i < FW_NUM_ARRAY_ELEMENTS(m_allocated); i++) { m_allocated[i] = false; } } @@ -34,7 +36,7 @@ StaticMemoryComponentImpl ::~StaticMemoryComponentImpl() {} // ---------------------------------------------------------------------- void StaticMemoryComponentImpl ::bufferDeallocate_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) { - FW_ASSERT(static_cast(portNum) < FW_NUM_ARRAY_ELEMENTS(m_static_memory)); + FW_ASSERT(portNum < static_cast(FW_NUM_ARRAY_ELEMENTS(m_static_memory))); FW_ASSERT(m_allocated[portNum], portNum); // It is also an error to deallocate before returning // Check the memory returned is within the region FW_ASSERT(fwBuffer.getData() >= m_static_memory[portNum]); @@ -45,8 +47,8 @@ void StaticMemoryComponentImpl ::bufferDeallocate_handler(const FwIndexType port m_allocated[portNum] = false; } -Fw::Buffer StaticMemoryComponentImpl ::bufferAllocate_handler(const FwIndexType portNum, U32 size) { - FW_ASSERT(static_cast(portNum) < FW_NUM_ARRAY_ELEMENTS(m_static_memory)); +Fw::Buffer StaticMemoryComponentImpl ::bufferAllocate_handler(const FwIndexType portNum, Fw::Buffer::SizeType size) { + FW_ASSERT(portNum < static_cast(FW_NUM_ARRAY_ELEMENTS(m_static_memory))); FW_ASSERT(size <= sizeof(m_static_memory[portNum])); // It is a topology error to ask for too much from this component FW_ASSERT(not m_allocated[portNum], portNum); // It is also an error to allocate again before returning m_allocated[portNum] = true; From b7f97868c95c828018dad2e0f97f7affba97d121 Mon Sep 17 00:00:00 2001 From: M Starch Date: Thu, 13 Mar 2025 09:58:05 -0700 Subject: [PATCH 20/34] Deleting UdpSender/UdpReceiver that lack models and build config --- Svc/UdpReceiver/UdpReceiverComponentImpl.cpp | 239 ------------------- Svc/UdpReceiver/UdpReceiverComponentImpl.hpp | 133 ----------- Svc/UdpReceiver/test/ut/Tester.cpp | 207 ---------------- Svc/UdpReceiver/test/ut/Tester.hpp | 108 --------- Svc/UdpReceiver/test/ut/main.cpp | 25 -- Svc/UdpSender/UdpSenderComponentImpl.cpp | 162 ------------- Svc/UdpSender/UdpSenderComponentImpl.hpp | 133 ----------- Svc/UdpSender/test/ut/Tester.cpp | 206 ---------------- Svc/UdpSender/test/ut/Tester.hpp | 92 ------- Svc/UdpSender/test/ut/main.cpp | 25 -- 10 files changed, 1330 deletions(-) delete mode 100644 Svc/UdpReceiver/UdpReceiverComponentImpl.cpp delete mode 100644 Svc/UdpReceiver/UdpReceiverComponentImpl.hpp delete mode 100644 Svc/UdpReceiver/test/ut/Tester.cpp delete mode 100644 Svc/UdpReceiver/test/ut/Tester.hpp delete mode 100644 Svc/UdpReceiver/test/ut/main.cpp delete mode 100644 Svc/UdpSender/UdpSenderComponentImpl.cpp delete mode 100644 Svc/UdpSender/UdpSenderComponentImpl.hpp delete mode 100644 Svc/UdpSender/test/ut/Tester.cpp delete mode 100644 Svc/UdpSender/test/ut/Tester.hpp delete mode 100644 Svc/UdpSender/test/ut/main.cpp diff --git a/Svc/UdpReceiver/UdpReceiverComponentImpl.cpp b/Svc/UdpReceiver/UdpReceiverComponentImpl.cpp deleted file mode 100644 index f94ce5f149..0000000000 --- a/Svc/UdpReceiver/UdpReceiverComponentImpl.cpp +++ /dev/null @@ -1,239 +0,0 @@ -// ====================================================================== -// \title UdpReceiverImpl.cpp -// \author tcanham -// \brief cpp file for UdpReceiver component implementation class -// -// \copyright -// Copyright 2009-2015, by the California Institute of Technology. -// ALL RIGHTS RESERVED. United States Government Sponsorship -// acknowledged. -// -// ====================================================================== - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Svc { - - // ---------------------------------------------------------------------- - // Construction, initialization, and destruction - // ---------------------------------------------------------------------- - - UdpReceiverComponentImpl :: - UdpReceiverComponentImpl( - const char *const compName - ) : UdpReceiverComponentBase(compName), - m_fd(-1), - m_packetsReceived(0), - m_bytesReceived(0), - m_packetsDropped(0), - m_decodeErrors(0), - m_firstSeq(true), - m_currSeq(0) - { - - } - - UdpReceiverComponentImpl :: - ~UdpReceiverComponentImpl() - { - if (this->m_fd != -1) { - close(this->m_fd); - } - } - - void UdpReceiverComponentImpl::open( - const char* port - ) { - - //create a UDP socket - this->m_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (-1 == this->m_fd) { - Fw::LogStringArg arg(strerror(errno)); - this->log_WARNING_HI_UR_SocketError(arg); - } - - sockaddr_in saddr; - // zero out the structure - memset(&saddr, 0, sizeof(saddr)); - - saddr.sin_family = AF_INET; - saddr.sin_port = htons(atoi(port)); - saddr.sin_addr.s_addr = htonl(INADDR_ANY); - - //bind socket to port - NATIVE_INT_TYPE status = bind(this->m_fd , (struct sockaddr*)&saddr, sizeof(saddr)); - if (-1 == status) { - Fw::LogStringArg arg(strerror(errno)); - this->log_WARNING_HI_UR_BindError(arg); - close(this->m_fd); - this->m_fd = -1; - } else { - this->log_ACTIVITY_HI_UR_PortOpened(atoi(port)); - } - } - - void UdpReceiverComponentImpl::startThread( - NATIVE_UINT_TYPE priority, /*!< read task priority */ - NATIVE_UINT_TYPE stackSize, /*!< stack size */ - NATIVE_UINT_TYPE affinity /*!< cpu affinity */ - ) { - Os::TaskString name(this->getObjName()); - Os::Task::TaskStatus stat = this->m_socketTask.start( - name, - 0, - priority, - stackSize, - UdpReceiverComponentImpl::workerTask, - this, - affinity); - FW_ASSERT(Os::Task::TASK_OK == stat,stat); - } - - - // ---------------------------------------------------------------------- - // Handler implementations for user-defined typed input ports - // ---------------------------------------------------------------------- - - void UdpReceiverComponentImpl :: - Sched_handler( - const FwIndexType portNum, - U32 context - ) - { - this->tlmWrite_UR_BytesReceived(this->m_bytesReceived); - this->tlmWrite_UR_PacketsReceived(this->m_packetsReceived); - this->tlmWrite_UR_PacketsDropped(this->m_packetsDropped); - } - - void UdpReceiverComponentImpl::workerTask(void* ptr) { - UdpReceiverComponentImpl *compPtr = static_cast(ptr); - while (true) { - compPtr->doRecv(); - } - } - - void UdpReceiverComponentImpl::doRecv() { - - // wait for data from the socket - NATIVE_INT_TYPE psize = recvfrom( - this->m_fd, - this->m_recvBuff.getBuffAddr(), - this->m_recvBuff.getBuffCapacity(), - MSG_WAITALL, - 0, - 0); - if (-1 == psize) { - if (errno != EINTR) { - Fw::LogStringArg arg(strerror(errno)); - this->log_WARNING_HI_UR_RecvError(arg); - } - return; - } - // reset buffer for deserialization - Fw::SerializeStatus stat = this->m_recvBuff.setBuffLen(psize); - FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, stat); - - // get sequence number - U8 seqNum; - stat = this->m_recvBuff.deserialize(seqNum); - // check for deserialization error or port number too high - if (stat != Fw::FW_SERIALIZE_OK) { - this->log_WARNING_HI_UR_DecodeError(DECODE_SEQ,stat); - this->m_decodeErrors++; - return; - } - - // track sequence number - if (this->m_firstSeq) { - // first time, set tracked sequence number equal to the one received - this->m_currSeq = seqNum; - this->m_firstSeq = false; - } else { - // make sure sequence number has gone up by one - if (seqNum != ++this->m_currSeq) { - // will only be right if it rolls over only once, but better than nothing - U8 diff = seqNum - this->m_currSeq; - this->m_packetsDropped += diff; - // send EVR - this->log_WARNING_HI_UR_DroppedPacket(diff); - // reset to current sequence - this->m_currSeq = seqNum; - } - } - - // get port number - U8 portNum; - stat = this->m_recvBuff.deserialize(portNum); - // check for deserialization error or port number too high - if (stat != Fw::FW_SERIALIZE_OK or portNum > this->getNum_PortsOut_OutputPorts()) { - this->log_WARNING_HI_UR_DecodeError(DECODE_PORT,stat); - this->m_decodeErrors++; - return; - } - // get buffer for port - - stat = this->m_recvBuff.deserialize(this->m_portBuff); - if (stat != Fw::FW_SERIALIZE_OK) { - this->log_WARNING_HI_UR_DecodeError(DECODE_BUFFER,stat); - this->m_decodeErrors++; - return; - } - - // call output port - if (this->isConnected_PortsOut_OutputPort(portNum)) { - - Fw::SerializeStatus stat = this->PortsOut_out(portNum,this->m_portBuff); - - // If had issues deserializing the data, then report it: - if (stat != Fw::FW_SERIALIZE_OK) { - - this->log_WARNING_HI_UR_DecodeError(PORT_SEND,stat); - this->m_decodeErrors++; - } - - this->m_packetsReceived++; - this->m_bytesReceived += psize; - - } - } - -#ifdef BUILD_UT - UdpReceiverComponentImpl::UdpSerialBuffer& UdpReceiverComponentImpl::UdpSerialBuffer::operator=(const UdpReceiverComponentImpl::UdpSerialBuffer& other) { - this->resetSer(); - this->serialize(other.getBuffAddr(),other.getBuffLength(),true); - return *this; - } - - UdpReceiverComponentImpl::UdpSerialBuffer::UdpSerialBuffer( - const Fw::SerializeBufferBase& other) : Fw::SerializeBufferBase() { - FW_ASSERT(sizeof(this->m_buff)>= other.getBuffLength(),sizeof(this->m_buff),other.getBuffLength()); - memcpy(this->m_buff,other.getBuffAddr(),other.getBuffLength()); - this->setBuffLen(other.getBuffLength()); - } - - UdpReceiverComponentImpl::UdpSerialBuffer::UdpSerialBuffer( - const UdpReceiverComponentImpl::UdpSerialBuffer& other) : Fw::SerializeBufferBase() { - FW_ASSERT(sizeof(this->m_buff)>= other.getBuffLength(),sizeof(this->m_buff),other.getBuffLength()); - memcpy(this->m_buff,other.m_buff,other.getBuffLength()); - this->setBuffLen(other.getBuffLength()); - } - - UdpReceiverComponentImpl::UdpSerialBuffer::UdpSerialBuffer(): Fw::SerializeBufferBase() { - - } - -#endif - - - -} // end namespace Svc diff --git a/Svc/UdpReceiver/UdpReceiverComponentImpl.hpp b/Svc/UdpReceiver/UdpReceiverComponentImpl.hpp deleted file mode 100644 index ea7e0ffebf..0000000000 --- a/Svc/UdpReceiver/UdpReceiverComponentImpl.hpp +++ /dev/null @@ -1,133 +0,0 @@ -// ====================================================================== -// \title UdpReceiverImpl.hpp -// \author tcanham -// \brief hpp file for UdpReceiver component implementation class -// -// \copyright -// Copyright 2009-2015, by the California Institute of Technology. -// ALL RIGHTS RESERVED. United States Government Sponsorship -// acknowledged. -// -// ====================================================================== - -#ifndef UdpReceiver_HPP -#define UdpReceiver_HPP - -#include "Svc/UdpReceiver/UdpReceiverComponentAc.hpp" -#include "UdpReceiverComponentImplCfg.hpp" - -namespace Svc { - - class UdpReceiverComponentImpl final : - public UdpReceiverComponentBase - { - - public: - - // ---------------------------------------------------------------------- - // Construction, initialization, and destruction - // ---------------------------------------------------------------------- - - //! Construct object UdpReceiver - //! - UdpReceiverComponentImpl( - const char *const compName /*!< The component name*/ - ); - - //! Destroy object UdpReceiver - //! - ~UdpReceiverComponentImpl(); - - //! Open the connection - void open( - const char* port - ); - - //! start worker thread - void startThread( - NATIVE_UINT_TYPE priority, /*!< read task priority */ - NATIVE_UINT_TYPE stackSize, /*!< stack size */ - NATIVE_UINT_TYPE affinity /*!< cpu affinity */ - ); - - - PRIVATE: - - // ---------------------------------------------------------------------- - // Handler implementations for user-defined typed input ports - // ---------------------------------------------------------------------- - - //! Handler implementation for Sched - //! - void Sched_handler( - const FwIndexType portNum, /*!< The port number*/ - U32 context /*!< The call order*/ - ); - - static void workerTask(void* ptr); //!< worker task entry point - void doRecv(); //!< receives a single packet (helps unit testing) - Os::Task m_socketTask; - - NATIVE_INT_TYPE m_fd; //!< socket file descriptor - - class UdpSerialBuffer : - public Fw::SerializeBufferBase - { - - public: - -#ifdef BUILD_UT - UdpSerialBuffer& operator=(const UdpSerialBuffer& other); - UdpSerialBuffer(const Fw::SerializeBufferBase& other); - UdpSerialBuffer(const UdpSerialBuffer& other); - UdpSerialBuffer(); -#endif - - NATIVE_UINT_TYPE getBuffCapacity() const { - return sizeof(m_buff); - } - - // Get the max number of bytes that can be serialized - NATIVE_UINT_TYPE getBuffSerLeft() const { - - const NATIVE_UINT_TYPE size = getBuffCapacity(); - const NATIVE_UINT_TYPE loc = getBuffLength(); - - if (loc >= (size-1) ) { - return 0; - } - else { - return (size - loc - 1); - } - } - - U8* getBuffAddr() { - return m_buff; - } - - const U8* getBuffAddr() const { - return m_buff; - } - - private: - // Should be the max of all the input ports serialized sizes... - U8 m_buff[UDP_RECEIVER_MSG_SIZE]; - - } m_recvBuff; - - UdpSerialBuffer m_portBuff; //!< working buffer for decoding packets - - U32 m_packetsReceived; //!< number of packets received - U32 m_bytesReceived; //!< number of bytes received - U32 m_packetsDropped; //!< number of detected packets dropped - U32 m_decodeErrors; //!< deserialization errors - - bool m_firstSeq; //!< first sequence number detected - U8 m_currSeq; //!< current tracked sequence number - - - }; - -} // end namespace Svc - -#endif diff --git a/Svc/UdpReceiver/test/ut/Tester.cpp b/Svc/UdpReceiver/test/ut/Tester.cpp deleted file mode 100644 index d3f226af9a..0000000000 --- a/Svc/UdpReceiver/test/ut/Tester.cpp +++ /dev/null @@ -1,207 +0,0 @@ -// ====================================================================== -// \title UdpReceiver.hpp -// \author tcanham -// \brief cpp file for UdpReceiver test harness implementation class -// -// \copyright -// Copyright 2009-2015, by the California Institute of Technology. -// ALL RIGHTS RESERVED. United States Government Sponsorship -// acknowledged. -// -// ====================================================================== - -#include "Tester.hpp" -#include -#include -#include -#include -#include -#include -#include - -#define INSTANCE 0 -#define MAX_HISTORY_SIZE 10 - -namespace Svc { - - // ---------------------------------------------------------------------- - // Construction and destruction - // ---------------------------------------------------------------------- - - Tester :: - Tester() : - UdpReceiverGTestBase("Tester", MAX_HISTORY_SIZE), - component("UdpReceiver") - { - this->initComponents(); - this->connectPorts(); - } - - Tester :: - ~Tester() - { - - } - - // ---------------------------------------------------------------------- - // Tests - // ---------------------------------------------------------------------- - - void Tester::openTest(const char* port) { - - this->component.open("50000"); - - } - - void Tester::recvTest(const char* port) { - - this->component.open("50000"); - - // send a packet - - this->sendPacket(20,"127.0.0.1","50000",26,3); - - // retrieve the packet - - this->m_sentVal = 0; - this->m_sentPort = 0; - this->component.doRecv(); - - // verify the port call - - EXPECT_EQ(20u,this->m_sentVal); - EXPECT_EQ(3,this->m_sentPort); - - } - - - // ---------------------------------------------------------------------- - // Handlers for serial from ports - // ---------------------------------------------------------------------- - - void Tester :: - from_PortsOut_handler( - FwIndexType portNum, /*!< The port number*/ - Fw::SerializeBufferBase &Buffer /*!< The serialization buffer*/ - ) - { - this->m_sentPort = portNum; - EXPECT_EQ(Fw::FW_SERIALIZE_OK,Buffer.deserialize(this->m_sentVal)); - - } - - // ---------------------------------------------------------------------- - // Helper methods - // ---------------------------------------------------------------------- - - void Tester :: - connectPorts() - { - - // Sched - this->connect_to_Sched( - 0, - this->component.get_Sched_InputPort(0) - ); - - // Tlm - this->component.set_Tlm_OutputPort( - 0, - this->get_from_Tlm(0) - ); - - // Time - this->component.set_Time_OutputPort( - 0, - this->get_from_Time(0) - ); - - // Log - this->component.set_Log_OutputPort( - 0, - this->get_from_Log(0) - ); - - // LogText - this->component.set_LogText_OutputPort( - 0, - this->get_from_LogText(0) - ); - - // Output serial ports - for (FwIndexType port = 0; port < UdpReceiverComponentImpl::NUM_PORTSOUT_OUTPUT_PORTS; port++) { - this->component.set_PortsOut_OutputPort(port,this->get_from_PortsOut(port)); - } - - - // ---------------------------------------------------------------------- - // Connect serial output ports - // ---------------------------------------------------------------------- - for (NATIVE_INT_TYPE i = 0; i < 10; ++i) { - this->component.set_PortsOut_OutputPort( - i, - this->get_from_PortsOut(i) - ); - } - - - - } - - void Tester :: - initComponents() - { - this->init(); - this->component.init( - INSTANCE - ); - } - - void Tester::sendPacket(U32 val, const char* addr, const char* port, NATIVE_UINT_TYPE seq, NATIVE_UINT_TYPE portNum) { - // open UDP connection - NATIVE_INT_TYPE fd = socket(AF_INET, SOCK_DGRAM, 0); - EXPECT_NE(fd,-1); - - /* fill in the server's address and data */ - struct sockaddr_in sockAddr; - memset(&sockAddr, 0, sizeof(sockAddr)); - sockAddr.sin_family = AF_INET; - sockAddr.sin_port = htons(atoi(port)); - inet_aton(addr , &sockAddr.sin_addr); - - - UdpReceiverComponentImpl::UdpSerialBuffer buff; - - // serialize sequence number - EXPECT_EQ(Fw::FW_SERIALIZE_OK,buff.serialize(static_cast(seq))); - // serialize port call - EXPECT_EQ(Fw::FW_SERIALIZE_OK,buff.serialize(static_cast(portNum))); - - UdpReceiverComponentImpl::UdpSerialBuffer portBuff; - EXPECT_EQ(Fw::FW_SERIALIZE_OK,portBuff.serialize(val)); - - EXPECT_EQ(Fw::FW_SERIALIZE_OK,buff.serialize(portBuff)); - // send on UDP socket - ssize_t sendStat = sendto(fd, - buff.getBuffAddr(), - buff.getBuffLength(), - 0, - reinterpret_cast(&sockAddr), - sizeof(sockAddr)); - EXPECT_NE(-1,sendStat); - EXPECT_EQ(buff.getBuffLength(),sendStat); - - close(fd); - } - - void Tester::textLogIn(const FwEventIdType id, //!< The event ID - Fw::Time& timeTag, //!< The time - const Fw::LogSeverity severity, //!< The severity - const Fw::TextLogString& text //!< The event string - ) { - TextLogEntry e = { id, timeTag, severity, text }; - - printTextLogHistoryEntry(e, stdout); - } - -} // end namespace Svc diff --git a/Svc/UdpReceiver/test/ut/Tester.hpp b/Svc/UdpReceiver/test/ut/Tester.hpp deleted file mode 100644 index 3ea02a19d4..0000000000 --- a/Svc/UdpReceiver/test/ut/Tester.hpp +++ /dev/null @@ -1,108 +0,0 @@ -// ====================================================================== -// \title UdpReceiver/test/ut/Tester.hpp -// \author tcanham -// \brief hpp file for UdpReceiver test harness implementation class -// -// \copyright -// Copyright 2009-2015, by the California Institute of Technology. -// ALL RIGHTS RESERVED. United States Government Sponsorship -// acknowledged. -// -// ====================================================================== - -#ifndef TESTER_HPP -#define TESTER_HPP - -#include "UdpReceiverGTestBase.hpp" -#include "Svc/UdpReceiver/UdpReceiverComponentImpl.hpp" - -namespace Svc { - - class Tester : - public UdpReceiverGTestBase - { - - // ---------------------------------------------------------------------- - // Construction and destruction - // ---------------------------------------------------------------------- - - public: - - //! Construct object Tester - //! - Tester(); - - //! Destroy object Tester - //! - ~Tester(); - - public: - - // ---------------------------------------------------------------------- - // Tests - // ---------------------------------------------------------------------- - - //! Open the connection - //! - void openTest(const char* port); - - //! Receive a packet - //! - void recvTest(const char* port); - - private: - - // ---------------------------------------------------------------------- - // Handlers for serial from ports - // ---------------------------------------------------------------------- - - //! Handler for from_PortsOut - //! - void from_PortsOut_handler( - FwIndexType portNum, /*!< The port number*/ - Fw::SerializeBufferBase &Buffer /*!< The serialization buffer*/ - ); - - private: - - // ---------------------------------------------------------------------- - // Helper methods - // ---------------------------------------------------------------------- - - //! Connect ports - //! - void connectPorts(); - - //! Initialize components - //! - void initComponents(); - - private: - - // ---------------------------------------------------------------------- - // Variables - // ---------------------------------------------------------------------- - - //! The component under test - //! - UdpReceiverComponentImpl component; - - // helper to send a packet - void sendPacket(U32 val, const char* addr, const char* port, NATIVE_UINT_TYPE seq, NATIVE_UINT_TYPE portNum); - - // stored port call arguments - U32 m_sentVal; - NATIVE_INT_TYPE m_sentPort; - - void textLogIn( - const FwEventIdType id, //!< The event ID - Fw::Time& timeTag, //!< The time - const Fw::LogSeverity severity, //!< The severity - const Fw::TextLogString& text //!< The event string - ); - - }; - -} // end namespace Svc - -#endif diff --git a/Svc/UdpReceiver/test/ut/main.cpp b/Svc/UdpReceiver/test/ut/main.cpp deleted file mode 100644 index 5556aabe37..0000000000 --- a/Svc/UdpReceiver/test/ut/main.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -TEST(Nominal,OpenConnection) { - - COMMENT("Open the connections"); - - Svc::Tester tester; - tester.openTest("50000"); - -} - -TEST(Nominal,RecvPacket) { - - COMMENT("Receive a packet"); - - Svc::Tester tester; - tester.recvTest("50000"); - -} - -int main(int argc, char* argv[]) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/Svc/UdpSender/UdpSenderComponentImpl.cpp b/Svc/UdpSender/UdpSenderComponentImpl.cpp deleted file mode 100644 index 9fcd350b17..0000000000 --- a/Svc/UdpSender/UdpSenderComponentImpl.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// ====================================================================== -// \title UdpSenderImpl.cpp -// \author tcanham -// \brief cpp file for UdpSender component implementation class -// -// \copyright -// Copyright 2009-2015, by the California Institute of Technology. -// ALL RIGHTS RESERVED. United States Government Sponsorship -// acknowledged. -// -// ====================================================================== - - -#include -#include -#include -#include -#include -#include -#include - -namespace Svc { - - // ---------------------------------------------------------------------- - // Construction, initialization, and destruction - // ---------------------------------------------------------------------- - - UdpSenderComponentImpl :: - UdpSenderComponentImpl( - const char *const compName - ) : UdpSenderComponentBase(compName), - m_fd(-1), - m_packetsSent(0), - m_bytesSent(0), - m_seq(0) - { - - } - - UdpSenderComponentImpl :: - ~UdpSenderComponentImpl() - { - if (this->m_fd != -1) { - close(this->m_fd); - } - } - - void UdpSenderComponentImpl::open( - const char* addr, /*!< server address */ - const char* port /*!< server port */ - ) { - - FW_ASSERT(addr); - FW_ASSERT(port); - // open UDP connection - this->m_fd = socket(AF_INET, SOCK_DGRAM, 0); - if (-1 == this->m_fd) { - Fw::LogStringArg arg(strerror(errno)); - this->log_WARNING_HI_US_SocketError(arg); - return; - } - - /* fill in the server's address and data */ - memset(&m_servAddr, 0, sizeof(m_servAddr)); - m_servAddr.sin_family = AF_INET; - m_servAddr.sin_port = htons(atoi(port)); - inet_aton(addr , &m_servAddr.sin_addr); - - Fw::LogStringArg arg(addr); - this->log_ACTIVITY_HI_US_PortOpened(arg,atoi(port)); - - } - - - - // ---------------------------------------------------------------------- - // Handler implementations for user-defined typed input ports - // ---------------------------------------------------------------------- - - void UdpSenderComponentImpl :: - Sched_handler( - const FwIndexType portNum, - U32 context - ) - { - this->tlmWrite_US_BytesSent(this->m_bytesSent); - this->tlmWrite_US_PacketsSent(this->m_packetsSent); - } - - // ---------------------------------------------------------------------- - // Handler implementations for user-defined serial input ports - // ---------------------------------------------------------------------- - - void UdpSenderComponentImpl :: - PortsIn_handler( - FwIndexType portNum, /*!< The port number*/ - Fw::SerializeBufferBase &Buffer /*!< The serialization buffer*/ - ) - { - // return if we never successfully created the socket - if (-1 == this->m_fd) { - return; - } - - Fw::SerializeStatus stat; - m_sendBuff.resetSer(); - - // serialize sequence number - stat = m_sendBuff.serialize(this->m_seq++); - FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,stat); - // serialize port call - stat = m_sendBuff.serialize(static_cast(portNum)); - FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,stat); - // serialize port arguments buffer - stat = m_sendBuff.serialize(Buffer); - FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,stat); - // send on UDP socket - ssize_t sendStat = sendto(this->m_fd, - m_sendBuff.getBuffAddr(), - m_sendBuff.getBuffLength(), - 0, - reinterpret_cast(&m_servAddr), - sizeof(m_servAddr)); - if (-1 == sendStat) { - Fw::LogStringArg arg(strerror(errno)); - this->log_WARNING_HI_US_SendError(arg); - } else { - FW_ASSERT((int)m_sendBuff.getBuffLength() == sendStat,(int)m_sendBuff.getBuffLength(),sendStat,portNum); - this->m_packetsSent++; - this->m_bytesSent += sendStat; - } - } - -#ifdef BUILD_UT - UdpSerialBuffer& UdpSenderComponentImpl::UdpSerialBuffer::operator=(const Svc::UdpSenderComponentImpl::UdpSerialBuffer& other) { - this->resetSer(); - this->serialize(other.getBuffAddr(),other.getBuffLength(),true); - return *this; - } - - UdpSenderComponentImpl::UdpSerialBuffer::UdpSerialBuffer( - const Fw::SerializeBufferBase& other) : Fw::SerializeBufferBase() { - FW_ASSERT(sizeof(this->m_buff)>= other.getBuffLength(),sizeof(this->m_buff),other.getBuffLength()); - memcpy(this->m_buff,other.getBuffAddr(),other.getBuffLength()); - this->setBuffLen(other.getBuffLength()); - } - - UdpSenderComponentImpl::UdpSerialBuffer::UdpSerialBuffer( - const UdpSenderComponentImpl::UdpSerialBuffer& other) : Fw::SerializeBufferBase() { - FW_ASSERT(sizeof(this->m_buff)>= other.getBuffLength(),sizeof(this->m_buff),other.getBuffLength()); - memcpy(this->m_buff,other.m_buff,other.getBuffLength()); - this->setBuffLen(other.getBuffLength()); - } - - UdpSenderComponentImpl::UdpSerialBuffer::UdpSerialBuffer(): Fw::SerializeBufferBase() { - - } - -#endif - - -} // end namespace Svc diff --git a/Svc/UdpSender/UdpSenderComponentImpl.hpp b/Svc/UdpSender/UdpSenderComponentImpl.hpp deleted file mode 100644 index b778f7a22f..0000000000 --- a/Svc/UdpSender/UdpSenderComponentImpl.hpp +++ /dev/null @@ -1,133 +0,0 @@ -// ====================================================================== -// \title UdpSenderImpl.hpp -// \author tcanham -// \brief hpp file for UdpSender component implementation class -// -// \copyright -// Copyright 2009-2015, by the California Institute of Technology. -// ALL RIGHTS RESERVED. United States Government Sponsorship -// acknowledged. -// -// ====================================================================== - -#ifndef UdpSender_HPP -#define UdpSender_HPP - -#include -#include -#include -#include - - -namespace Svc { - - class UdpSenderComponentImpl final : - public UdpSenderComponentBase - { - - public: - - // ---------------------------------------------------------------------- - // Construction, initialization, and destruction - // ---------------------------------------------------------------------- - - //! Construct object UdpSender - //! - UdpSenderComponentImpl( - const char *const compName /*!< The component name*/ - ); - - //! Destroy object UdpSender - //! - ~UdpSenderComponentImpl(); - - //! Open the connection - //! - void open( - const char* addr, /*!< server address */ - const char* port /*!< server port */ - ); - - PRIVATE: - - // ---------------------------------------------------------------------- - // Handler implementations for user-defined typed input ports - // ---------------------------------------------------------------------- - - //! Handler implementation for Sched - //! - void Sched_handler( - const FwIndexType portNum, /*!< The port number*/ - U32 context /*!< The call order*/ - ); - - PRIVATE: - - // ---------------------------------------------------------------------- - // Handler implementations for user-defined serial input ports - // ---------------------------------------------------------------------- - - //! Handler implementation for PortsIn - //! - void PortsIn_handler( - FwIndexType portNum, /*!< The port number*/ - Fw::SerializeBufferBase &Buffer /*!< The serialization buffer*/ - ); - - NATIVE_INT_TYPE m_fd; //!< file descriptor for UDP socket - NATIVE_UINT_TYPE m_packetsSent; //!< number of packets sent to server - NATIVE_UINT_TYPE m_bytesSent; //!< number of bytes sent to server - U8 m_seq; //!< packet sequence number; used to detect drops on the server end - - struct sockaddr_in m_servAddr; //!< server address for sends - - class UdpSerialBuffer : - public Fw::SerializeBufferBase - { - - public: - -#ifdef BUILD_UT - UdpSerialBuffer& operator=(const UdpSerialBuffer& other); - UdpSerialBuffer(const Fw::SerializeBufferBase& other); - UdpSerialBuffer(const UdpSerialBuffer& other); - UdpSerialBuffer(); -#endif - - NATIVE_UINT_TYPE getBuffCapacity() const { - return sizeof(m_buff); - } - - // Get the max number of bytes that can be serialized - NATIVE_UINT_TYPE getBuffSerLeft() const { - - const NATIVE_UINT_TYPE size = getBuffCapacity(); - const NATIVE_UINT_TYPE loc = getBuffLength(); - - if (loc >= (size-1) ) { - return 0; - } - else { - return (size - loc - 1); - } - } - - U8* getBuffAddr() { - return m_buff; - } - - const U8* getBuffAddr() const { - return m_buff; - } - - private: - // Should be the max of all the input ports serialized sizes... - U8 m_buff[UDP_SENDER_MSG_SIZE]; - - } m_sendBuff; - - }; - -} // end namespace Svc - -#endif diff --git a/Svc/UdpSender/test/ut/Tester.cpp b/Svc/UdpSender/test/ut/Tester.cpp deleted file mode 100644 index b6a41701ed..0000000000 --- a/Svc/UdpSender/test/ut/Tester.cpp +++ /dev/null @@ -1,206 +0,0 @@ -// ====================================================================== -// \title UdpSender.hpp -// \author tcanham -// \brief cpp file for UdpSender test harness implementation class -// -// \copyright -// Copyright 2009-2015, by the California Institute of Technology. -// ALL RIGHTS RESERVED. United States Government Sponsorship -// acknowledged. -// -// ====================================================================== - -#include "Tester.hpp" - -#define INSTANCE 0 -#define MAX_HISTORY_SIZE 10 -#define QUEUE_DEPTH 10 - -namespace Svc { - - // ---------------------------------------------------------------------- - // Construction and destruction - // ---------------------------------------------------------------------- - - Tester :: - Tester() : - UdpSenderGTestBase("Tester", MAX_HISTORY_SIZE), - component("UdpSender") - ,m_recvFd(-1) - { - this->initComponents(); - this->connectPorts(); - } - - Tester :: - ~Tester() - { - close(this->m_recvFd); - } - - // ---------------------------------------------------------------------- - // Tests - // ---------------------------------------------------------------------- - - void Tester :: - openTest(const char* server, const char* port) - { - this->component.open(server,port); - - // expect successfully opened - ASSERT_EVENTS_SIZE(1); - ASSERT_EVENTS_US_PortOpened_SIZE(1); - } - - void Tester :: - sendTest(const char* server, const char* port) - { - this->component.open(server,port); - - // expect successfully opened - ASSERT_EVENTS_SIZE(1); - ASSERT_EVENTS_US_PortOpened_SIZE(1); - - // open receive port - this->udpRecvStart(port); - - this->clearEvents(); - // send a buffer - Svc::UdpSenderComponentImpl::UdpSerialBuffer buff; - ASSERT_EQ(Fw::FW_SERIALIZE_OK,buff.serialize(static_cast(10))); - - this->invoke_to_PortsIn(1,buff); - this->component.doDispatch(); - - // verify packet count - ASSERT_EVENTS_SIZE(0); - // verify byte count - this->invoke_to_Sched(0,0); - ASSERT_TLM_US_PacketsSent_SIZE(1); - ASSERT_TLM_US_PacketsSent(0,1); - - // get data back - U8 recvBytes[256]; - memset(recvBytes,0xFF,sizeof(recvBytes)); - NATIVE_INT_TYPE bytes = this->udpGet(recvBytes,sizeof(recvBytes)); - ASSERT_EQ(bytes,8); - Fw::ExternalSerializeBuffer checkBuff(recvBytes,8); - checkBuff.setBuffLen(8); - // deserialize data packet - U8 seq; - ASSERT_EQ(Fw::FW_SERIALIZE_OK,checkBuff.deserialize(seq)); - ASSERT_EQ(0,seq); - // deserialize port number - U8 port; - ASSERT_EQ(Fw::FW_SERIALIZE_OK,checkBuff.deserialize(port)); - ASSERT_EQ(1,port); - // deserialize buffer - Svc::UdpSenderComponentImpl::UdpSerialBuffer inBuff; - ASSERT_EQ(Fw::FW_SERIALIZE_OK,checkBuff.deserialize(inBuff)); - ASSERT_EQ(buff,inBuff); - - - } - - // ---------------------------------------------------------------------- - // Helper methods - // ---------------------------------------------------------------------- - - void Tester :: - connectPorts() - { - - // Sched - this->connect_to_Sched( - 0, - this->component.get_Sched_InputPort(0) - ); - - // Tlm - this->component.set_Tlm_OutputPort( - 0, - this->get_from_Tlm(0) - ); - - // Time - this->component.set_Time_OutputPort( - 0, - this->get_from_Time(0) - ); - - // Log - this->component.set_Log_OutputPort( - 0, - this->get_from_Log(0) - ); - - // LogText - this->component.set_LogText_OutputPort( - 0, - this->get_from_LogText(0) - ); - - - - // ---------------------------------------------------------------------- - // Connect serial input ports - // ---------------------------------------------------------------------- - // PortsIn - for (NATIVE_INT_TYPE i = 0; i < 10; ++i) { - this->connect_to_PortsIn( - i, - this->component.get_PortsIn_InputPort(i) - ); - } - - - } - - void Tester :: - initComponents() - { - this->init(); - this->component.init( - QUEUE_DEPTH, 255, INSTANCE - ); - } - - void Tester::textLogIn(const FwEventIdType id, //!< The event ID - Fw::Time& timeTag, //!< The time - const Fw::LogSeverity severity, //!< The severity - const Fw::TextLogString& text //!< The event string - ) { - TextLogEntry e = { id, timeTag, severity, text }; - - printTextLogHistoryEntry(e, stdout); - } - - void Tester::udpRecvStart(const char* port) { - - sockaddr_in saddr; - //create a UDP socket - this->m_recvFd=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - EXPECT_NE(-1,this->m_recvFd); - - // zero out the structure - memset(&saddr, 0, sizeof(saddr)); - - saddr.sin_family = AF_INET; - saddr.sin_port = htons(atoi(port)); - saddr.sin_addr.s_addr = htonl(INADDR_ANY); - - //bind socket to port - EXPECT_NE(-1,bind(this->m_recvFd , (struct sockaddr*)&saddr, sizeof(saddr) )); - } - - NATIVE_INT_TYPE Tester::udpGet(U8* buff, NATIVE_UINT_TYPE size) { - - NATIVE_INT_TYPE psize = recvfrom(this->m_recvFd,buff,size,MSG_WAITALL,0,0); - EXPECT_NE(psize,-1); - return psize; - - } - - - -} // end namespace Svc diff --git a/Svc/UdpSender/test/ut/Tester.hpp b/Svc/UdpSender/test/ut/Tester.hpp deleted file mode 100644 index 824486bb87..0000000000 --- a/Svc/UdpSender/test/ut/Tester.hpp +++ /dev/null @@ -1,92 +0,0 @@ -// ====================================================================== -// \title UdpSender/test/ut/Tester.hpp -// \author tcanham -// \brief hpp file for UdpSender test harness implementation class -// -// \copyright -// Copyright 2009-2015, by the California Institute of Technology. -// ALL RIGHTS RESERVED. United States Government Sponsorship -// acknowledged. -// -// ====================================================================== - -#ifndef TESTER_HPP -#define TESTER_HPP - -#include "UdpSenderGTestBase.hpp" -#include "Svc/UdpSender/UdpSenderComponentImpl.hpp" - -namespace Svc { - - class Tester : - public UdpSenderGTestBase - { - - // ---------------------------------------------------------------------- - // Construction and destruction - // ---------------------------------------------------------------------- - - public: - - //! Construct object Tester - //! - Tester(); - - //! Destroy object Tester - //! - ~Tester(); - - public: - - // ---------------------------------------------------------------------- - // Tests - // ---------------------------------------------------------------------- - - //! open socket test - //! - void openTest(const char* server, const char* port); - - //! open socket test - //! - void sendTest(const char* server, const char* port); - - private: - - // ---------------------------------------------------------------------- - // Helper methods - // ---------------------------------------------------------------------- - - //! Connect ports - //! - void connectPorts(); - - //! Initialize components - //! - void initComponents(); - - private: - - // ---------------------------------------------------------------------- - // Variables - // ---------------------------------------------------------------------- - - //! The component under test - //! - UdpSenderComponentImpl component; - - void textLogIn( - const FwEventIdType id, //!< The event ID - Fw::Time& timeTag, //!< The time - const Fw::LogSeverity severity, //!< The severity - const Fw::TextLogString& text //!< The event string - ); - - NATIVE_INT_TYPE m_recvFd; - void udpRecvStart(const char* port); - NATIVE_INT_TYPE udpGet(U8* buff, NATIVE_UINT_TYPE size); - - }; - -} // end namespace Svc - -#endif diff --git a/Svc/UdpSender/test/ut/main.cpp b/Svc/UdpSender/test/ut/main.cpp deleted file mode 100644 index b55b4be770..0000000000 --- a/Svc/UdpSender/test/ut/main.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -TEST(Nominal,OpenConnection) { - - COMMENT("Open the connections"); - - Svc::Tester tester; - tester.openTest("127.0.0.1","50000"); - -} - -TEST(Nominal,SendPacket) { - - COMMENT("Send a packet"); - - Svc::Tester tester; - tester.sendTest("127.0.0.1","50000"); - -} - -int main(int argc, char* argv[]) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} From f2591086fec6fdec93182ae29868e17be042e1fd Mon Sep 17 00:00:00 2001 From: M Starch Date: Thu, 13 Mar 2025 10:14:08 -0700 Subject: [PATCH 21/34] NATIVE_ types from Health --- Svc/Health/HealthComponentImpl.cpp | 26 +++++++++++++------------- Svc/Health/HealthComponentImpl.hpp | 10 +++++----- Svc/Health/test/ut/HealthTester.cpp | 8 ++++---- Svc/Health/test/ut/HealthTester.hpp | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Svc/Health/HealthComponentImpl.cpp b/Svc/Health/HealthComponentImpl.cpp index fb4b51c1ef..0595e6f9a0 100644 --- a/Svc/Health/HealthComponentImpl.cpp +++ b/Svc/Health/HealthComponentImpl.cpp @@ -15,7 +15,7 @@ #include namespace Svc { - + static_assert((HealthComponentBase::NUM_PINGSEND_OUTPUT_PORTS >= 0) && (HealthComponentBase::NUM_PINGSEND_OUTPUT_PORTS <= std::numeric_limits::max()), "NUM_PINGSEND_OUTPUT_PORTS must fit in the positive range of FwIndexType"); // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- @@ -29,8 +29,8 @@ namespace Svc { m_enabled(Fw::Enabled::ENABLED), queue_depth(0) { // clear tracker by disabling pings - for (NATIVE_UINT_TYPE entry = 0; - entry < FW_NUM_ARRAY_ELEMENTS(this->m_pingTrackerEntries); + for (FwIndexType entry = 0; + entry < static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_pingTrackerEntries)); entry++) { this->m_pingTrackerEntries[entry].enabled = Fw::Enabled::DISABLED; } @@ -42,17 +42,17 @@ namespace Svc { } - void HealthImpl::setPingEntries(PingEntry* pingEntries, NATIVE_INT_TYPE numPingEntries, U32 watchDogCode) { + void HealthImpl::setPingEntries(PingEntry* pingEntries, FwIndexType numPingEntries, U32 watchDogCode) { FW_ASSERT(pingEntries); // make sure not asking for more pings than ports FW_ASSERT(numPingEntries <= NUM_PINGSEND_OUTPUT_PORTS); - this->m_numPingEntries = static_cast(numPingEntries); + this->m_numPingEntries = numPingEntries; this->m_watchDogCode = watchDogCode; // copy entries to private data - for (NATIVE_INT_TYPE entry = 0; entry < numPingEntries; entry++) { + for (FwIndexType entry = 0; entry < numPingEntries; entry++) { FW_ASSERT( pingEntries[entry].warnCycles <= pingEntries[entry].fatalCycles, static_cast(pingEntries[entry].warnCycles), @@ -87,7 +87,7 @@ namespace Svc { void HealthImpl::Run_handler(const FwIndexType portNum, U32 context) { //dispatch messages - for (NATIVE_UINT_TYPE i = 0; i < this->queue_depth; i++) { + for (FwSizeType i = 0; i < this->queue_depth; i++) { MsgDispatchStatus stat = this->doDispatch(); if (MSG_DISPATCH_EMPTY == stat) { break; @@ -100,7 +100,7 @@ namespace Svc { // for ports that are awaiting a reply, decrement their counters // and check for violations - for (NATIVE_UINT_TYPE entry = 0; entry < this->m_numPingEntries; entry++) { + for (FwIndexType entry = 0; entry < this->m_numPingEntries; entry++) { if (Fw::Enabled::ENABLED == this->m_pingTrackerEntries[entry].enabled) { // If clear entry if (0 == this->m_pingTrackerEntries[entry].cycleCount) { @@ -161,7 +161,7 @@ namespace Svc { void HealthImpl::HLTH_PING_ENABLE_cmdHandler(const FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg& entry, Fw::Enabled enable) { // check to see if entry is in range - NATIVE_INT_TYPE entryIndex = this->findEntry(entry); + FwIndexType entryIndex = this->findEntry(entry); if (-1 == entryIndex) { this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::VALIDATION_ERROR); @@ -181,7 +181,7 @@ namespace Svc { void HealthImpl::HLTH_CHNG_PING_cmdHandler(const FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg& entry, U32 warningValue, U32 fatalValue) { // check to see if entry is in range - NATIVE_INT_TYPE entryIndex = this->findEntry(entry); + FwIndexType entryIndex = this->findEntry(entry); if (-1 == entryIndex) { this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::VALIDATION_ERROR); return; @@ -203,12 +203,12 @@ namespace Svc { this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK); } - NATIVE_INT_TYPE HealthImpl::findEntry(const Fw::CmdStringArg& entry) { - + FwIndexType HealthImpl::findEntry(const Fw::CmdStringArg& entry) { + static_assert(std::numeric_limits::is_signed, "FwIndexType must be signed to return -1 for error"); // walk through entries for (FwIndexType tableEntry = 0; tableEntry < NUM_PINGSEND_OUTPUT_PORTS; tableEntry++) { if (entry == this->m_pingTrackerEntries[tableEntry].entry.entryName) { - return static_cast(tableEntry); + return static_cast(tableEntry); } } Fw::LogStringArg arg = entry; diff --git a/Svc/Health/HealthComponentImpl.hpp b/Svc/Health/HealthComponentImpl.hpp index 4b3eae04fe..e76976646a 100644 --- a/Svc/Health/HealthComponentImpl.hpp +++ b/Svc/Health/HealthComponentImpl.hpp @@ -43,8 +43,8 @@ namespace Svc { //! event. A descriptive name is stored in entryName //! for events. struct PingEntry { - NATIVE_UINT_TYPE warnCycles; //!< number of cycles before WARNING - NATIVE_UINT_TYPE fatalCycles; //!< number of cycles before FATAL + FwSizeType warnCycles; //!< number of cycles before WARNING + FwSizeType fatalCycles; //!< number of cycles before FATAL Fw::String entryName; //!< the name of the entry }; @@ -70,7 +70,7 @@ namespace Svc { //! \param pingEntries Pointer to provided ping table entries //! \param numPingEntries Number of ping entries in table //! \param watchDogCode Value that is sent to watchdog - void setPingEntries(PingEntry* pingEntries, NATIVE_INT_TYPE numPingEntries, U32 watchDogCode); + void setPingEntries(PingEntry* pingEntries, FwIndexType numPingEntries, U32 watchDogCode); //! \brief Component destructor //! @@ -142,10 +142,10 @@ namespace Svc { Fw::Enabled::t enabled; //!< if current ping result is checked } m_pingTrackerEntries[NUM_PINGSEND_OUTPUT_PORTS]; - NATIVE_INT_TYPE findEntry(const Fw::CmdStringArg& entry); + FwIndexType findEntry(const Fw::CmdStringArg& entry); //! Private member data - U32 m_numPingEntries; //!< stores number of entries passed to constructor + FwIndexType m_numPingEntries; //!< stores number of entries passed to constructor U32 m_key; //!< current key value. Just increments for each ping entry. U32 m_watchDogCode; //!< stores code used for watchdog stroking U32 m_warnings; //!< number of slip warnings issued diff --git a/Svc/Health/test/ut/HealthTester.cpp b/Svc/Health/test/ut/HealthTester.cpp index 3c02266cd3..14917c8b20 100644 --- a/Svc/Health/test/ut/HealthTester.cpp +++ b/Svc/Health/test/ut/HealthTester.cpp @@ -84,7 +84,7 @@ namespace Svc { { // PingReturn - for (NATIVE_INT_TYPE i = 0; i < this->component.getNum_PingReturn_InputPorts(); ++i) { + for (FwIndexType i = 0; i < this->component.getNum_PingReturn_InputPorts(); ++i) { this->connect_to_PingReturn( i, this->component.get_PingReturn_InputPort(i) @@ -104,7 +104,7 @@ namespace Svc { ); // PingSend - for (NATIVE_INT_TYPE i = 0; i < this->component.getNum_PingSend_OutputPorts(); ++i) { + for (FwIndexType i = 0; i < this->component.getNum_PingSend_OutputPorts(); ++i) { this->component.set_PingSend_OutputPort( i, this->get_from_PingSend(i) @@ -178,7 +178,7 @@ namespace Svc { this->override = false; this->override_key = 0; - for (U32 i = 0; i < this->numPingEntries; i++) { + for (FwIndexType i = 0; i < this->numPingEntries; i++) { this->keys[i] = 100000; } } @@ -726,7 +726,7 @@ namespace Svc { this->component.m_key = 0; //reset cycle counts - for (U32 i = 0; i < this->numPingEntries; i++) { + for (FwIndexType i = 0; i < this->numPingEntries; i++) { this->component.m_pingTrackerEntries[i].cycleCount = 0; } diff --git a/Svc/Health/test/ut/HealthTester.hpp b/Svc/Health/test/ut/HealthTester.hpp index 0ef548f3ab..4e990a8e93 100644 --- a/Svc/Health/test/ut/HealthTester.hpp +++ b/Svc/Health/test/ut/HealthTester.hpp @@ -95,7 +95,7 @@ namespace Svc { // Variables // ---------------------------------------------------------------------- - NATIVE_UINT_TYPE numPingEntries; + FwIndexType numPingEntries; HealthImpl::PingEntry pingEntries[Svc::HealthComponentBase::NUM_PINGSEND_OUTPUT_PORTS]; U32 watchDogCode; U32 keys[Svc::HealthComponentBase::NUM_PINGSEND_OUTPUT_PORTS]; From 3b1c9bd006ea635c42002cfbb6f8cf853929b312 Mon Sep 17 00:00:00 2001 From: M Starch Date: Thu, 13 Mar 2025 10:19:42 -0700 Subject: [PATCH 22/34] NATIVE_ types from CmdSequencer --- Svc/CmdSequencer/CmdSequencerImpl.cpp | 4 ++-- Svc/CmdSequencer/CmdSequencerImpl.hpp | 6 +++--- Svc/CmdSequencer/test/ut/CmdSequencerTester.hpp | 2 +- Svc/CmdSequencer/test/ut/InvalidFiles.cpp | 4 ++-- Svc/CmdSequencer/test/ut/SequenceFiles/MixedFile.cpp | 2 +- Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.cpp | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Svc/CmdSequencer/CmdSequencerImpl.cpp b/Svc/CmdSequencer/CmdSequencerImpl.cpp index b955f828fb..04531403c0 100644 --- a/Svc/CmdSequencer/CmdSequencerImpl.cpp +++ b/Svc/CmdSequencer/CmdSequencerImpl.cpp @@ -44,7 +44,7 @@ namespace Svc { } - void CmdSequencerComponentImpl::setTimeout(const NATIVE_UINT_TYPE timeout) { + void CmdSequencerComponentImpl::setTimeout(const U32 timeout) { this->m_timeout = timeout; } @@ -322,7 +322,7 @@ namespace Svc { } void CmdSequencerComponentImpl :: - schedIn_handler(FwIndexType portNum, NATIVE_UINT_TYPE order) + schedIn_handler(FwIndexType portNum, U32 order) { Fw::Time currTime = this->getTime(); diff --git a/Svc/CmdSequencer/CmdSequencerImpl.hpp b/Svc/CmdSequencer/CmdSequencerImpl.hpp index beef78b45d..8c73523a8a 100644 --- a/Svc/CmdSequencer/CmdSequencerImpl.hpp +++ b/Svc/CmdSequencer/CmdSequencerImpl.hpp @@ -529,7 +529,7 @@ namespace Svc { //! Sequence will quit if a command takes longer than the number of //! seconds in the timeout value. void setTimeout( - const NATIVE_UINT_TYPE seconds //!< The number of seconds + const U32 seconds //!< The number of seconds ); //! (Optional) Set the sequence format. @@ -580,7 +580,7 @@ namespace Svc { //! Handler for input port schedIn void schedIn_handler( FwIndexType portNum, //!< The port number - NATIVE_UINT_TYPE order //!< The call order + U32 order //!< The call order ); //! Handler for input port seqRunIn @@ -768,7 +768,7 @@ namespace Svc { U32 m_sequencesCompletedCount; //! timeout value - NATIVE_UINT_TYPE m_timeout; + U32 m_timeout; //! timeout timer Timer m_cmdTimeoutTimer; diff --git a/Svc/CmdSequencer/test/ut/CmdSequencerTester.hpp b/Svc/CmdSequencer/test/ut/CmdSequencerTester.hpp index 55ea92899d..324aa1021b 100644 --- a/Svc/CmdSequencer/test/ut/CmdSequencerTester.hpp +++ b/Svc/CmdSequencer/test/ut/CmdSequencerTester.hpp @@ -39,7 +39,7 @@ namespace Svc { // Constants // ---------------------------------------------------------------------- - static const NATIVE_UINT_TYPE TEST_SEQ_BUFFER_SIZE = 255; + static const FwSizeType TEST_SEQ_BUFFER_SIZE = 255; protected: diff --git a/Svc/CmdSequencer/test/ut/InvalidFiles.cpp b/Svc/CmdSequencer/test/ut/InvalidFiles.cpp index b2914bc295..dce66405de 100644 --- a/Svc/CmdSequencer/test/ut/InvalidFiles.cpp +++ b/Svc/CmdSequencer/test/ut/InvalidFiles.cpp @@ -77,7 +77,7 @@ namespace Svc { Fw::Time testTime(TB_WORKSTATION_TIME, 1, 1); this->setTestTime(testTime); // Write the file - NATIVE_INT_TYPE numRecords = 1; + FwSizeType numRecords = 1; SequenceFiles::BadDescriptorFile file(numRecords, this->format); file.write(); // Validate the file @@ -127,7 +127,7 @@ namespace Svc { Fw::Time testTime(TB_WORKSTATION_TIME, 1, 1); this->setTestTime(testTime); // Write the file - const NATIVE_INT_TYPE numRecords = 5; + const FwSizeType numRecords = 5; SequenceFiles::BadTimeBaseFile file(numRecords, this->format); file.write(); // Validate the file diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/MixedFile.cpp b/Svc/CmdSequencer/test/ut/SequenceFiles/MixedFile.cpp index f89130fd48..8476b41000 100644 --- a/Svc/CmdSequencer/test/ut/SequenceFiles/MixedFile.cpp +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/MixedFile.cpp @@ -29,7 +29,7 @@ namespace Svc { serializeFPrime(Fw::SerializeBufferBase& buffer) { // Header - const NATIVE_INT_TYPE numRecs = 4; + const FwSizeType numRecs = 4; const U32 recordDataSize = numRecs * FPrime::Records::STANDARD_SIZE; const U32 dataSize = recordDataSize + FPrime::CRCs::SIZE; diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.cpp b/Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.cpp index 2d641fabf0..19198aa6a8 100644 --- a/Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.cpp +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.cpp @@ -26,7 +26,7 @@ namespace Svc { void NoRecordsFile::serializeFPrime(Fw::SerializeBufferBase& buffer) { // Header - const NATIVE_INT_TYPE numRecs = 0; + const FwSizeType numRecs = 0; const U32 recordDataSize = numRecs * FPrime::Records::STANDARD_SIZE; const U32 dataSize = recordDataSize + FPrime::CRCs::SIZE; const TimeBase timeBase = TB_WORKSTATION_TIME; From 7015ec60132f95988d293e8a23a091b9fdb356cf Mon Sep 17 00:00:00 2001 From: M Starch Date: Thu, 13 Mar 2025 10:33:35 -0700 Subject: [PATCH 23/34] NATIVE_ types from TlmPacketizer --- Svc/TlmPacketizer/TlmPacketizer.cpp | 47 ++++++++++--------- Svc/TlmPacketizer/TlmPacketizer.hpp | 20 ++++---- Svc/TlmPacketizer/TlmPacketizerTypes.hpp | 8 ++-- .../test/ut/TlmPacketizerTester.cpp | 4 +- config/TlmPacketizerCfg.hpp | 10 ++-- 5 files changed, 46 insertions(+), 43 deletions(-) diff --git a/Svc/TlmPacketizer/TlmPacketizer.cpp b/Svc/TlmPacketizer/TlmPacketizer.cpp index 7752a666b2..a950743421 100644 --- a/Svc/TlmPacketizer/TlmPacketizer.cpp +++ b/Svc/TlmPacketizer/TlmPacketizer.cpp @@ -21,11 +21,11 @@ namespace Svc { TlmPacketizer ::TlmPacketizer(const char* const compName) : TlmPacketizerComponentBase(compName), m_numPackets(0), m_configured(false), m_startLevel(0), m_maxLevel(0) { // clear slot pointers - for (NATIVE_UINT_TYPE entry = 0; entry < TLMPACKETIZER_NUM_TLM_HASH_SLOTS; entry++) { + for (FwChanIdType entry = 0; entry < TLMPACKETIZER_NUM_TLM_HASH_SLOTS; entry++) { this->m_tlmEntries.slots[entry] = nullptr; } // clear buckets - for (NATIVE_UINT_TYPE entry = 0; entry < TLMPACKETIZER_HASH_BUCKETS; entry++) { + for (FwChanIdType entry = 0; entry < TLMPACKETIZER_HASH_BUCKETS; entry++) { this->m_tlmEntries.buckets[entry].used = false; this->m_tlmEntries.buckets[entry].bucketNo = entry; this->m_tlmEntries.buckets[entry].next = nullptr; @@ -34,13 +34,13 @@ TlmPacketizer ::TlmPacketizer(const char* const compName) // clear free index this->m_tlmEntries.free = 0; // clear missing tlm channel check - for (NATIVE_UINT_TYPE entry = 0; entry < TLMPACKETIZER_MAX_MISSING_TLM_CHECK; entry++) { + for (FwChanIdType entry = 0; entry < TLMPACKETIZER_MAX_MISSING_TLM_CHECK; entry++) { this->m_missTlmCheck[entry].checked = false; this->m_missTlmCheck[entry].id = 0; } // clear packet buffers - for (NATIVE_UINT_TYPE buffer = 0; buffer < MAX_PACKETIZER_PACKETS; buffer++) { + for (FwChanIdType buffer = 0; buffer < MAX_PACKETIZER_PACKETS; buffer++) { this->m_fillBuffers[buffer].updated = false; this->m_fillBuffers[buffer].requested = false; this->m_sendBuffers[buffer].updated = false; @@ -51,19 +51,20 @@ TlmPacketizer ::~TlmPacketizer() {} void TlmPacketizer::setPacketList(const TlmPacketizerPacketList& packetList, const Svc::TlmPacketizerPacket& ignoreList, - const NATIVE_UINT_TYPE startLevel) { + const FwChanIdType startLevel) { FW_ASSERT(packetList.list); FW_ASSERT(ignoreList.list); FW_ASSERT(packetList.numEntries <= MAX_PACKETIZER_PACKETS, static_cast(packetList.numEntries)); // validate packet sizes against maximum com buffer size and populate hash // table - for (NATIVE_UINT_TYPE pktEntry = 0; pktEntry < packetList.numEntries; pktEntry++) { + for (FwChanIdType pktEntry = 0; pktEntry < packetList.numEntries; pktEntry++) { // Initial size is packetized telemetry descriptor + size of time tag + sizeof packet ID - NATIVE_UINT_TYPE packetLen = + //TODO: do I add a check here + FwSizeType packetLen = sizeof(FwPacketDescriptorType) + Fw::Time::SERIALIZED_SIZE + sizeof(FwTlmPacketizeIdType); FW_ASSERT(packetList.list[pktEntry]->list, static_cast(pktEntry)); // add up entries for each defined packet - for (NATIVE_UINT_TYPE tlmEntry = 0; tlmEntry < packetList.list[pktEntry]->numEntries; tlmEntry++) { + for (FwChanIdType tlmEntry = 0; tlmEntry < packetList.list[pktEntry]->numEntries; tlmEntry++) { // get hash value for id FwChanIdType id = packetList.list[pktEntry]->list[tlmEntry].id; TlmEntry* entryToUse = this->findBucket(id); @@ -74,7 +75,9 @@ void TlmPacketizer::setPacketList(const TlmPacketizerPacketList& packetList, entryToUse->ignored = false; entryToUse->id = id; // the offset into the buffer will be the current packet length - entryToUse->packetOffset[pktEntry] = static_cast(packetLen); + // the offset must fit within FwIndexType to allow for negative values + FW_ASSERT(packetLen <= std::numeric_limits::max(), static_cast(packetLen)); + entryToUse->packetOffset[pktEntry] = static_cast(packetLen); packetLen += packetList.list[pktEntry]->list[tlmEntry].size; @@ -105,7 +108,7 @@ void TlmPacketizer::setPacketList(const TlmPacketizerPacketList& packetList, } // end packet list // populate hash table with ignore list - for (NATIVE_UINT_TYPE channelEntry = 0; channelEntry < ignoreList.numEntries; channelEntry++) { + for (FwChanIdType channelEntry = 0; channelEntry < ignoreList.numEntries; channelEntry++) { // get hash value for id FwChanIdType id = ignoreList.list[channelEntry].id; @@ -127,7 +130,7 @@ void TlmPacketizer::setPacketList(const TlmPacketizerPacketList& packetList, } TlmPacketizer::TlmEntry* TlmPacketizer::findBucket(FwChanIdType id) { - NATIVE_UINT_TYPE index = this->doHash(id); + FwChanIdType index = this->doHash(id); FW_ASSERT(index < TLMPACKETIZER_HASH_BUCKETS); TlmEntry* entryToUse = nullptr; TlmEntry* prevEntry = nullptr; @@ -135,7 +138,7 @@ TlmPacketizer::TlmEntry* TlmPacketizer::findBucket(FwChanIdType id) { // Search to see if channel has already been stored or a bucket needs to be added if (this->m_tlmEntries.slots[index]) { entryToUse = this->m_tlmEntries.slots[index]; - for (NATIVE_UINT_TYPE bucket = 0; bucket < TLMPACKETIZER_HASH_BUCKETS; bucket++) { + for (FwChanIdType bucket = 0; bucket < TLMPACKETIZER_HASH_BUCKETS; bucket++) { if (entryToUse) { if (entryToUse->id == id) { // found the matching entry break; @@ -154,7 +157,7 @@ TlmPacketizer::TlmEntry* TlmPacketizer::findBucket(FwChanIdType id) { // clear next pointer entryToUse->next = nullptr; // set all packet offsets to -1 for new entry - for (NATIVE_UINT_TYPE pktOffsetEntry = 0; pktOffsetEntry < MAX_PACKETIZER_PACKETS; pktOffsetEntry++) { + for (FwChanIdType pktOffsetEntry = 0; pktOffsetEntry < MAX_PACKETIZER_PACKETS; pktOffsetEntry++) { entryToUse->packetOffset[pktOffsetEntry] = -1; } break; @@ -168,7 +171,7 @@ TlmPacketizer::TlmEntry* TlmPacketizer::findBucket(FwChanIdType id) { entryToUse = this->m_tlmEntries.slots[index]; entryToUse->next = nullptr; // set all packet offsets to -1 for new entry - for (NATIVE_UINT_TYPE pktOffsetEntry = 0; pktOffsetEntry < MAX_PACKETIZER_PACKETS; pktOffsetEntry++) { + for (FwChanIdType pktOffsetEntry = 0; pktOffsetEntry < MAX_PACKETIZER_PACKETS; pktOffsetEntry++) { entryToUse->packetOffset[pktOffsetEntry] = -1; } } @@ -186,7 +189,7 @@ void TlmPacketizer ::TlmRecv_handler(const FwIndexType portNum, Fw::TlmBuffer& val) { FW_ASSERT(this->m_configured); // get hash value for id - NATIVE_UINT_TYPE index = this->doHash(id); + FwChanIdType index = this->doHash(id); TlmEntry* entryToUse = nullptr; // Search to see if the channel is being sent @@ -198,7 +201,7 @@ void TlmPacketizer ::TlmRecv_handler(const FwIndexType portNum, return; } - for (NATIVE_UINT_TYPE bucket = 0; bucket < TLMPACKETIZER_HASH_BUCKETS; bucket++) { + for (FwChanIdType bucket = 0; bucket < TLMPACKETIZER_HASH_BUCKETS; bucket++) { if (entryToUse) { if (entryToUse->id == id) { // found the matching entry // check to see if the channel is ignored. If so, just return. @@ -217,7 +220,7 @@ void TlmPacketizer ::TlmRecv_handler(const FwIndexType portNum, } // copy telemetry value into active buffers - for (NATIVE_UINT_TYPE pkt = 0; pkt < MAX_PACKETIZER_PACKETS; pkt++) { + for (FwChanIdType pkt = 0; pkt < MAX_PACKETIZER_PACKETS; pkt++) { // check if current packet has this channel if (entryToUse->packetOffset[pkt] != -1) { // get destination address @@ -243,7 +246,7 @@ void TlmPacketizer ::Run_handler(const FwIndexType portNum, U32 context) { // so the data can be read without worrying about updates this->m_lock.lock(); // copy buffers from fill side to send side - for (NATIVE_UINT_TYPE pkt = 0; pkt < this->m_numPackets; pkt++) { + for (FwChanIdType pkt = 0; pkt < this->m_numPackets; pkt++) { if ((this->m_fillBuffers[pkt].updated) and ((this->m_fillBuffers[pkt].level <= this->m_startLevel) or (this->m_fillBuffers[pkt].requested))) { this->m_sendBuffers[pkt] = this->m_fillBuffers[pkt]; @@ -263,7 +266,7 @@ void TlmPacketizer ::Run_handler(const FwIndexType portNum, U32 context) { this->m_lock.unLock(); // push all updated packet buffers - for (NATIVE_UINT_TYPE pkt = 0; pkt < this->m_numPackets; pkt++) { + for (FwChanIdType pkt = 0; pkt < this->m_numPackets; pkt++) { if (this->m_sendBuffers[pkt].updated) { // serialize time into time offset in packet Fw::ExternalSerializeBuffer buff( @@ -298,7 +301,7 @@ void TlmPacketizer ::SET_LEVEL_cmdHandler(const FwOpcodeType opCode, const U32 c } void TlmPacketizer ::SEND_PKT_cmdHandler(const FwOpcodeType opCode, const U32 cmdSeq, U32 id) { - NATIVE_UINT_TYPE pkt = 0; + FwChanIdType pkt = 0; for (pkt = 0; pkt < this->m_numPackets; pkt++) { if (this->m_fillBuffers[pkt].id == id) { this->m_lock.lock(); @@ -322,13 +325,13 @@ void TlmPacketizer ::SEND_PKT_cmdHandler(const FwOpcodeType opCode, const U32 cm this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); } -NATIVE_UINT_TYPE TlmPacketizer::doHash(FwChanIdType id) { +FwChanIdType TlmPacketizer::doHash(FwChanIdType id) { return (id % TLMPACKETIZER_HASH_MOD_VALUE) % TLMPACKETIZER_NUM_TLM_HASH_SLOTS; } void TlmPacketizer::missingChannel(FwChanIdType id) { // search to see if missing channel has already been sent - for (NATIVE_UINT_TYPE slot = 0; slot < TLMPACKETIZER_MAX_MISSING_TLM_CHECK; slot++) { + for (FwChanIdType slot = 0; slot < TLMPACKETIZER_MAX_MISSING_TLM_CHECK; slot++) { // if it's been checked, return if (this->m_missTlmCheck[slot].checked and (this->m_missTlmCheck[slot].id == id)) { return; diff --git a/Svc/TlmPacketizer/TlmPacketizer.hpp b/Svc/TlmPacketizer/TlmPacketizer.hpp index b1afaec5dd..fc547617c1 100644 --- a/Svc/TlmPacketizer/TlmPacketizer.hpp +++ b/Svc/TlmPacketizer/TlmPacketizer.hpp @@ -32,7 +32,7 @@ class TlmPacketizer final : public TlmPacketizerComponentBase { void setPacketList( const TlmPacketizerPacketList& packetList, // channels to packetize const Svc::TlmPacketizerPacket& ignoreList, // channels to ignore (i.e. no warning event if not packetized) - const NATIVE_UINT_TYPE startLevel); // starting level of packets to send + const FwChanIdType startLevel); // starting level of packets to send //! Destroy object TlmPacketizer //! @@ -78,15 +78,15 @@ class TlmPacketizer final : public TlmPacketizerComponentBase { ); // number of packets to fill - NATIVE_UINT_TYPE m_numPackets; + FwChanIdType m_numPackets; // Array of packet buffers to send // Double-buffered to fill one while sending one struct BufferEntry { Fw::ComBuffer buffer; //!< buffer for packetized channels Fw::Time latestTime; //!< latest update time - NATIVE_UINT_TYPE id; //!< channel id - NATIVE_UINT_TYPE level; //!< channel level + FwChanIdType id; //!< channel id + FwChanIdType level; //!< channel level bool updated; //!< if packet had any updates during last cycle bool requested; //!< if the packet was requested with SEND_PKT in the last cycle }; @@ -100,21 +100,21 @@ class TlmPacketizer final : public TlmPacketizerComponentBase { FwChanIdType id; //!< telemetry id stored in slot // Offsets into packet buffers. // -1 means that channel is not in that packet - NATIVE_INT_TYPE packetOffset[MAX_PACKETIZER_PACKETS]; + FwSignedSizeType packetOffset[MAX_PACKETIZER_PACKETS]; //TODO: what to do here? TlmEntry* next; //!< pointer to next bucket in table bool used; //!< if entry has been used bool ignored; //!< ignored packet id - NATIVE_UINT_TYPE bucketNo; //!< for testing + FwChanIdType bucketNo; //!< for testing }; struct TlmSet { TlmEntry* slots[TLMPACKETIZER_NUM_TLM_HASH_SLOTS]; //!< set of hash slots in hash table TlmEntry buckets[TLMPACKETIZER_HASH_BUCKETS]; //!< set of buckets used in hash table - NATIVE_UINT_TYPE free; //!< next free bucket + FwChanIdType free; //!< next free bucket } m_tlmEntries; // hash function for looking up telemetry channel - NATIVE_UINT_TYPE doHash(FwChanIdType id); + FwChanIdType doHash(FwChanIdType id); Os::Mutex m_lock; //!< used to lock access to packet buffers @@ -129,8 +129,8 @@ class TlmPacketizer final : public TlmPacketizerComponentBase { TlmEntry* findBucket(FwChanIdType id); - NATIVE_UINT_TYPE m_startLevel; //!< initial level for sending packets - NATIVE_UINT_TYPE m_maxLevel; //!< maximum level in all packets + FwChanIdType m_startLevel; //!< initial level for sending packets + FwChanIdType m_maxLevel; //!< maximum level in all packets }; } // end namespace Svc diff --git a/Svc/TlmPacketizer/TlmPacketizerTypes.hpp b/Svc/TlmPacketizer/TlmPacketizerTypes.hpp index 0ef7c38a62..06bfefe298 100644 --- a/Svc/TlmPacketizer/TlmPacketizerTypes.hpp +++ b/Svc/TlmPacketizer/TlmPacketizerTypes.hpp @@ -20,19 +20,19 @@ namespace Svc { struct TlmPacketizerChannelEntry { FwChanIdType id; //!< Id of channel - NATIVE_UINT_TYPE size; //!< serialized size of channel in bytes + FwSizeType size; //!< serialized size of channel in bytes }; struct TlmPacketizerPacket { const TlmPacketizerChannelEntry* list; //!< pointer to a channel entry FwTlmPacketizeIdType id; //!< packet ID - NATIVE_UINT_TYPE level; //!< packet level - used to select set of packets to send - NATIVE_UINT_TYPE numEntries; //!< number of channels in packet + FwChanIdType level; //!< packet level - used to select set of packets to send + FwChanIdType numEntries; //!< number of channels in packet }; struct TlmPacketizerPacketList { const TlmPacketizerPacket* list[MAX_PACKETIZER_PACKETS]; //!< - NATIVE_UINT_TYPE numEntries; + FwChanIdType numEntries; }; } // namespace Svc diff --git a/Svc/TlmPacketizer/test/ut/TlmPacketizerTester.cpp b/Svc/TlmPacketizer/test/ut/TlmPacketizerTester.cpp index 42a4982519..f293c68fea 100644 --- a/Svc/TlmPacketizer/test/ut/TlmPacketizerTester.cpp +++ b/Svc/TlmPacketizer/test/ut/TlmPacketizerTester.cpp @@ -866,7 +866,7 @@ void TlmPacketizerTester ::nonPacketizedChannelTest() { Fw::TlmBuffer buff; // start at non-used channel - for (NATIVE_UINT_TYPE channel = 1000; channel < 1000 + TLMPACKETIZER_MAX_MISSING_TLM_CHECK; channel++) { + for (FwChanIdType channel = 1000; channel < 1000 + TLMPACKETIZER_MAX_MISSING_TLM_CHECK; channel++) { this->clearEvents(); this->invoke_to_TlmRecv(0, channel, ts, buff); ASSERT_EVENTS_SIZE(1); @@ -882,7 +882,7 @@ void TlmPacketizerTester ::nonPacketizedChannelTest() { // sending the missing channels again should emit no events - for (NATIVE_UINT_TYPE channel = 1000; channel < 1000 + TLMPACKETIZER_MAX_MISSING_TLM_CHECK; channel++) { + for (FwChanIdType channel = 1000; channel < 1000 + TLMPACKETIZER_MAX_MISSING_TLM_CHECK; channel++) { this->clearEvents(); this->invoke_to_TlmRecv(0, channel, ts, buff); ASSERT_EVENTS_SIZE(0); diff --git a/config/TlmPacketizerCfg.hpp b/config/TlmPacketizerCfg.hpp index 2b514374a9..e073e00f32 100644 --- a/config/TlmPacketizerCfg.hpp +++ b/config/TlmPacketizerCfg.hpp @@ -16,18 +16,18 @@ #include namespace Svc { -static const NATIVE_UINT_TYPE MAX_PACKETIZER_PACKETS = 200; -static const NATIVE_UINT_TYPE TLMPACKETIZER_NUM_TLM_HASH_SLOTS = +static const FwChanIdType MAX_PACKETIZER_PACKETS = 200; +static const FwChanIdType TLMPACKETIZER_NUM_TLM_HASH_SLOTS = 15; // !< Number of slots in the hash table. // Works best when set to about twice the number of components producing telemetry -static const NATIVE_UINT_TYPE TLMPACKETIZER_HASH_MOD_VALUE = +static const FwChanIdType TLMPACKETIZER_HASH_MOD_VALUE = 99; // !< The modulo value of the hashing function. // Should be set to a little below the ID gaps to spread the entries around -static const NATIVE_UINT_TYPE TLMPACKETIZER_HASH_BUCKETS = +static const FwChanIdType TLMPACKETIZER_HASH_BUCKETS = 1000; // !< Buckets assignable to a hash slot. // Buckets must be >= number of telemetry channels in system -static const NATIVE_UINT_TYPE TLMPACKETIZER_MAX_MISSING_TLM_CHECK = +static const FwChanIdType TLMPACKETIZER_MAX_MISSING_TLM_CHECK = 25; // !< Maximum number of missing telemetry channel checks // packet update mode From 69fd08de948703445c169900b03351c2e1832ea4 Mon Sep 17 00:00:00 2001 From: M Starch Date: Thu, 13 Mar 2025 10:43:39 -0700 Subject: [PATCH 24/34] Fixing unit test issues --- Svc/BufferLogger/BufferLoggerFile.cpp | 2 +- Svc/DpCatalog/test/ut/DpCatalogTester.cpp | 2 +- Svc/DpCatalog/test/ut/DpCatalogTester.hpp | 2 +- Svc/DpManager/test/ut/Rules/CLEAR_EVENT_THROTTLE.cpp | 2 +- Svc/StaticMemory/StaticMemoryComponentImpl.cpp | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Svc/BufferLogger/BufferLoggerFile.cpp b/Svc/BufferLogger/BufferLoggerFile.cpp index 048e6a3ad5..ea0b7c0430 100644 --- a/Svc/BufferLogger/BufferLoggerFile.cpp +++ b/Svc/BufferLogger/BufferLoggerFile.cpp @@ -205,7 +205,7 @@ namespace Svc { FwSignedSizeType size = static_cast(length); const Os::File::Status fileStatus = this->m_osFile.write(reinterpret_cast(data), size); bool status; - if (fileStatus == Os::File::OP_OK && size == static_cast(length)) { + if (fileStatus == Os::File::OP_OK && static_cast(size) == length) { this->m_bytesWritten += length; status = true; } diff --git a/Svc/DpCatalog/test/ut/DpCatalogTester.cpp b/Svc/DpCatalog/test/ut/DpCatalogTester.cpp index f773837e10..68b76f4364 100644 --- a/Svc/DpCatalog/test/ut/DpCatalogTester.cpp +++ b/Svc/DpCatalog/test/ut/DpCatalogTester.cpp @@ -54,7 +54,7 @@ namespace Svc { void DpCatalogTester::testTree( DpCatalog::DpStateEntry* input, DpCatalog::DpStateEntry* output, - FwSizeType numEntries) { + FwIndexType numEntries) { ASSERT_TRUE(input != nullptr); ASSERT_TRUE(output != nullptr); ASSERT_TRUE(numEntries > 0); diff --git a/Svc/DpCatalog/test/ut/DpCatalogTester.hpp b/Svc/DpCatalog/test/ut/DpCatalogTester.hpp index 164d202850..8e5ee31281 100644 --- a/Svc/DpCatalog/test/ut/DpCatalogTester.hpp +++ b/Svc/DpCatalog/test/ut/DpCatalogTester.hpp @@ -56,7 +56,7 @@ namespace Svc { void testTree( DpCatalog::DpStateEntry* list, DpCatalog::DpStateEntry* output, - FwSizeType numEntries); + FwIndexType numEntries); struct DpSet { FwDpIdType id; diff --git a/Svc/DpManager/test/ut/Rules/CLEAR_EVENT_THROTTLE.cpp b/Svc/DpManager/test/ut/Rules/CLEAR_EVENT_THROTTLE.cpp index e1da13717a..51ac91394b 100644 --- a/Svc/DpManager/test/ut/Rules/CLEAR_EVENT_THROTTLE.cpp +++ b/Svc/DpManager/test/ut/Rules/CLEAR_EVENT_THROTTLE.cpp @@ -27,7 +27,7 @@ void TestState::action__CLEAR_EVENT_THROTTLE__OK() { // Clear history this->clearHistory(); // Send the command - const FwOpcodeType instance = static_cast(STest::Pick::any()); + const FwEnumStoreType instance = static_cast(STest::Pick::any()); const U32 cmdSeq = STest::Pick::any(); this->sendCmd_CLEAR_EVENT_THROTTLE(instance, cmdSeq); this->component.doDispatch(); diff --git a/Svc/StaticMemory/StaticMemoryComponentImpl.cpp b/Svc/StaticMemory/StaticMemoryComponentImpl.cpp index 3e89447f37..a04aa94a32 100644 --- a/Svc/StaticMemory/StaticMemoryComponentImpl.cpp +++ b/Svc/StaticMemory/StaticMemoryComponentImpl.cpp @@ -15,8 +15,8 @@ #include "Fw/Types/Assert.hpp" namespace Svc { -static_assert((NUM_BUFFERALLOCATE_INPUT_PORTS >= 0) && - (NUM_BUFFERALLOCATE_INPUT_PORTS <= std::numeric_limits::max()), +static_assert((StaticMemoryComponentBase::NUM_BUFFERALLOCATE_INPUT_PORTS >= 0) && + (StaticMemoryComponentBase::NUM_BUFFERALLOCATE_INPUT_PORTS <= std::numeric_limits::max()), "NUM_BUFFERALLOCATE_INPUT_PORTS must fit in the positive range of FwIndexType"); // ---------------------------------------------------------------------- // Construction, initialization, and destruction @@ -24,7 +24,7 @@ static_assert((NUM_BUFFERALLOCATE_INPUT_PORTS >= 0) && StaticMemoryComponentImpl ::StaticMemoryComponentImpl(const char* const compName) : StaticMemoryComponentBase(compName) { - for (FwIndexType i = 0; i < FW_NUM_ARRAY_ELEMENTS(m_allocated); i++) { + for (FwIndexType i = 0; i < static_cast(FW_NUM_ARRAY_ELEMENTS(m_allocated)); i++) { m_allocated[i] = false; } } From 063bfc46fe40cdd080a6e598ef6f247e95e140e3 Mon Sep 17 00:00:00 2001 From: M Starch Date: Thu, 13 Mar 2025 10:44:46 -0700 Subject: [PATCH 25/34] POINTER_CAST from Svc --- Svc/BufferManager/BufferManagerComponentImpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Svc/BufferManager/BufferManagerComponentImpl.cpp b/Svc/BufferManager/BufferManagerComponentImpl.cpp index 7be32b5758..c51f425d1c 100644 --- a/Svc/BufferManager/BufferManagerComponentImpl.cpp +++ b/Svc/BufferManager/BufferManagerComponentImpl.cpp @@ -230,8 +230,8 @@ namespace Svc { FW_ASSERT(CURR_PTR == END_PTR, static_cast(mgrId), static_cast(memId), - static_cast(reinterpret_cast(CURR_PTR)), - static_cast(reinterpret_cast(END_PTR))); + static_cast(reinterpret_cast(CURR_PTR)), + static_cast(reinterpret_cast(END_PTR))); // secondary init verification FW_ASSERT( currStruct == this->m_numStructs, From b5f171e61f64f9b2dfc3aa6b3d7ec2de38312504 Mon Sep 17 00:00:00 2001 From: M Starch Date: Thu, 13 Mar 2025 10:58:23 -0700 Subject: [PATCH 26/34] CI fixes --- Svc/BufferManager/BufferManagerComponentImpl.cpp | 4 ++-- Svc/Health/HealthComponentImpl.cpp | 3 ++- Svc/StaticMemory/StaticMemoryComponentImpl.cpp | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Svc/BufferManager/BufferManagerComponentImpl.cpp b/Svc/BufferManager/BufferManagerComponentImpl.cpp index c51f425d1c..ffa6d0a456 100644 --- a/Svc/BufferManager/BufferManagerComponentImpl.cpp +++ b/Svc/BufferManager/BufferManagerComponentImpl.cpp @@ -230,8 +230,8 @@ namespace Svc { FW_ASSERT(CURR_PTR == END_PTR, static_cast(mgrId), static_cast(memId), - static_cast(reinterpret_cast(CURR_PTR)), - static_cast(reinterpret_cast(END_PTR))); + static_cast(reinterpret_cast(CURR_PTR)), + static_cast(reinterpret_cast(END_PTR))); // secondary init verification FW_ASSERT( currStruct == this->m_numStructs, diff --git a/Svc/Health/HealthComponentImpl.cpp b/Svc/Health/HealthComponentImpl.cpp index 0595e6f9a0..808648ce1c 100644 --- a/Svc/Health/HealthComponentImpl.cpp +++ b/Svc/Health/HealthComponentImpl.cpp @@ -15,7 +15,7 @@ #include namespace Svc { - static_assert((HealthComponentBase::NUM_PINGSEND_OUTPUT_PORTS >= 0) && (HealthComponentBase::NUM_PINGSEND_OUTPUT_PORTS <= std::numeric_limits::max()), "NUM_PINGSEND_OUTPUT_PORTS must fit in the positive range of FwIndexType"); + // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- @@ -28,6 +28,7 @@ namespace Svc { m_warnings(0), m_enabled(Fw::Enabled::ENABLED), queue_depth(0) { + static_assert((HealthComponentBase::NUM_PINGSEND_OUTPUT_PORTS >= 0) && (HealthComponentBase::NUM_PINGSEND_OUTPUT_PORTS <= std::numeric_limits::max()), "NUM_PINGSEND_OUTPUT_PORTS must fit in the positive range of FwIndexType"); // clear tracker by disabling pings for (FwIndexType entry = 0; entry < static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_pingTrackerEntries)); diff --git a/Svc/StaticMemory/StaticMemoryComponentImpl.cpp b/Svc/StaticMemory/StaticMemoryComponentImpl.cpp index a04aa94a32..ac3921b60f 100644 --- a/Svc/StaticMemory/StaticMemoryComponentImpl.cpp +++ b/Svc/StaticMemory/StaticMemoryComponentImpl.cpp @@ -15,15 +15,16 @@ #include "Fw/Types/Assert.hpp" namespace Svc { -static_assert((StaticMemoryComponentBase::NUM_BUFFERALLOCATE_INPUT_PORTS >= 0) && - (StaticMemoryComponentBase::NUM_BUFFERALLOCATE_INPUT_PORTS <= std::numeric_limits::max()), - "NUM_BUFFERALLOCATE_INPUT_PORTS must fit in the positive range of FwIndexType"); + // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- StaticMemoryComponentImpl ::StaticMemoryComponentImpl(const char* const compName) : StaticMemoryComponentBase(compName) { + static_assert((StaticMemoryComponentBase::NUM_BUFFERALLOCATE_INPUT_PORTS >= 0) && + (StaticMemoryComponentBase::NUM_BUFFERALLOCATE_INPUT_PORTS <= std::numeric_limits::max()), + "NUM_BUFFERALLOCATE_INPUT_PORTS must fit in the positive range of FwIndexType"); for (FwIndexType i = 0; i < static_cast(FW_NUM_ARRAY_ELEMENTS(m_allocated)); i++) { m_allocated[i] = false; } From 6d742c431fa4d5f5da06ad73faed6ba6479f6a3a Mon Sep 17 00:00:00 2001 From: Michael D Starch Date: Thu, 13 Mar 2025 11:57:00 -0700 Subject: [PATCH 27/34] CI fixes (Linux) --- Svc/BufferAccumulator/test/ut/BufferAccumulatorTester.cpp | 4 ++-- Svc/BufferManager/BufferManagerComponentImpl.cpp | 2 +- Svc/FprimeDeframer/test/ut/FprimeDeframerTester.cpp | 2 +- .../test/ut/detectors/FprimeFrameDetectorTestMain.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Svc/BufferAccumulator/test/ut/BufferAccumulatorTester.cpp b/Svc/BufferAccumulator/test/ut/BufferAccumulatorTester.cpp index ab9a807bbc..8850e4d669 100644 --- a/Svc/BufferAccumulator/test/ut/BufferAccumulatorTester.cpp +++ b/Svc/BufferAccumulator/test/ut/BufferAccumulatorTester.cpp @@ -26,7 +26,7 @@ namespace Svc { // Construction and destruction // ---------------------------------------------------------------------- -BufferAccumulatorTester ::BufferAccumulatorTester(bool doAllocateQueue) +BufferAccumulatorTester ::BufferAccumulatorTester(bool a_doAllocateQueue) : #if FW_OBJECT_NAMES == 1 BufferAccumulatorGTestBase("Tester", MAX_HISTORY_SIZE), @@ -35,7 +35,7 @@ BufferAccumulatorTester ::BufferAccumulatorTester(bool doAllocateQueue) BufferAccumulatorGTestBase(MAX_HISTORY_SIZE), component(), #endif - doAllocateQueue(doAllocateQueue) { + doAllocateQueue(a_doAllocateQueue) { this->initComponents(); this->connectPorts(); diff --git a/Svc/BufferManager/BufferManagerComponentImpl.cpp b/Svc/BufferManager/BufferManagerComponentImpl.cpp index ffa6d0a456..9f35a87e8f 100644 --- a/Svc/BufferManager/BufferManagerComponentImpl.cpp +++ b/Svc/BufferManager/BufferManagerComponentImpl.cpp @@ -184,7 +184,7 @@ namespace Svc { (static_cast(sizeof(AllocatedBuffer)) * this->m_bufferBins.bins[bin].numBuffers); // allocate the structs to track the buffers // Total structures is bounded by U16 maximum value to fit in half of context (U32) FW_ASSERT((std::numeric_limits::max() - this->m_numStructs) >= this->m_bufferBins.bins[bin].numBuffers); - this->m_numStructs += this->m_bufferBins.bins[bin].numBuffers; + this->m_numStructs = static_cast(this->m_numStructs + this->m_bufferBins.bins[bin].numBuffers); } } diff --git a/Svc/FprimeDeframer/test/ut/FprimeDeframerTester.cpp b/Svc/FprimeDeframer/test/ut/FprimeDeframerTester.cpp index 8a5ee0a39a..e48c5916a0 100644 --- a/Svc/FprimeDeframer/test/ut/FprimeDeframerTester.cpp +++ b/Svc/FprimeDeframer/test/ut/FprimeDeframerTester.cpp @@ -117,7 +117,7 @@ void FprimeDeframerTester::injectChecksum(U8* data, FwSizeType size) { crc_calculator.final(crc_result); // Inject the checksum into the data for (FwSizeType i = 0; i < 4; i++) { - data[size - 4 + i] = (crc_result.asBigEndianU32() >> (8 * (3 - i)) & 0xFF); + data[size - 4 + i] = static_cast(crc_result.asBigEndianU32() >> (8 * (3 - i)) & 0xFF); } } diff --git a/Svc/FrameAccumulator/test/ut/detectors/FprimeFrameDetectorTestMain.cpp b/Svc/FrameAccumulator/test/ut/detectors/FprimeFrameDetectorTestMain.cpp index c1fb9eca5f..984bee4c92 100644 --- a/Svc/FrameAccumulator/test/ut/detectors/FprimeFrameDetectorTestMain.cpp +++ b/Svc/FrameAccumulator/test/ut/detectors/FprimeFrameDetectorTestMain.cpp @@ -55,7 +55,7 @@ FwSizeType generate_random_fprime_frame(Types::CircularBuffer& circular_buffer) for (FwIndexType i = 0; i < static_cast(FRAME_FOOTER_SIZE); i++) { // crc is a U32; unpack into 4 bytes (shift by 24->-16->8->0 bits, mask with 0xFF) fprime_frame[i + FRAME_HEADER_SIZE + static_cast(packet_size)] = - (crc_result.asBigEndianU32() >> (8 * (3 - i))) & 0xFF; + static_cast((crc_result.asBigEndianU32() >> (8 * (3 - i))) & 0xFF); } // Serialize frame into circular buffer circular_buffer.serialize(fprime_frame, fprime_frame_size); From 71ee45b84f51e36817b2524aa3e2306f563da875 Mon Sep 17 00:00:00 2001 From: Michael D Starch Date: Thu, 13 Mar 2025 12:26:45 -0700 Subject: [PATCH 28/34] Fixing Ref/RPI for RG context --- RPI/RpiDemo/RpiDemoComponentImpl.cpp | 8 ++++---- RPI/Top/instances.fpp | 4 ++-- Ref/SendBuffApp/SendBuffComponentImpl.cpp | 4 ++-- Ref/Top/RefTopology.cpp | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/RPI/RpiDemo/RpiDemoComponentImpl.cpp b/RPI/RpiDemo/RpiDemoComponentImpl.cpp index cc21e7995c..06d884f0d6 100644 --- a/RPI/RpiDemo/RpiDemoComponentImpl.cpp +++ b/RPI/RpiDemo/RpiDemoComponentImpl.cpp @@ -114,7 +114,7 @@ namespace RPI { char uMsg[serBuffer.getSize() + 1]; char *bPtr = reinterpret_cast(serBuffer.getData()); - for (NATIVE_UINT_TYPE byte = 0; byte < serBuffer.getSize(); byte++) { + for (FwSizeType byte = 0; byte < serBuffer.getSize(); byte++) { uMsg[byte] = isalpha(bPtr[byte]) ? bPtr[byte] : '*'; } uMsg[sizeof(uMsg) - 1] = 0; @@ -160,7 +160,7 @@ namespace RPI { Fw::Logic value ) { - NATIVE_INT_TYPE port; + FwIndexType port; // convert to connected ports switch (output.e) { case RpiDemo_GpioOutNum::PIN_23: @@ -191,7 +191,7 @@ namespace RPI { RpiDemo_GpioInNum input /*!< Input GPIO*/ ) { - NATIVE_INT_TYPE port; + FwIndexType port; // convert to connected ports switch (input.e) { case RpiDemo_GpioInNum::PIN_25: @@ -229,7 +229,7 @@ namespace RPI { out.setData(reinterpret_cast(const_cast(data.toChar()))); out.setSize(data.length()); this->SpiReadWrite_out(0, out, in); - for (NATIVE_UINT_TYPE byte = 0; byte < sizeof(inBuf); byte++) { + for (FwSizeType byte = 0; byte < sizeof(inBuf); byte++) { inBuf[byte] = isalpha(inBuf[byte])?inBuf[byte]:'*'; } inBuf[sizeof(inBuf)-1] = 0; diff --git a/RPI/Top/instances.fpp b/RPI/Top/instances.fpp index b2e986e8ac..c1eb6de51b 100644 --- a/RPI/Top/instances.fpp +++ b/RPI/Top/instances.fpp @@ -23,7 +23,7 @@ module RPI { { phase Fpp.ToCpp.Phases.configObjects """ - NATIVE_INT_TYPE context[] = { RpiDemo::RG_CONTEXT_10Hz, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + U32 context[] = { RpiDemo::RG_CONTEXT_10Hz, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; """ phase Fpp.ToCpp.Phases.configComponents """ @@ -100,7 +100,7 @@ module RPI { { phase Fpp.ToCpp.Phases.configObjects """ - NATIVE_INT_TYPE context[] = { 0, 0, RpiDemo::RG_CONTEXT_1Hz, 0, 0, 0, 0, 0, 0, 0 }; + U32 context[] = { 0, 0, RpiDemo::RG_CONTEXT_1Hz, 0, 0, 0, 0, 0, 0, 0 }; """ phase Fpp.ToCpp.Phases.configComponents """ diff --git a/Ref/SendBuffApp/SendBuffComponentImpl.cpp b/Ref/SendBuffApp/SendBuffComponentImpl.cpp index 9be2738d6b..5aea61cc07 100644 --- a/Ref/SendBuffApp/SendBuffComponentImpl.cpp +++ b/Ref/SendBuffApp/SendBuffComponentImpl.cpp @@ -57,8 +57,8 @@ namespace Ref { this->tlmWrite_PacketsSent(this->m_buffsSent); // write data U8 testData[24]; - NATIVE_UINT_TYPE dataSize = sizeof(testData); - memset(testData,0xFF,dataSize); + FwSizeType dataSize = sizeof(testData); + memset(testData,0xFF,static_cast(dataSize)); // compute checksum U32 csum = 0; for (U32 byte = 0; byte < dataSize; byte++) { diff --git a/Ref/Top/RefTopology.cpp b/Ref/Top/RefTopology.cpp index 0b66660cd3..e7b77fd2c7 100644 --- a/Ref/Top/RefTopology.cpp +++ b/Ref/Top/RefTopology.cpp @@ -43,9 +43,9 @@ Svc::RateGroupDriver::DividerSet rateGroupDivisorsSet{{{1, 0}, {2, 0}, {4, 0}}}; // Rate groups may supply a context token to each of the attached children whose purpose is set by the project. The // reference topology sets each token to zero as these contexts are unused in this project. -NATIVE_INT_TYPE rateGroup1Context[Svc::ActiveRateGroup::CONNECTION_COUNT_MAX] = {}; -NATIVE_INT_TYPE rateGroup2Context[Svc::ActiveRateGroup::CONNECTION_COUNT_MAX] = {}; -NATIVE_INT_TYPE rateGroup3Context[Svc::ActiveRateGroup::CONNECTION_COUNT_MAX] = {}; +U32 rateGroup1Context[Svc::ActiveRateGroup::CONNECTION_COUNT_MAX] = {}; +U32 rateGroup2Context[Svc::ActiveRateGroup::CONNECTION_COUNT_MAX] = {}; +U32 rateGroup3Context[Svc::ActiveRateGroup::CONNECTION_COUNT_MAX] = {}; // A number of constants are needed for construction of the topology. These are specified here. enum TopologyConstants { From 3c2e08f2e74540869099142025472175dd60e4ad Mon Sep 17 00:00:00 2001 From: Michael D Starch Date: Thu, 13 Mar 2025 12:30:06 -0700 Subject: [PATCH 29/34] CI (sp) --- Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp b/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp index 34e23c365a..360e98fc64 100644 --- a/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp +++ b/Svc/CmdDispatcher/test/ut/CommandDispatcherImplTester.cpp @@ -15,7 +15,7 @@ #include #include -static_assert(CMD_DISPATCHER_SEQUENCER_TABLE_SIZE + 1 <= std::numeric_limits::max(), "Unit test depends on CMD_DISPATCHER_SEQUENCER_TABLE_SIZE + 1 fiting int U32"); +static_assert(CMD_DISPATCHER_SEQUENCER_TABLE_SIZE + 1 <= std::numeric_limits::max(), "Unit test depends on CMD_DISPATCHER_SEQUENCER_TABLE_SIZE + 1 within range of U32"); namespace Svc { CommandDispatcherImplTester::CommandDispatcherImplTester(Svc::CommandDispatcherImpl& inst) : From eead0a528591f040238295cf2e3da415efd60267 Mon Sep 17 00:00:00 2001 From: Michael D Starch Date: Thu, 13 Mar 2025 12:48:12 -0700 Subject: [PATCH 30/34] Fixing RPI build for time conversions --- Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp b/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp index 2d027d0066..183a489618 100644 --- a/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp +++ b/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp @@ -27,10 +27,10 @@ namespace Svc { /* Create the timer */ fd = timerfd_create (CLOCK_MONOTONIC, 0); - itval.it_interval.tv_sec = interval/1000; - itval.it_interval.tv_nsec = (interval*1000000)%1000000000; - itval.it_value.tv_sec = interval/1000; - itval.it_value.tv_nsec = (interval*1000000)%1000000000; + itval.it_interval.tv_sec = static_cast(interval/1000); + itval.it_interval.tv_nsec = static_cast((interval*1000000)%1000000000); + itval.it_value.tv_sec = static_cast(interval/1000); + itval.it_value.tv_nsec = static_cast((interval*1000000)%1000000000); timerfd_settime (fd, 0, &itval, nullptr); From 8adc219ea06bab2cba07681a87d3be46a18ac282 Mon Sep 17 00:00:00 2001 From: Michael D Starch Date: Thu, 13 Mar 2025 13:25:38 -0700 Subject: [PATCH 31/34] CI fixes (RPI) --- Svc/TlmPacketizer/TlmPacketizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Svc/TlmPacketizer/TlmPacketizer.cpp b/Svc/TlmPacketizer/TlmPacketizer.cpp index a950743421..9161db4e80 100644 --- a/Svc/TlmPacketizer/TlmPacketizer.cpp +++ b/Svc/TlmPacketizer/TlmPacketizer.cpp @@ -84,7 +84,7 @@ void TlmPacketizer::setPacketList(const TlmPacketizerPacketList& packetList, } // end channel in packet FW_ASSERT(packetLen <= FW_COM_BUFFER_MAX_SIZE, static_cast(packetLen), static_cast(pktEntry)); // clear contents - memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(), 0, packetLen); + memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(), 0, static_cast(packetLen)); // serialize packet descriptor and packet ID now since it will always be the same Fw::SerializeStatus stat = this->m_fillBuffers[pktEntry].buffer.serialize( static_cast(Fw::ComPacket::FW_PACKET_PACKETIZED_TLM)); From 33a3774df14c450ef73d09795fdcdccea6b70ab3 Mon Sep 17 00:00:00 2001 From: M Starch Date: Thu, 13 Mar 2025 13:42:17 -0700 Subject: [PATCH 32/34] Self review comments --- RPI/RpiDemo/RpiDemoComponentImpl.cpp | 2 +- Ref/SendBuffApp/SendBuffComponentImpl.cpp | 2 +- Svc/ComLogger/ComLogger.cpp | 3 ++- Svc/ComQueue/ComQueue.cpp | 5 ++++- Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp | 8 +++++--- Svc/TlmPacketizer/TlmPacketizer.hpp | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/RPI/RpiDemo/RpiDemoComponentImpl.cpp b/RPI/RpiDemo/RpiDemoComponentImpl.cpp index 06d884f0d6..3137c63277 100644 --- a/RPI/RpiDemo/RpiDemoComponentImpl.cpp +++ b/RPI/RpiDemo/RpiDemoComponentImpl.cpp @@ -229,7 +229,7 @@ namespace RPI { out.setData(reinterpret_cast(const_cast(data.toChar()))); out.setSize(data.length()); this->SpiReadWrite_out(0, out, in); - for (FwSizeType byte = 0; byte < sizeof(inBuf); byte++) { + for (FwSizeType byte = 0; byte < static_cast(sizeof(inBuf)); byte++) { inBuf[byte] = isalpha(inBuf[byte])?inBuf[byte]:'*'; } inBuf[sizeof(inBuf)-1] = 0; diff --git a/Ref/SendBuffApp/SendBuffComponentImpl.cpp b/Ref/SendBuffApp/SendBuffComponentImpl.cpp index 5aea61cc07..74d61523e3 100644 --- a/Ref/SendBuffApp/SendBuffComponentImpl.cpp +++ b/Ref/SendBuffApp/SendBuffComponentImpl.cpp @@ -57,7 +57,7 @@ namespace Ref { this->tlmWrite_PacketsSent(this->m_buffsSent); // write data U8 testData[24]; - FwSizeType dataSize = sizeof(testData); + FwSizeType dataSize = static_cast(sizeof(testData)); memset(testData,0xFF,static_cast(dataSize)); // compute checksum U32 csum = 0; diff --git a/Svc/ComLogger/ComLogger.cpp b/Svc/ComLogger/ComLogger.cpp index 6a1256b728..997d8740c7 100644 --- a/Svc/ComLogger/ComLogger.cpp +++ b/Svc/ComLogger/ComLogger.cpp @@ -12,7 +12,8 @@ #include namespace Svc { - + static_assert(std::numeric_limits::max() <= std::numeric_limits::max(), + "U16 must fit in the positive range of FwSignedSizeType"); // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- diff --git a/Svc/ComQueue/ComQueue.cpp b/Svc/ComQueue/ComQueue.cpp index 4fa409a208..b41c32d96f 100644 --- a/Svc/ComQueue/ComQueue.cpp +++ b/Svc/ComQueue/ComQueue.cpp @@ -83,7 +83,10 @@ void ComQueue::configure(QueueConfigurationTable queueConfig, // Message size is determined by the type of object being stored, which in turn is determined by the // index of the entry. Those lower than COM_PORT_COUNT are Fw::ComBuffers and those larger Fw::Buffer. entry.msgSize = (entryIndex < COM_PORT_COUNT) ? sizeof(Fw::ComBuffer) : sizeof(Fw::Buffer); - // Overflow check + // Overflow checks + FW_ASSERT((std::numeric_limits::max()/entry.depth) >= entry.msgSize, + static_cast(entry.depth), + static_cast(entry.msgSize)); FW_ASSERT(std::numeric_limits::max() - (entry.depth * entry.msgSize) >= totalAllocation); totalAllocation += entry.depth * entry.msgSize; currentPriorityIndex++; diff --git a/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp b/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp index 183a489618..06fdc7391e 100644 --- a/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp +++ b/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp @@ -26,10 +26,12 @@ namespace Svc { /* Create the timer */ fd = timerfd_create (CLOCK_MONOTONIC, 0); - - itval.it_interval.tv_sec = static_cast(interval/1000); + const FwSizeType interval_secs = interval/1000; + FW_ASSERT(static_cast(std::numeric_limits::max()) >= interval_secs, + static_cast(interval)); + itval.it_interval.tv_sec = static_cast(interval_secs); itval.it_interval.tv_nsec = static_cast((interval*1000000)%1000000000); - itval.it_value.tv_sec = static_cast(interval/1000); + itval.it_value.tv_sec = static_cast(interval_secs); itval.it_value.tv_nsec = static_cast((interval*1000000)%1000000000); timerfd_settime (fd, 0, &itval, nullptr); diff --git a/Svc/TlmPacketizer/TlmPacketizer.hpp b/Svc/TlmPacketizer/TlmPacketizer.hpp index fc547617c1..78b24ac959 100644 --- a/Svc/TlmPacketizer/TlmPacketizer.hpp +++ b/Svc/TlmPacketizer/TlmPacketizer.hpp @@ -100,7 +100,7 @@ class TlmPacketizer final : public TlmPacketizerComponentBase { FwChanIdType id; //!< telemetry id stored in slot // Offsets into packet buffers. // -1 means that channel is not in that packet - FwSignedSizeType packetOffset[MAX_PACKETIZER_PACKETS]; //TODO: what to do here? + FwSignedSizeType packetOffset[MAX_PACKETIZER_PACKETS]; TlmEntry* next; //!< pointer to next bucket in table bool used; //!< if entry has been used bool ignored; //!< ignored packet id From 5a55178325d7a3189c8ed0d0b139808a95333478 Mon Sep 17 00:00:00 2001 From: M Starch Date: Thu, 13 Mar 2025 14:23:54 -0700 Subject: [PATCH 33/34] Removing UDP sender/receiver config --- config/UdpReceiverComponentImplCfg.hpp | 17 ----------------- config/UdpSenderComponentImplCfg.hpp | 17 ----------------- 2 files changed, 34 deletions(-) delete mode 100644 config/UdpReceiverComponentImplCfg.hpp delete mode 100644 config/UdpSenderComponentImplCfg.hpp diff --git a/config/UdpReceiverComponentImplCfg.hpp b/config/UdpReceiverComponentImplCfg.hpp deleted file mode 100644 index 4b69dd24eb..0000000000 --- a/config/UdpReceiverComponentImplCfg.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * UdpReceiverComponentImplCfg.hpp - * - * Created on: Nov 11, 2017 - * Author: tim - */ - -#ifndef SVC_UDPRECEIVER_UDPRECEIVERCOMPONENTIMPLCFG_HPP_ -#define SVC_UDPRECEIVER_UDPRECEIVERCOMPONENTIMPLCFG_HPP_ - -#include - -namespace Svc { - static const NATIVE_UINT_TYPE UDP_RECEIVER_MSG_SIZE = 256; -} - -#endif /* SVC_UDPRECEIVER_UDPRECEIVERCOMPONENTIMPLCFG_HPP_ */ diff --git a/config/UdpSenderComponentImplCfg.hpp b/config/UdpSenderComponentImplCfg.hpp deleted file mode 100644 index 3ed3660e06..0000000000 --- a/config/UdpSenderComponentImplCfg.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * UdpSenderComponentImplCfg.hpp - * - * Created on: Nov 11, 2017 - * Author: tim - */ - -#ifndef SVC_UDPSENDER_UDPSENDERCOMPONENTIMPLCFG_HPP_ -#define SVC_UDPSENDER_UDPSENDERCOMPONENTIMPLCFG_HPP_ - -#include - -namespace Svc { - static const NATIVE_UINT_TYPE UDP_SENDER_MSG_SIZE = 256; -} - -#endif /* SVC_UDPSENDER_UDPSENDERCOMPONENTIMPLCFG_HPP_ */ From 0befbc967375e7c31197cc3a8f445e563c234403 Mon Sep 17 00:00:00 2001 From: M Starch Date: Fri, 14 Mar 2025 17:05:02 -0700 Subject: [PATCH 34/34] Review recommendations - pt 1 --- Svc/TlmPacketizer/TlmPacketizer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Svc/TlmPacketizer/TlmPacketizer.cpp b/Svc/TlmPacketizer/TlmPacketizer.cpp index 9161db4e80..3f1acc09e0 100644 --- a/Svc/TlmPacketizer/TlmPacketizer.cpp +++ b/Svc/TlmPacketizer/TlmPacketizer.cpp @@ -59,7 +59,6 @@ void TlmPacketizer::setPacketList(const TlmPacketizerPacketList& packetList, // table for (FwChanIdType pktEntry = 0; pktEntry < packetList.numEntries; pktEntry++) { // Initial size is packetized telemetry descriptor + size of time tag + sizeof packet ID - //TODO: do I add a check here FwSizeType packetLen = sizeof(FwPacketDescriptorType) + Fw::Time::SERIALIZED_SIZE + sizeof(FwTlmPacketizeIdType); FW_ASSERT(packetList.list[pktEntry]->list, static_cast(pktEntry));