diff --git a/Drv/Ports/DataTypes/DataBuffer.cpp b/Drv/Ports/DataTypes/DataBuffer.cpp index 49a41a0869..fb0f0ead70 100644 --- a/Drv/Ports/DataTypes/DataBuffer.cpp +++ b/Drv/Ports/DataTypes/DataBuffer.cpp @@ -13,7 +13,7 @@ DataBuffer::DataBuffer() {} DataBuffer::~DataBuffer() {} DataBuffer::DataBuffer(const DataBuffer& other) : Fw::SerializeBufferBase() { - Fw::SerializeStatus stat = Fw::SerializeBufferBase::setBuff(other.m_data, other.getBuffLength()); + Fw::SerializeStatus stat = Fw::SerializeBufferBase::setBuff(other.m_data, other.getSize()); FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast(stat)); } @@ -22,15 +22,19 @@ DataBuffer& DataBuffer::operator=(const DataBuffer& other) { return *this; } - Fw::SerializeStatus stat = Fw::SerializeBufferBase::setBuff(other.m_data, other.getBuffLength()); + Fw::SerializeStatus stat = Fw::SerializeBufferBase::setBuff(other.m_data, other.getSize()); FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast(stat)); return *this; } -FwSizeType DataBuffer::getBuffCapacity() const { +FwSizeType DataBuffer::getCapacity() const { return sizeof(this->m_data); } +FwSizeType DataBuffer::getBuffCapacity() const { + return this->getCapacity(); +} + const U8* DataBuffer::getBuffAddr() const { return this->m_data; } diff --git a/Drv/Ports/DataTypes/DataBuffer.hpp b/Drv/Ports/DataTypes/DataBuffer.hpp index 76456a2d28..46d01a60c7 100644 --- a/Drv/Ports/DataTypes/DataBuffer.hpp +++ b/Drv/Ports/DataTypes/DataBuffer.hpp @@ -20,7 +20,9 @@ class DataBuffer : public Fw::SerializeBufferBase { virtual ~DataBuffer(); DataBuffer& operator=(const DataBuffer& other); - FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer + DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead"); + FwSizeType getCapacity() const; + U8* getBuffAddr(); const U8* getBuffAddr() const; diff --git a/FppTestProject/FppTest/component/active/ActiveTest.cpp b/FppTestProject/FppTest/component/active/ActiveTest.cpp index f616b46f13..65794a585e 100644 --- a/FppTestProject/FppTest/component/active/ActiveTest.cpp +++ b/FppTestProject/FppTest/component/active/ActiveTest.cpp @@ -25,38 +25,38 @@ ActiveTest ::~ActiveTest() {} // Handler implementations for user-defined serial input ports // ---------------------------------------------------------------------- -void ActiveTest ::serialAsync_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& Buffer //!< The serialization buffer +void ActiveTest ::serialAsync_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& Buffer //!< The serialization buffer ) { this->serializeStatus = this->serialOut_out(portNum, Buffer); } -void ActiveTest ::serialAsyncAssert_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& Buffer //!< The serialization buffer +void ActiveTest ::serialAsyncAssert_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& Buffer //!< The serialization buffer ) { this->serializeStatus = this->serialOut_out(SerialPortIndex::ENUM, Buffer); } -void ActiveTest ::serialAsyncBlockPriority_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& Buffer //!< The serialization buffer +void ActiveTest ::serialAsyncBlockPriority_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& Buffer //!< The serialization buffer ) { this->serializeStatus = this->serialOut_out(SerialPortIndex::ARRAY, Buffer); } -void ActiveTest ::serialAsyncDropPriority_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& Buffer //!< The serialization buffer +void ActiveTest ::serialAsyncDropPriority_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& Buffer //!< The serialization buffer ) { this->serializeStatus = this->serialOut_out(SerialPortIndex::STRUCT, Buffer); } -void ActiveTest ::serialGuarded_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& Buffer //!< The serialization buffer +void ActiveTest ::serialGuarded_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& Buffer //!< The serialization buffer ) { this->serializeStatus = this->serialOut_out(portNum, Buffer); } -void ActiveTest ::serialSync_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& Buffer //!< The serialization buffer +void ActiveTest ::serialSync_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& Buffer //!< The serialization buffer ) { this->serializeStatus = this->serialOut_out(portNum, Buffer); } diff --git a/FppTestProject/FppTest/component/active/ActiveTest.hpp b/FppTestProject/FppTest/component/active/ActiveTest.hpp index 0b7f9a4fe6..9966351f51 100644 --- a/FppTestProject/FppTest/component/active/ActiveTest.hpp +++ b/FppTestProject/FppTest/component/active/ActiveTest.hpp @@ -34,33 +34,33 @@ class ActiveTest : public ActiveTestComponentBase { // ---------------------------------------------------------------------- //! Handler implementation for serialAsync - void serialAsync_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& buffer //!< The serialization buffer + void serialAsync_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& buffer //!< The serialization buffer ) override; //! Handler implementation for serialAsyncAssert - void serialAsyncAssert_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& buffer //!< The serialization buffer + void serialAsyncAssert_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& buffer //!< The serialization buffer ) override; //! Handler implementation for serialAsyncBlockPriority - void serialAsyncBlockPriority_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& buffer //!< The serialization buffer + void serialAsyncBlockPriority_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& buffer //!< The serialization buffer ) override; //! Handler implementation for serialAsyncDropPriority - void serialAsyncDropPriority_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& buffer //!< The serialization buffer + void serialAsyncDropPriority_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& buffer //!< The serialization buffer ) override; //! Handler implementation for serialGuarded - void serialGuarded_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& buffer //!< The serialization buffer + void serialGuarded_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& buffer //!< The serialization buffer ) override; //! Handler implementation for serialSync - void serialSync_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& buffer //!< The serialization buffer + void serialSync_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& buffer //!< The serialization buffer ) override; private: diff --git a/FppTestProject/FppTest/component/active/test/ut/ActiveTestTester.cpp b/FppTestProject/FppTest/component/active/test/ut/ActiveTestTester.cpp index 91dec9f9dc..6f4fdaced2 100644 --- a/FppTestProject/FppTest/component/active/test/ut/ActiveTestTester.cpp +++ b/FppTestProject/FppTest/component/active/test/ut/ActiveTestTester.cpp @@ -130,7 +130,7 @@ Fw::SerializeStatus ActiveTestTester::ActiveTestComponentBaseParamExternalDelega const FwPrmIdType base_id, const FwPrmIdType local_id, const Fw::ParamValid prmStat, - Fw::SerializeBufferBase& buff) { + Fw::SerialBufferBase& buff) { Fw::SerializeStatus stat; (void)base_id; @@ -171,7 +171,7 @@ Fw::SerializeStatus ActiveTestTester::ActiveTestComponentBaseParamExternalDelega Fw::SerializeStatus ActiveTestTester::ActiveTestComponentBaseParamExternalDelegate ::serializeParam( const FwPrmIdType base_id, const FwPrmIdType local_id, - Fw::SerializeBufferBase& buff) const { + Fw::SerialBufferBase& buff) const { Fw::SerializeStatus stat; (void)base_id; diff --git a/FppTestProject/FppTest/component/active/test/ut/ActiveTestTester.hpp b/FppTestProject/FppTest/component/active/test/ut/ActiveTestTester.hpp index 869479e721..3c51928775 100644 --- a/FppTestProject/FppTest/component/active/test/ut/ActiveTestTester.hpp +++ b/FppTestProject/FppTest/component/active/test/ut/ActiveTestTester.hpp @@ -226,14 +226,13 @@ class ActiveTestTester : public ActiveTestGTestBase { const FwPrmIdType base_id, //!< The component base parameter ID to deserialize const FwPrmIdType local_id, //!< The parameter local ID to deserialize const Fw::ParamValid prmStat, //!< The parameter validity status - Fw::SerializeBufferBase& buff //!< The buffer containing the parameter to deserialize + Fw::SerialBufferBase& buff //!< The buffer containing the parameter to deserialize ) override; //! Parameter serialization function for external parameter unit testing - Fw::SerializeStatus serializeParam( - const FwPrmIdType base_id, //!< The component base parameter ID to serialize - const FwPrmIdType local_id, //!< The parameter local ID to serialize - Fw::SerializeBufferBase& buff //!< The buffer to serialize the parameter into + Fw::SerializeStatus serializeParam(const FwPrmIdType base_id, //!< The component base parameter ID to serialize + const FwPrmIdType local_id, //!< The parameter local ID to serialize + Fw::SerialBufferBase& buff //!< The buffer to serialize the parameter into ) const override; }; diff --git a/FppTestProject/FppTest/component/passive/test/ut/PassiveTestTester.cpp b/FppTestProject/FppTest/component/passive/test/ut/PassiveTestTester.cpp index 5e0fe26593..561d5ca624 100644 --- a/FppTestProject/FppTest/component/passive/test/ut/PassiveTestTester.cpp +++ b/FppTestProject/FppTest/component/passive/test/ut/PassiveTestTester.cpp @@ -129,7 +129,7 @@ Fw::SerializeStatus PassiveTestTester::PassiveTestComponentBaseParamExternalDele const FwPrmIdType base_id, const FwPrmIdType local_id, const Fw::ParamValid prmStat, - Fw::SerializeBufferBase& buff) { + Fw::SerialBufferBase& buff) { Fw::SerializeStatus stat; (void)base_id; @@ -170,7 +170,7 @@ Fw::SerializeStatus PassiveTestTester::PassiveTestComponentBaseParamExternalDele Fw::SerializeStatus PassiveTestTester::PassiveTestComponentBaseParamExternalDelegate ::serializeParam( const FwPrmIdType base_id, const FwPrmIdType local_id, - Fw::SerializeBufferBase& buff) const { + Fw::SerialBufferBase& buff) const { Fw::SerializeStatus stat; (void)base_id; diff --git a/FppTestProject/FppTest/component/passive/test/ut/PassiveTestTester.hpp b/FppTestProject/FppTest/component/passive/test/ut/PassiveTestTester.hpp index 861301d9ac..ee5962757e 100644 --- a/FppTestProject/FppTest/component/passive/test/ut/PassiveTestTester.hpp +++ b/FppTestProject/FppTest/component/passive/test/ut/PassiveTestTester.hpp @@ -210,14 +210,13 @@ class PassiveTestTester : public PassiveTestGTestBase { const FwPrmIdType base_id, //!< The component base parameter ID to deserialize const FwPrmIdType local_id, //!< The parameter local ID to deserialize const Fw::ParamValid prmStat, //!< The parameter validity status - Fw::SerializeBufferBase& buff //!< The buffer containing the parameter to deserialize + Fw::SerialBufferBase& buff //!< The buffer containing the parameter to deserialize ) override; //! Parameter serialization function for external parameter unit testing - Fw::SerializeStatus serializeParam( - const FwPrmIdType base_id, //!< The component base parameter ID to serialize - const FwPrmIdType local_id, //!< The parameter local ID to serialize - Fw::SerializeBufferBase& buff //!< The buffer to serialize the parameter into + Fw::SerializeStatus serializeParam(const FwPrmIdType base_id, //!< The component base parameter ID to serialize + const FwPrmIdType local_id, //!< The parameter local ID to serialize + Fw::SerialBufferBase& buff //!< The buffer to serialize the parameter into ) const override; }; diff --git a/FppTestProject/FppTest/component/queued/test/ut/QueuedTestTester.cpp b/FppTestProject/FppTest/component/queued/test/ut/QueuedTestTester.cpp index 29b9480685..869370fdb1 100644 --- a/FppTestProject/FppTest/component/queued/test/ut/QueuedTestTester.cpp +++ b/FppTestProject/FppTest/component/queued/test/ut/QueuedTestTester.cpp @@ -130,7 +130,7 @@ Fw::SerializeStatus QueuedTestTester::QueuedTestComponentBaseParamExternalDelega const FwPrmIdType base_id, const FwPrmIdType local_id, const Fw::ParamValid prmStat, - Fw::SerializeBufferBase& buff) { + Fw::SerialBufferBase& buff) { Fw::SerializeStatus stat; (void)base_id; @@ -171,7 +171,7 @@ Fw::SerializeStatus QueuedTestTester::QueuedTestComponentBaseParamExternalDelega Fw::SerializeStatus QueuedTestTester::QueuedTestComponentBaseParamExternalDelegate ::serializeParam( const FwPrmIdType base_id, const FwPrmIdType local_id, - Fw::SerializeBufferBase& buff) const { + Fw::SerialBufferBase& buff) const { Fw::SerializeStatus stat; (void)base_id; diff --git a/FppTestProject/FppTest/component/queued/test/ut/QueuedTestTester.hpp b/FppTestProject/FppTest/component/queued/test/ut/QueuedTestTester.hpp index e831084243..6004859880 100644 --- a/FppTestProject/FppTest/component/queued/test/ut/QueuedTestTester.hpp +++ b/FppTestProject/FppTest/component/queued/test/ut/QueuedTestTester.hpp @@ -82,8 +82,8 @@ class QueuedTestTester : public QueuedTestGTestBase { //! Handler for from_serialOut //! - void from_serialOut_handler(FwIndexType portNum, //!< The port number - Fw::SerializeBufferBase& Buffer //!< The serialization buffer + void from_serialOut_handler(FwIndexType portNum, //!< The port number + Fw::LinearBufferBase& Buffer //!< The serialization buffer ); public: @@ -227,14 +227,13 @@ class QueuedTestTester : public QueuedTestGTestBase { const FwPrmIdType base_id, //!< The component base parameter ID to deserialize const FwPrmIdType local_id, //!< The parameter local ID to deserialize const Fw::ParamValid prmStat, //!< The parameter validity status - Fw::SerializeBufferBase& buff //!< The buffer containing the parameter to deserialize + Fw::SerialBufferBase& buff //!< The buffer containing the parameter to deserialize ) override; //! Parameter serialization function for external parameter unit testing - Fw::SerializeStatus serializeParam( - const FwPrmIdType base_id, //!< The component base parameter ID to serialize - const FwPrmIdType local_id, //!< The parameter local ID to serialize - Fw::SerializeBufferBase& buff //!< The buffer to serialize the parameter into + Fw::SerializeStatus serializeParam(const FwPrmIdType base_id, //!< The component base parameter ID to serialize + const FwPrmIdType local_id, //!< The parameter local ID to serialize + Fw::SerialBufferBase& buff //!< The buffer to serialize the parameter into ) const override; }; diff --git a/FppTestProject/FppTest/component/tests/TesterHandlers.cpp b/FppTestProject/FppTest/component/tests/TesterHandlers.cpp index 7eebff1dc0..769f87ef06 100644 --- a/FppTestProject/FppTest/component/tests/TesterHandlers.cpp +++ b/FppTestProject/FppTest/component/tests/TesterHandlers.cpp @@ -139,23 +139,23 @@ void Tester ::from_serialOut_handler(FwIndexType portNum, //!< The p break; case SerialPortIndex::PRIMITIVE: - status = Buffer.copyRaw(this->primitiveBuf, Buffer.getBuffCapacity()); + status = Buffer.copyRaw(this->primitiveBuf, Buffer.getDeserializeSizeLeft()); break; case SerialPortIndex::STRING: - status = Buffer.copyRaw(this->stringBuf, Buffer.getBuffCapacity()); + status = Buffer.copyRaw(this->stringBuf, Buffer.getDeserializeSizeLeft()); break; case SerialPortIndex::ENUM: - status = Buffer.copyRaw(this->enumBuf, Buffer.getBuffCapacity()); + status = Buffer.copyRaw(this->enumBuf, Buffer.getDeserializeSizeLeft()); break; case SerialPortIndex::ARRAY: - status = Buffer.copyRaw(this->arrayBuf, Buffer.getBuffCapacity()); + status = Buffer.copyRaw(this->arrayBuf, Buffer.getDeserializeSizeLeft()); break; case SerialPortIndex::STRUCT: - status = Buffer.copyRaw(this->structBuf, Buffer.getBuffCapacity()); + status = Buffer.copyRaw(this->structBuf, Buffer.getDeserializeSizeLeft()); break; } diff --git a/FppTestProject/FppTest/state_machine/internal/harness/TestAbsType.hpp b/FppTestProject/FppTest/state_machine/internal/harness/TestAbsType.hpp index 942c3eb811..4058396e3f 100644 --- a/FppTestProject/FppTest/state_machine/internal/harness/TestAbsType.hpp +++ b/FppTestProject/FppTest/state_machine/internal/harness/TestAbsType.hpp @@ -48,14 +48,14 @@ struct TestAbsType final : public Fw::Serializable { //! Serialize function //! \return Status - Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase& sbb, //!< The serialize buffer base + Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& sbb, //!< The serialize buffer base Fw::Endianness mode = Fw::Endianness::BIG) const final { return sbb.serializeFrom(this->m_data, mode); } //! Deserialize method //! \return status - Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase& sbb, //!< The serialize buffer base + Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& sbb, //!< The serialize buffer base Fw::Endianness mode = Fw::Endianness::BIG) final { return sbb.deserializeTo(this->m_data, mode); } diff --git a/FppTestProject/FppTest/state_machine/internal_instance/choice/ChoiceToChoiceTester.cpp b/FppTestProject/FppTest/state_machine/internal_instance/choice/ChoiceToChoiceTester.cpp index 608a3e7de6..0d2787a7b6 100644 --- a/FppTestProject/FppTest/state_machine/internal_instance/choice/ChoiceToChoiceTester.cpp +++ b/FppTestProject/FppTest/state_machine/internal_instance/choice/ChoiceToChoiceTester.cpp @@ -77,7 +77,7 @@ void ChoiceToChoiceTester ::smChoiceChoiceToChoice_stateMachineOverflowHook(SmId this->m_hookCalled = true; ASSERT_EQ(smId, SmId::smChoiceChoiceToChoice); ASSERT_EQ(static_cast(signal), SmChoice_ChoiceToChoice::Signal::s); - ASSERT_EQ(buffer.getBuffLeft(), 0); + ASSERT_EQ(buffer.getDeserializeSizeLeft(), 0); } // ---------------------------------------------------------------------- diff --git a/FppTestProject/FppTest/state_machine/internal_instance/initial/NestedTester.cpp b/FppTestProject/FppTest/state_machine/internal_instance/initial/NestedTester.cpp index 38e34d9ec1..3a288c94d5 100644 --- a/FppTestProject/FppTest/state_machine/internal_instance/initial/NestedTester.cpp +++ b/FppTestProject/FppTest/state_machine/internal_instance/initial/NestedTester.cpp @@ -43,7 +43,7 @@ void NestedTester::FppTest_SmInstanceInitial_Nested_Nested_action_a( void NestedTester ::smInitialNested_stateMachineOverflowHook(SmId smId, FwEnumStoreType signal, - Fw::SerializeBufferBase& buffer) { + Fw::SerialBufferBase& buffer) { // Nothing to do } diff --git a/FppTestProject/FppTest/state_machine/internal_instance/initial/NestedTester.hpp b/FppTestProject/FppTest/state_machine/internal_instance/initial/NestedTester.hpp index 15981443b1..139229b215 100644 --- a/FppTestProject/FppTest/state_machine/internal_instance/initial/NestedTester.hpp +++ b/FppTestProject/FppTest/state_machine/internal_instance/initial/NestedTester.hpp @@ -78,9 +78,9 @@ class NestedTester : public NestedComponentBase { // ---------------------------------------------------------------------- //! Overflow hook implementation for smInitialNested - void smInitialNested_stateMachineOverflowHook(SmId smId, //!< The state machine ID - FwEnumStoreType signal, //!< The signal - Fw::SerializeBufferBase& buffer //!< The message buffer + void smInitialNested_stateMachineOverflowHook(SmId smId, //!< The state machine ID + FwEnumStoreType signal, //!< The signal + Fw::SerialBufferBase& buffer //!< The message buffer ) override; public: diff --git a/FppTestProject/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsTypeTester.cpp b/FppTestProject/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsTypeTester.cpp index d0ab956ca7..98c09aeabe 100644 --- a/FppTestProject/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsTypeTester.cpp +++ b/FppTestProject/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsTypeTester.cpp @@ -53,17 +53,16 @@ bool BasicGuardTestAbsTypeTester::FppTest_SmState_BasicGuardTestAbsType_guard_g( // Overflow hook implementations for internal state machines // ---------------------------------------------------------------------- -void BasicGuardTestAbsTypeTester::smStateBasicGuardTestAbsType_stateMachineOverflowHook( - SmId smId, - FwEnumStoreType signal, - Fw::SerializeBufferBase& buffer) { +void BasicGuardTestAbsTypeTester::smStateBasicGuardTestAbsType_stateMachineOverflowHook(SmId smId, + FwEnumStoreType signal, + Fw::SerialBufferBase& buffer) { this->m_hookCalled = true; ASSERT_EQ(smId, SmId::smStateBasicGuardTestAbsType); ASSERT_EQ(static_cast(signal), SmState_BasicGuardTestAbsType::Signal::s); SmHarness::TestAbsType value; const auto status = buffer.deserializeTo(value); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); - ASSERT_EQ(buffer.getBuffLeft(), 0); + ASSERT_EQ(buffer.getDeserializeSizeLeft(), 0); ASSERT_EQ(value, this->m_value); } diff --git a/FppTestProject/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsTypeTester.hpp b/FppTestProject/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsTypeTester.hpp index c3a0d390fe..0616688815 100644 --- a/FppTestProject/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsTypeTester.hpp +++ b/FppTestProject/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsTypeTester.hpp @@ -83,9 +83,9 @@ class BasicGuardTestAbsTypeTester : public BasicGuardTestAbsTypeComponentBase { // ---------------------------------------------------------------------- //! Overflow hook implementation for smStateBasicGuardTestAbsType - void smStateBasicGuardTestAbsType_stateMachineOverflowHook(SmId smId, //!< The state machine ID - FwEnumStoreType signal, //!< The signal - Fw::SerializeBufferBase& buffer //!< The message buffer + void smStateBasicGuardTestAbsType_stateMachineOverflowHook(SmId smId, //!< The state machine ID + FwEnumStoreType signal, //!< The signal + Fw::SerialBufferBase& buffer //!< The message buffer ) override; public: diff --git a/FppTestProject/FppTest/struct/NonPrimitiveStructTest.cpp b/FppTestProject/FppTest/struct/NonPrimitiveStructTest.cpp index b6d4c3ffe6..76d5965faf 100644 --- a/FppTestProject/FppTest/struct/NonPrimitiveStructTest.cpp +++ b/FppTestProject/FppTest/struct/NonPrimitiveStructTest.cpp @@ -259,7 +259,7 @@ TEST_F(NonPrimitiveStructTest, Serialization) { status = buf.serializeFrom(s); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); - ASSERT_EQ(buf.getBuffLength(), serializedSize); + ASSERT_EQ(buf.getSize(), serializedSize); // Deserialize status = buf.deserializeTo(sCopy); diff --git a/FppTestProject/FppTest/struct/PrimitiveStructTest.cpp b/FppTestProject/FppTest/struct/PrimitiveStructTest.cpp index 4389f24e4b..95422b6bb1 100644 --- a/FppTestProject/FppTest/struct/PrimitiveStructTest.cpp +++ b/FppTestProject/FppTest/struct/PrimitiveStructTest.cpp @@ -171,7 +171,7 @@ TEST_F(PrimitiveStructTest, Serialization) { status = buf.serializeFrom(s); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); - ASSERT_EQ(buf.getBuffLength(), Primitive::SERIALIZED_SIZE); + ASSERT_EQ(buf.getSize(), Primitive::SERIALIZED_SIZE); // Deserialize status = buf.deserializeTo(sCopy); diff --git a/FppTestProject/FppTest/typed_tests/ArrayTest.hpp b/FppTestProject/FppTest/typed_tests/ArrayTest.hpp index e4f5ee9408..8c93d1150a 100644 --- a/FppTestProject/FppTest/typed_tests/ArrayTest.hpp +++ b/FppTestProject/FppTest/typed_tests/ArrayTest.hpp @@ -182,7 +182,7 @@ TYPED_TEST_P(ArrayTest, Serialization) { status = buf.serializeFrom(a); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); - ASSERT_EQ(buf.getBuffLength(), serializedSize); + ASSERT_EQ(buf.getSize(), serializedSize); // Deserialize status = buf.deserializeTo(aCopy); @@ -199,7 +199,7 @@ TYPED_TEST_P(ArrayTest, Serialization) { status = buf2.serializeFrom(a); ASSERT_NE(status, Fw::FW_SERIALIZE_OK); - ASSERT_NE(buf2.getBuffLength(), serializedSize); + ASSERT_NE(buf2.getSize(), serializedSize); // Deserialize status = buf2.deserializeTo(aCopy2); diff --git a/FppTestProject/FppTest/typed_tests/EnumTest.hpp b/FppTestProject/FppTest/typed_tests/EnumTest.hpp index 1ecfe61224..49e96c550d 100644 --- a/FppTestProject/FppTest/typed_tests/EnumTest.hpp +++ b/FppTestProject/FppTest/typed_tests/EnumTest.hpp @@ -168,12 +168,12 @@ TYPED_TEST_P(EnumTest, Serialization) { status = buf.serializeFrom(validEnum); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); - ASSERT_EQ(buf.getBuffLength(), sizeof(typename TypeParam::SerialType)); + ASSERT_EQ(buf.getSize(), sizeof(typename TypeParam::SerialType)); status = buf.serializeFrom(invalidEnum); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); - ASSERT_EQ(buf.getBuffLength(), sizeof(typename TypeParam::SerialType) * 2); + ASSERT_EQ(buf.getSize(), sizeof(typename TypeParam::SerialType) * 2); // Deserialize the enums status = buf.deserializeTo(validEnumCopy); diff --git a/Fw/Buffer/Buffer.cpp b/Fw/Buffer/Buffer.cpp index c507a40a03..4898b7c583 100644 --- a/Fw/Buffer/Buffer.cpp +++ b/Fw/Buffer/Buffer.cpp @@ -113,7 +113,7 @@ Fw::ExternalSerializeBufferWithMemberCopy Buffer::getDeserializer() { } } -Fw::SerializeStatus Buffer::serializeTo(Fw::SerializeBufferBase& buffer, Fw::Endianness mode) const { +Fw::SerializeStatus Buffer::serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode) const { Fw::SerializeStatus stat; #if FW_SERIALIZATION_TYPE_ID stat = buffer.serializeFrom(static_cast(Buffer::TYPE_ID)); @@ -136,7 +136,7 @@ Fw::SerializeStatus Buffer::serializeTo(Fw::SerializeBufferBase& buffer, Fw::End return stat; } -Fw::SerializeStatus Buffer::deserializeFrom(Fw::SerializeBufferBase& buffer, Fw::Endianness mode) { +Fw::SerializeStatus Buffer::deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode) { Fw::SerializeStatus stat; #if FW_SERIALIZATION_TYPE_ID diff --git a/Fw/Buffer/Buffer.hpp b/Fw/Buffer/Buffer.hpp index 54362e261b..55180cd458 100644 --- a/Fw/Buffer/Buffer.hpp +++ b/Fw/Buffer/Buffer.hpp @@ -134,7 +134,7 @@ class Buffer : public Fw::Serializable { //! or the serialize buffer base representation and serialize from that. //! \param serialBuffer: serialize buffer to write data into //! \return: status of serialization - Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase& serialBuffer, + Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& serialBuffer, Fw::Endianness mode = Fw::Endianness::BIG) const; //! Deserializes this buffer from a SerializeBufferBase @@ -145,7 +145,7 @@ class Buffer : public Fw::Serializable { //! or the serialize buffer base representation and deserialize from that. //! \param buffer: serialize buffer to read data into //! \return: status of serialization - Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG); + Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG); // ---------------------------------------------------------------------- // Accessor functions diff --git a/Fw/Buffer/docs/sdd.md b/Fw/Buffer/docs/sdd.md index 27964b6554..234af58900 100644 --- a/Fw/Buffer/docs/sdd.md +++ b/Fw/Buffer/docs/sdd.md @@ -93,3 +93,7 @@ sb.deserializeTo(my_byte); sb.deserializeTo(my_data, Fw::Endianness::LITTLE); sb.deserializeTo(my_byte, Fw::Endianness::LITTLE); ``` + +The objects returned by `getSerializer()` and `getDeserializer()` implement the `Fw::SerialBufferBase` interface. This +allows them to be passed directly to `Fw::Serializable::serializeTo` and `Fw::Serializable::deserializeFrom` on +user-defined serializable types. diff --git a/Fw/Cmd/CmdArgBuffer.cpp b/Fw/Cmd/CmdArgBuffer.cpp index 189d23650a..38cca9ee11 100644 --- a/Fw/Cmd/CmdArgBuffer.cpp +++ b/Fw/Cmd/CmdArgBuffer.cpp @@ -13,7 +13,7 @@ CmdArgBuffer::CmdArgBuffer() {} CmdArgBuffer::~CmdArgBuffer() {} CmdArgBuffer::CmdArgBuffer(const CmdArgBuffer& other) : Fw::SerializeBufferBase() { - SerializeStatus stat = this->setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = this->setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); } @@ -22,15 +22,19 @@ CmdArgBuffer& CmdArgBuffer::operator=(const CmdArgBuffer& other) { return *this; } - SerializeStatus stat = this->setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = this->setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); return *this; } -FwSizeType CmdArgBuffer::getBuffCapacity() const { +FwSizeType CmdArgBuffer::getCapacity() const { return sizeof(this->m_bufferData); } +FwSizeType CmdArgBuffer::getBuffCapacity() const { + return this->getCapacity(); +} + const U8* CmdArgBuffer::getBuffAddr() const { return this->m_bufferData; } diff --git a/Fw/Cmd/CmdArgBuffer.hpp b/Fw/Cmd/CmdArgBuffer.hpp index f1d8ad5ce6..b784fe2805 100644 --- a/Fw/Cmd/CmdArgBuffer.hpp +++ b/Fw/Cmd/CmdArgBuffer.hpp @@ -31,9 +31,11 @@ class CmdArgBuffer final : public SerializeBufferBase { virtual ~CmdArgBuffer(); //!< destructor CmdArgBuffer& operator=(const CmdArgBuffer& other); //!< Equal operator - FwSizeType getBuffCapacity() const; //!< return capacity of buffer (how much it can hold) - U8* getBuffAddr(); //!< return address of buffer (non const version) - const U8* getBuffAddr() const; //!< return address of buffer (const version) + DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead"); + FwSizeType getCapacity() const; //!< return capacity of buffer (how much it can hold) + + U8* getBuffAddr(); //!< return address of buffer (non const version) + const U8* getBuffAddr() const; //!< return address of buffer (const version) private: U8 m_bufferData[FW_CMD_ARG_BUFFER_MAX_SIZE]; //!< command argument buffer diff --git a/Fw/Cmd/CmdPacket.cpp b/Fw/Cmd/CmdPacket.cpp index 101f4ac0e7..86deb9551b 100644 --- a/Fw/Cmd/CmdPacket.cpp +++ b/Fw/Cmd/CmdPacket.cpp @@ -18,13 +18,13 @@ CmdPacket::CmdPacket() : m_opcode(0) { CmdPacket::~CmdPacket() {} // New serialization interface methods -SerializeStatus CmdPacket::serializeTo(SerializeBufferBase& buffer, Fw::Endianness mode) const { +SerializeStatus CmdPacket::serializeTo(SerialBufferBase& buffer, Fw::Endianness mode) const { // Shouldn't be called, no use case for serializing CmdPackets in FSW (currently) FW_ASSERT(0); return FW_SERIALIZE_OK; // for compiler } -SerializeStatus CmdPacket::deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode) { +SerializeStatus CmdPacket::deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode) { SerializeStatus stat = ComPacket::deserializeBase(buffer); if (stat != FW_SERIALIZE_OK) { return stat; @@ -41,9 +41,9 @@ SerializeStatus CmdPacket::deserializeFrom(SerializeBufferBase& buffer, Fw::Endi } // if non-empty, copy data - if (buffer.getBuffLeft()) { + if (buffer.getDeserializeSizeLeft()) { // copy the serialized arguments to the buffer - stat = buffer.copyRaw(this->m_argBuffer, buffer.getBuffLeft()); + stat = buffer.copyRaw(this->m_argBuffer, buffer.getDeserializeSizeLeft()); } return stat; diff --git a/Fw/Cmd/CmdPacket.hpp b/Fw/Cmd/CmdPacket.hpp index af20769b62..e36c70c502 100644 --- a/Fw/Cmd/CmdPacket.hpp +++ b/Fw/Cmd/CmdPacket.hpp @@ -19,8 +19,8 @@ class CmdPacket : public ComPacket { virtual ~CmdPacket(); // New serialization interface methods - SerializeStatus serializeTo(SerializeBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const; - SerializeStatus deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG); + SerializeStatus serializeTo(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override; + SerializeStatus deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override; FwOpcodeType getOpCode() const; CmdArgBuffer& getArgBuffer(); diff --git a/Fw/Com/ComBuffer.cpp b/Fw/Com/ComBuffer.cpp index 00e1dddb08..10c1311a97 100644 --- a/Fw/Com/ComBuffer.cpp +++ b/Fw/Com/ComBuffer.cpp @@ -13,7 +13,7 @@ ComBuffer::ComBuffer() {} ComBuffer::~ComBuffer() {} ComBuffer::ComBuffer(const ComBuffer& other) : Fw::SerializeBufferBase() { - SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); } @@ -22,15 +22,19 @@ ComBuffer& ComBuffer::operator=(const ComBuffer& other) { return *this; } - SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); return *this; } -FwSizeType ComBuffer::getBuffCapacity() const { +FwSizeType ComBuffer::getCapacity() const { return sizeof(this->m_bufferData); } +FwSizeType ComBuffer::getBuffCapacity() const { + return this->getCapacity(); +} + const U8* ComBuffer::getBuffAddr() const { return this->m_bufferData; } diff --git a/Fw/Com/ComBuffer.hpp b/Fw/Com/ComBuffer.hpp index 74a63dc545..ae2a5f523b 100644 --- a/Fw/Com/ComBuffer.hpp +++ b/Fw/Com/ComBuffer.hpp @@ -30,7 +30,9 @@ class ComBuffer final : public SerializeBufferBase { virtual ~ComBuffer(); ComBuffer& operator=(const ComBuffer& other); - FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer + DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead"); + FwSizeType getCapacity() const; // !< returns capacity, not current size, of buffer + U8* getBuffAddr(); const U8* getBuffAddr() const; diff --git a/Fw/Com/ComPacket.cpp b/Fw/Com/ComPacket.cpp index ba694e1c51..84d94d072f 100644 --- a/Fw/Com/ComPacket.cpp +++ b/Fw/Com/ComPacket.cpp @@ -13,11 +13,11 @@ ComPacket::ComPacket() : m_type(ComPacketType::FW_PACKET_UNKNOWN) {} ComPacket::~ComPacket() {} -SerializeStatus ComPacket::serializeBase(SerializeBufferBase& buffer) const { +SerializeStatus ComPacket::serializeBase(SerialBufferBase& buffer) const { return buffer.serializeFrom(static_cast(this->m_type)); } -SerializeStatus ComPacket::deserializeBase(SerializeBufferBase& buffer) { +SerializeStatus ComPacket::deserializeBase(SerialBufferBase& buffer) { FwPacketDescriptorType serVal; SerializeStatus stat = buffer.deserializeTo(serVal); if (FW_SERIALIZE_OK == stat) { diff --git a/Fw/Com/ComPacket.hpp b/Fw/Com/ComPacket.hpp index bd0dda59c2..6f755b67c1 100644 --- a/Fw/Com/ComPacket.hpp +++ b/Fw/Com/ComPacket.hpp @@ -27,9 +27,9 @@ class ComPacket : public Serializable { protected: ComPacketType m_type; SerializeStatus serializeBase( - SerializeBufferBase& buffer) const; // called by derived classes to serialize common fields + SerialBufferBase& buffer) const; // called by derived classes to serialize common fields SerializeStatus deserializeBase( - SerializeBufferBase& buffer); // called by derived classes to deserialize common fields + SerialBufferBase& buffer); // called by derived classes to deserialize common fields }; } /* namespace Fw */ diff --git a/Fw/Comp/ActiveComponentBase.cpp b/Fw/Comp/ActiveComponentBase.cpp index e814a56fc4..92a57f8db1 100644 --- a/Fw/Comp/ActiveComponentBase.cpp +++ b/Fw/Comp/ActiveComponentBase.cpp @@ -7,7 +7,8 @@ namespace Fw { class ActiveComponentExitSerializableBuffer : public Fw::SerializeBufferBase { public: - FwSizeType getBuffCapacity() const { return sizeof(m_buff); } + DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead"); + FwSizeType getCapacity() const { return sizeof(m_buff); } U8* getBuffAddr() { return m_buff; } diff --git a/Fw/Dp/DpContainer.cpp b/Fw/Dp/DpContainer.cpp index e2e13bbccb..c0dbf55454 100644 --- a/Fw/Dp/DpContainer.cpp +++ b/Fw/Dp/DpContainer.cpp @@ -212,7 +212,7 @@ void DpContainer::setDataHash(Utils::HashBuffer hash) { static_cast(dataHashOffset + HASH_DIGEST_LENGTH), static_cast(bufferSize)); ExternalSerializeBuffer serialBuffer(dataHashAddr, HASH_DIGEST_LENGTH); - hash.resetSer(); + hash.resetDeser(); const Fw::SerializeStatus status = hash.copyRaw(serialBuffer, HASH_DIGEST_LENGTH); FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast(status)); } diff --git a/Fw/Dp/test/ut/DpContainerTester.hpp b/Fw/Dp/test/ut/DpContainerTester.hpp index 29b611e3c1..86854eac83 100644 --- a/Fw/Dp/test/ut/DpContainerTester.hpp +++ b/Fw/Dp/test/ut/DpContainerTester.hpp @@ -27,13 +27,13 @@ class DpContainerTester { } static bool verifyDataBufferCapacity(const Fw::DpContainer& container, FwSizeType expectedCapacity) { - return container.m_dataBuffer.getBuffCapacity() == expectedCapacity; + return container.m_dataBuffer.getCapacity() == expectedCapacity; } static bool isDataBufferEmpty(const Fw::DpContainer& container) { const Fw::SerializeBufferBase& buffer = container.m_dataBuffer; - const FwSizeType buffLength = buffer.getBuffLength(); - const FwSizeType buffLeft = buffer.getBuffLeft(); + const FwSizeType buffLength = buffer.getSize(); + const FwSizeType buffLeft = buffer.getDeserializeSizeLeft(); return buffLength == 0 && buffLeft == 0; } diff --git a/Fw/FilePacket/CancelPacket.cpp b/Fw/FilePacket/CancelPacket.cpp index 1785cb14c5..e55350e9ed 100644 --- a/Fw/FilePacket/CancelPacket.cpp +++ b/Fw/FilePacket/CancelPacket.cpp @@ -31,7 +31,7 @@ SerializeStatus FilePacket::CancelPacket ::toBuffer(Buffer& buffer) const { SerializeStatus FilePacket::CancelPacket ::fromSerialBuffer(SerialBuffer& serialBuffer) { FW_ASSERT(this->m_header.m_type == T_CANCEL); - if (serialBuffer.getBuffLeft() != 0) { + if (serialBuffer.getDeserializeSizeLeft() != 0) { return FW_DESERIALIZE_SIZE_MISMATCH; } diff --git a/Fw/FilePacket/DataPacket.cpp b/Fw/FilePacket/DataPacket.cpp index a3633ff889..e3e475e420 100644 --- a/Fw/FilePacket/DataPacket.cpp +++ b/Fw/FilePacket/DataPacket.cpp @@ -48,7 +48,7 @@ SerializeStatus FilePacket::DataPacket ::fromSerialBuffer(SerialBuffer& serialBu return status; } - if (serialBuffer.getBuffLeft() != this->m_dataSize) { + if (serialBuffer.getDeserializeSizeLeft() != this->m_dataSize) { return FW_DESERIALIZE_SIZE_MISMATCH; } diff --git a/Fw/Fpy/StatementArgBuffer.cpp b/Fw/Fpy/StatementArgBuffer.cpp index 79e1bd5f03..82cc57d75e 100644 --- a/Fw/Fpy/StatementArgBuffer.cpp +++ b/Fw/Fpy/StatementArgBuffer.cpp @@ -14,7 +14,7 @@ StatementArgBuffer::StatementArgBuffer() {} StatementArgBuffer::~StatementArgBuffer() {} StatementArgBuffer::StatementArgBuffer(const StatementArgBuffer& other) : Fw::SerializeBufferBase() { - SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); } @@ -23,15 +23,19 @@ StatementArgBuffer& StatementArgBuffer::operator=(const StatementArgBuffer& othe return *this; } - SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); return *this; } -Serializable::SizeType StatementArgBuffer::getBuffCapacity() const { +Serializable::SizeType StatementArgBuffer::getCapacity() const { return sizeof(this->m_bufferData); } +Serializable::SizeType StatementArgBuffer::getBuffCapacity() const { + return this->getCapacity(); +} + const U8* StatementArgBuffer::getBuffAddr() const { return this->m_bufferData; } @@ -41,7 +45,7 @@ U8* StatementArgBuffer::getBuffAddr() { } bool StatementArgBuffer::operator==(const StatementArgBuffer& other) const { - if (this->getBuffLength() != other.getBuffLength()) { + if (this->getSize() != other.getSize()) { return false; } @@ -51,7 +55,7 @@ bool StatementArgBuffer::operator==(const StatementArgBuffer& other) const { FW_ASSERT(us); FW_ASSERT(them); - for (Serializable::SizeType byte = 0; byte < this->getBuffLength(); byte++) { + for (Serializable::SizeType byte = 0; byte < this->getSize(); byte++) { if (us[byte] != them[byte]) { return false; } @@ -63,7 +67,7 @@ bool StatementArgBuffer::operator==(const StatementArgBuffer& other) const { #if FW_SERIALIZABLE_TO_STRING void StatementArgBuffer::toString(Fw::StringBase& text) const { static const char* formatString = "(data = %p, size = %" PRI_FwSizeType ")"; - text.format(formatString, &this->m_bufferData, this->getBuffLength()); + text.format(formatString, &this->m_bufferData, this->getSize()); } #endif } // namespace Fw diff --git a/Fw/Fpy/StatementArgBuffer.hpp b/Fw/Fpy/StatementArgBuffer.hpp index 0aaf0f0e0f..cfeadee6ca 100644 --- a/Fw/Fpy/StatementArgBuffer.hpp +++ b/Fw/Fpy/StatementArgBuffer.hpp @@ -20,7 +20,9 @@ class StatementArgBuffer : public SerializeBufferBase { virtual ~StatementArgBuffer(); StatementArgBuffer& operator=(const StatementArgBuffer& other); - Serializable::SizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer + DEPRECATED(Serializable::SizeType getBuffCapacity() const, "Use getCapacity() instead"); + Serializable::SizeType getCapacity() const; // !< returns capacity, not current size, of buffer + U8* getBuffAddr(); const U8* getBuffAddr() const; bool operator==(const StatementArgBuffer& other) const; diff --git a/Fw/Log/AmpcsEvrLogPacket.cpp b/Fw/Log/AmpcsEvrLogPacket.cpp index 509e514988..9f4b1c9623 100644 --- a/Fw/Log/AmpcsEvrLogPacket.cpp +++ b/Fw/Log/AmpcsEvrLogPacket.cpp @@ -16,7 +16,7 @@ AmpcsEvrLogPacket::AmpcsEvrLogPacket() : m_eventID(0), m_overSeqNum(0), m_catSeq } AmpcsEvrLogPacket::~AmpcsEvrLogPacket() {} -SerializeStatus AmpcsEvrLogPacket::serializeTo(SerializeBufferBase& buffer) const { +SerializeStatus AmpcsEvrLogPacket::serializeTo(SerialBufferBase& buffer) const { SerializeStatus stat; stat = buffer.serializeFrom(this->m_taskName, AMPCS_EVR_TASK_NAME_LEN, Fw::Serialization::OMIT_LENGTH); @@ -39,14 +39,12 @@ SerializeStatus AmpcsEvrLogPacket::serializeTo(SerializeBufferBase& buffer) cons return stat; } - return buffer.serializeFrom(this->m_logBuffer.getBuffAddr(), m_logBuffer.getBuffLength(), - Fw::Serialization::OMIT_LENGTH); + return buffer.serializeFrom(this->m_logBuffer.getBuffAddr(), m_logBuffer.getSize(), Fw::Serialization::OMIT_LENGTH); } -SerializeStatus AmpcsEvrLogPacket::deserializeFrom(SerializeBufferBase& buffer) { +SerializeStatus AmpcsEvrLogPacket::deserializeFrom(SerialBufferBase& buffer) { FwSizeType len; - SerializeStatus stat; SerializeStatus stat; len = AMPCS_EVR_TASK_NAME_LEN; @@ -70,7 +68,7 @@ SerializeStatus AmpcsEvrLogPacket::deserializeFrom(SerializeBufferBase& buffer) return stat; } - FwSizeType size = buffer.getBuffLeft(); + FwSizeType size = buffer.getDeserializeSizeLeft(); stat = buffer.deserializeTo(this->m_logBuffer.getBuffAddr(), size, true); if (stat == FW_SERIALIZE_OK) { // Shouldn't fail diff --git a/Fw/Log/AmpcsEvrLogPacket.hpp b/Fw/Log/AmpcsEvrLogPacket.hpp index e0a2fbd183..40481e333c 100644 --- a/Fw/Log/AmpcsEvrLogPacket.hpp +++ b/Fw/Log/AmpcsEvrLogPacket.hpp @@ -23,8 +23,8 @@ class AmpcsEvrLogPacket : public ComPacket { AmpcsEvrLogPacket(); virtual ~AmpcsEvrLogPacket(); - SerializeStatus serializeTo(SerializeBufferBase& buffer, - Fw::Endianness mode = Fw::Endianness::BIG) const; //!< serialize contents + SerializeStatus serializeTo(SerialBufferBase& buffer, + Fw::Endianness mode = Fw::Endianness::BIG) const override; //!< serialize contents SerializeStatus deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG); void setTaskName(U8* taskName, U8 len); diff --git a/Fw/Log/LogBuffer.cpp b/Fw/Log/LogBuffer.cpp index 9a7be1511f..3e7ff16914 100644 --- a/Fw/Log/LogBuffer.cpp +++ b/Fw/Log/LogBuffer.cpp @@ -13,7 +13,7 @@ LogBuffer::LogBuffer() {} LogBuffer::~LogBuffer() {} LogBuffer::LogBuffer(const LogBuffer& other) : Fw::SerializeBufferBase() { - SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); } @@ -22,15 +22,19 @@ LogBuffer& LogBuffer::operator=(const LogBuffer& other) { return *this; } - SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); return *this; } -FwSizeType LogBuffer::getBuffCapacity() const { +FwSizeType LogBuffer::getCapacity() const { return sizeof(this->m_bufferData); } +FwSizeType LogBuffer::getBuffCapacity() const { + return this->getCapacity(); +} + const U8* LogBuffer::getBuffAddr() const { return this->m_bufferData; } diff --git a/Fw/Log/LogBuffer.hpp b/Fw/Log/LogBuffer.hpp index e884568103..be1153bf67 100644 --- a/Fw/Log/LogBuffer.hpp +++ b/Fw/Log/LogBuffer.hpp @@ -28,7 +28,9 @@ class LogBuffer final : public SerializeBufferBase { virtual ~LogBuffer(); LogBuffer& operator=(const LogBuffer& other); - FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer + DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead"); + FwSizeType getCapacity() const; // !< returns capacity, not current size, of buffer + U8* getBuffAddr(); const U8* getBuffAddr() const; diff --git a/Fw/Log/LogPacket.cpp b/Fw/Log/LogPacket.cpp index ce8a950c30..340a1b46b5 100644 --- a/Fw/Log/LogPacket.cpp +++ b/Fw/Log/LogPacket.cpp @@ -16,7 +16,7 @@ LogPacket::LogPacket() : m_id(0) { LogPacket::~LogPacket() {} -SerializeStatus LogPacket::serializeTo(SerializeBufferBase& buffer, Fw::Endianness mode) const { +SerializeStatus LogPacket::serializeTo(SerialBufferBase& buffer, Fw::Endianness mode) const { SerializeStatus stat = ComPacket::serializeBase(buffer); if (stat != FW_SERIALIZE_OK) { return stat; @@ -33,11 +33,10 @@ SerializeStatus LogPacket::serializeTo(SerializeBufferBase& buffer, Fw::Endianne } // We want to add data but not size for the ground software - return buffer.serializeFrom(this->m_logBuffer.getBuffAddr(), m_logBuffer.getBuffLength(), - Fw::Serialization::OMIT_LENGTH); + return buffer.serializeFrom(this->m_logBuffer.getBuffAddr(), m_logBuffer.getSize(), Fw::Serialization::OMIT_LENGTH); } -SerializeStatus LogPacket::deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode) { +SerializeStatus LogPacket::deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode) { SerializeStatus stat = deserializeBase(buffer); if (stat != FW_SERIALIZE_OK) { return stat; @@ -54,7 +53,7 @@ SerializeStatus LogPacket::deserializeFrom(SerializeBufferBase& buffer, Fw::Endi } // remainder of buffer must be telemetry value - FwSizeType size = buffer.getBuffLeft(); + FwSizeType size = buffer.getDeserializeSizeLeft(); stat = buffer.deserializeTo(this->m_logBuffer.getBuffAddr(), size, Fw::Serialization::OMIT_LENGTH); if (stat == FW_SERIALIZE_OK) { // Shouldn't fail diff --git a/Fw/Log/LogPacket.hpp b/Fw/Log/LogPacket.hpp index 28a01cab73..714aa6fc87 100644 --- a/Fw/Log/LogPacket.hpp +++ b/Fw/Log/LogPacket.hpp @@ -19,9 +19,9 @@ class LogPacket : public ComPacket { LogPacket(); virtual ~LogPacket(); - SerializeStatus serializeTo(SerializeBufferBase& buffer, + SerializeStatus serializeTo(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override; //!< serialize contents - SerializeStatus deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override; + SerializeStatus deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override; void setId(FwEventIdType id); void setLogBuffer(const LogBuffer& buffer); diff --git a/Fw/Port/InputPortBase.hpp b/Fw/Port/InputPortBase.hpp index 21db274e54..c117662771 100644 --- a/Fw/Port/InputPortBase.hpp +++ b/Fw/Port/InputPortBase.hpp @@ -15,7 +15,7 @@ class InputPortBase : public PortBase { #if FW_PORT_SERIALIZATION virtual SerializeStatus invokeSerial( - SerializeBufferBase& buffer) = 0; // !< invoke the port with a serialized version of the call + LinearBufferBase& buffer) = 0; // !< invoke the port with a serialized version of the call #endif protected: diff --git a/Fw/Port/InputSerializePort.cpp b/Fw/Port/InputSerializePort.cpp index 479515fe01..de9cf776b4 100644 --- a/Fw/Port/InputSerializePort.cpp +++ b/Fw/Port/InputSerializePort.cpp @@ -14,7 +14,7 @@ void InputSerializePort::init() { InputPortBase::init(); } -SerializeStatus InputSerializePort::invokeSerial(SerializeBufferBase& buffer) { +SerializeStatus InputSerializePort::invokeSerial(LinearBufferBase& buffer) { FW_ASSERT(this->m_comp); FW_ASSERT(this->m_func); diff --git a/Fw/Port/InputSerializePort.hpp b/Fw/Port/InputSerializePort.hpp index 61c70608c9..42d7caa005 100644 --- a/Fw/Port/InputSerializePort.hpp +++ b/Fw/Port/InputSerializePort.hpp @@ -17,11 +17,11 @@ class InputSerializePort final : public InputPortBase { void init() override; SerializeStatus invokeSerial( - SerializeBufferBase& buffer) override; // !< invoke the port with a serialized version of the call + LinearBufferBase& buffer) override; // !< invoke the port with a serialized version of the call typedef void (*CompFuncPtr)(Fw::PassiveComponentBase* callComp, FwIndexType portNum, - SerializeBufferBase& arg); //!< port callback definition + LinearBufferBase& arg); //!< port callback definition void addCallComp(Fw::PassiveComponentBase* callComp, CompFuncPtr funcPtr); //!< call to register a component protected: diff --git a/Fw/Prm/PrmBuffer.cpp b/Fw/Prm/PrmBuffer.cpp index f6b2549752..8a5292e2b7 100644 --- a/Fw/Prm/PrmBuffer.cpp +++ b/Fw/Prm/PrmBuffer.cpp @@ -13,7 +13,7 @@ ParamBuffer::ParamBuffer() {} ParamBuffer::~ParamBuffer() {} ParamBuffer::ParamBuffer(const ParamBuffer& other) : Fw::SerializeBufferBase() { - SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); } @@ -22,15 +22,19 @@ ParamBuffer& ParamBuffer::operator=(const ParamBuffer& other) { return *this; } - SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); return *this; } -FwSizeType ParamBuffer::getBuffCapacity() const { +FwSizeType ParamBuffer::getCapacity() const { return sizeof(this->m_bufferData); } +FwSizeType ParamBuffer::getBuffCapacity() const { + return this->getCapacity(); +} + const U8* ParamBuffer::getBuffAddr() const { return this->m_bufferData; } diff --git a/Fw/Prm/PrmBuffer.hpp b/Fw/Prm/PrmBuffer.hpp index 682d50a8f4..5da565e4fd 100644 --- a/Fw/Prm/PrmBuffer.hpp +++ b/Fw/Prm/PrmBuffer.hpp @@ -36,7 +36,9 @@ class ParamBuffer final : public SerializeBufferBase { virtual ~ParamBuffer(); ParamBuffer& operator=(const ParamBuffer& other); - FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer + DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead"); + FwSizeType getCapacity() const; // !< returns capacity, not current size, of buffer + U8* getBuffAddr(); const U8* getBuffAddr() const; diff --git a/Fw/Prm/PrmExternalTypes.hpp b/Fw/Prm/PrmExternalTypes.hpp index c8802f3292..598a05e190 100644 --- a/Fw/Prm/PrmExternalTypes.hpp +++ b/Fw/Prm/PrmExternalTypes.hpp @@ -31,7 +31,7 @@ class ParamExternalDelegate { virtual SerializeStatus deserializeParam(const FwPrmIdType base_id, const FwPrmIdType local_id, const ParamValid prmStat, - SerializeBufferBase& buff) = 0; + SerialBufferBase& buff) = 0; //! Serialize a parameter into a parameter buffer //! @@ -42,7 +42,7 @@ class ParamExternalDelegate { //! \return: The status of the serialize operation virtual SerializeStatus serializeParam(const FwPrmIdType base_id, const FwPrmIdType local_id, - SerializeBufferBase& buff) const = 0; + SerialBufferBase& buff) const = 0; }; } // namespace Fw diff --git a/Fw/SerializableFile/SerializableFile.cpp b/Fw/SerializableFile/SerializableFile.cpp index 6f50fd39bb..2a6c59b53d 100644 --- a/Fw/SerializableFile/SerializableFile.cpp +++ b/Fw/SerializableFile/SerializableFile.cpp @@ -39,7 +39,7 @@ SerializableFile::Status SerializableFile::load(const char* fileName, Serializab return FILE_OPEN_ERROR; } - FwSizeType length = this->m_buffer.getBuffCapacity(); + FwSizeType length = this->m_buffer.getCapacity(); status = file.read(this->m_buffer.getBuffAddr(), length, Os::File::WaitType::NO_WAIT); if (Os::File::OP_OK != status) { file.close(); @@ -71,9 +71,9 @@ SerializableFile::Status SerializableFile::save(const char* fileName, Serializab return FILE_OPEN_ERROR; } - FwSizeType length = this->m_buffer.getBuffLength(); + FwSizeType length = this->m_buffer.getSize(); status = file.write(this->m_buffer.getBuffAddr(), length); - if ((Os::File::OP_OK != status) || (length != this->m_buffer.getBuffLength())) { + if ((Os::File::OP_OK != status) || (length != this->m_buffer.getSize())) { file.close(); return FILE_WRITE_ERROR; } diff --git a/Fw/Sm/SmSignalBuffer.cpp b/Fw/Sm/SmSignalBuffer.cpp index afa85d7ef2..ebfbad8625 100644 --- a/Fw/Sm/SmSignalBuffer.cpp +++ b/Fw/Sm/SmSignalBuffer.cpp @@ -16,9 +16,9 @@ SmSignalBuffer::~SmSignalBuffer() {} SmSignalBuffer::SmSignalBuffer(const SmSignalBuffer& other) : Fw::SerializeBufferBase(), m_bufferData{} { FW_ASSERT(other.getBuffAddr() != nullptr); - FW_ASSERT(other.getBuffLength() <= sizeof(this->m_bufferData)); + FW_ASSERT(other.getSize() <= sizeof(this->m_bufferData)); - SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); } @@ -28,17 +28,21 @@ SmSignalBuffer& SmSignalBuffer::operator=(const SmSignalBuffer& other) { } FW_ASSERT(other.getBuffAddr() != nullptr); - FW_ASSERT(other.getBuffLength() <= sizeof(this->m_bufferData)); + FW_ASSERT(other.getSize() <= sizeof(this->m_bufferData)); - SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); return *this; } -Serializable::SizeType SmSignalBuffer::getBuffCapacity() const { +Serializable::SizeType SmSignalBuffer::getCapacity() const { return sizeof(this->m_bufferData); } +Serializable::SizeType SmSignalBuffer::getBuffCapacity() const { + return this->getCapacity(); +} + const U8* SmSignalBuffer::getBuffAddr() const { return this->m_bufferData; } diff --git a/Fw/Sm/SmSignalBuffer.hpp b/Fw/Sm/SmSignalBuffer.hpp index 6c8d246e36..1465ab5104 100644 --- a/Fw/Sm/SmSignalBuffer.hpp +++ b/Fw/Sm/SmSignalBuffer.hpp @@ -28,7 +28,9 @@ class SmSignalBuffer final : public SerializeBufferBase { virtual ~SmSignalBuffer(); SmSignalBuffer& operator=(const SmSignalBuffer& other); - Serializable::SizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer + DEPRECATED(Serializable::SizeType getBuffCapacity() const, "Use getCapacity() instead"); + Serializable::SizeType getCapacity() const; // !< returns capacity, not current size, of buffer + U8* getBuffAddr(); const U8* getBuffAddr() const; diff --git a/Fw/Time/Time.cpp b/Fw/Time/Time.cpp index abef7c9d57..92dd1dabf7 100644 --- a/Fw/Time/Time.cpp +++ b/Fw/Time/Time.cpp @@ -77,11 +77,11 @@ bool Time::operator<=(const Time& other) const { return ((LT == c) or (EQ == c)); } -SerializeStatus Time::serializeTo(SerializeBufferBase& buffer, Fw::Endianness mode) const { +SerializeStatus Time::serializeTo(SerialBufferBase& buffer, Fw::Endianness mode) const { return this->m_val.serializeTo(buffer, mode); } -SerializeStatus Time::deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode) { +SerializeStatus Time::deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode) { return this->m_val.deserializeFrom(buffer, mode); } diff --git a/Fw/Time/Time.hpp b/Fw/Time/Time.hpp index 2c8013bef3..889d0adafa 100644 --- a/Fw/Time/Time.hpp +++ b/Fw/Time/Time.hpp @@ -36,9 +36,9 @@ class Time : public Serializable { TimeBase getTimeBase() const; // !< Time base of time. This is project specific and is meant for indicating different sources of time FwTimeContextStoreType getContext() const; // !< get the context value - SerializeStatus serializeTo(SerializeBufferBase& buffer, + SerializeStatus serializeTo(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override; // !< Serialize method - SerializeStatus deserializeFrom(SerializeBufferBase& buffer, + SerializeStatus deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override; // !< Deserialize method bool operator==(const Time& other) const; bool operator!=(const Time& other) const; diff --git a/Fw/Time/TimeInterval.cpp b/Fw/Time/TimeInterval.cpp index 130f81fb3c..4f4232dba1 100644 --- a/Fw/Time/TimeInterval.cpp +++ b/Fw/Time/TimeInterval.cpp @@ -53,12 +53,12 @@ bool TimeInterval::operator<=(const TimeInterval& other) const { return ((LT == c) or (EQ == c)); } -SerializeStatus TimeInterval::serializeTo(SerializeBufferBase& buffer, Fw::Endianness mode) const { +SerializeStatus TimeInterval::serializeTo(SerialBufferBase& buffer, Fw::Endianness mode) const { // Use TimeIntervalValue's built-in serialization return this->m_val.serializeTo(buffer, mode); } -SerializeStatus TimeInterval::deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode) { +SerializeStatus TimeInterval::deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode) { // Use TimeIntervalValue's built-in deserialization return this->m_val.deserializeFrom(buffer, mode); } diff --git a/Fw/Time/TimeInterval.hpp b/Fw/Time/TimeInterval.hpp index 7f45101aee..6d0f0181fb 100644 --- a/Fw/Time/TimeInterval.hpp +++ b/Fw/Time/TimeInterval.hpp @@ -30,9 +30,9 @@ class TimeInterval : public Serializable { U32 getSeconds() const; // !< Gets seconds part of time U32 getUSeconds() const; // !< Gets microseconds part of time - SerializeStatus serializeTo(SerializeBufferBase& buffer, + SerializeStatus serializeTo(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override; // !< Serialize method - SerializeStatus deserializeFrom(SerializeBufferBase& buffer, + SerializeStatus deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override; // !< Deserialize method void add(U32 seconds, U32 mseconds); // !< Add seconds and microseconds to existing time interval bool operator==(const TimeInterval& other) const; diff --git a/Fw/Tlm/TlmBuffer.cpp b/Fw/Tlm/TlmBuffer.cpp index 396f5f1b81..88a678bf46 100644 --- a/Fw/Tlm/TlmBuffer.cpp +++ b/Fw/Tlm/TlmBuffer.cpp @@ -13,7 +13,7 @@ TlmBuffer::TlmBuffer() {} TlmBuffer::~TlmBuffer() {} TlmBuffer::TlmBuffer(const TlmBuffer& other) : Fw::SerializeBufferBase() { - SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); } @@ -22,15 +22,19 @@ TlmBuffer& TlmBuffer::operator=(const TlmBuffer& other) { return *this; } - SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); return *this; } -FwSizeType TlmBuffer::getBuffCapacity() const { +FwSizeType TlmBuffer::getCapacity() const { return sizeof(this->m_bufferData); } +FwSizeType TlmBuffer::getBuffCapacity() const { + return this->getCapacity(); +} + const U8* TlmBuffer::getBuffAddr() const { return this->m_bufferData; } diff --git a/Fw/Tlm/TlmBuffer.hpp b/Fw/Tlm/TlmBuffer.hpp index 0c3dc69565..c17b988449 100644 --- a/Fw/Tlm/TlmBuffer.hpp +++ b/Fw/Tlm/TlmBuffer.hpp @@ -27,7 +27,9 @@ class TlmBuffer final : public SerializeBufferBase { virtual ~TlmBuffer(); TlmBuffer& operator=(const TlmBuffer& other); - FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer + DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead"); + FwSizeType getCapacity() const; // !< returns capacity, not current size, of buffer + U8* getBuffAddr(); const U8* getBuffAddr() const; diff --git a/Fw/Tlm/TlmPacket.cpp b/Fw/Tlm/TlmPacket.cpp index edfb60478d..0f6b228e8e 100644 --- a/Fw/Tlm/TlmPacket.cpp +++ b/Fw/Tlm/TlmPacket.cpp @@ -62,8 +62,8 @@ void TlmPacket::setBuffer(Fw::ComBuffer& buffer) { SerializeStatus TlmPacket::addValue(FwChanIdType id, Time& timeTag, TlmBuffer& buffer) { // check to make sure there is room for all the fields - FwSizeType left = this->m_tlmBuffer.getBuffCapacity() - this->m_tlmBuffer.getBuffLength(); - if ((sizeof(FwChanIdType) + Time::SERIALIZED_SIZE + buffer.getBuffLength()) > left) { + FwSizeType left = this->m_tlmBuffer.getCapacity() - this->m_tlmBuffer.getSize(); + if ((sizeof(FwChanIdType) + Time::SERIALIZED_SIZE + buffer.getSize()) > left) { return Fw::FW_SERIALIZE_NO_ROOM_LEFT; } @@ -82,8 +82,7 @@ SerializeStatus TlmPacket::addValue(FwChanIdType id, Time& timeTag, TlmBuffer& b } // telemetry buffer - stat = - this->m_tlmBuffer.serializeFrom(buffer.getBuffAddr(), buffer.getBuffLength(), Fw::Serialization::OMIT_LENGTH); + stat = this->m_tlmBuffer.serializeFrom(buffer.getBuffAddr(), buffer.getSize(), Fw::Serialization::OMIT_LENGTH); if (stat != Fw::FW_SERIALIZE_OK) { return stat; } @@ -125,25 +124,24 @@ SerializeStatus TlmPacket::extractValue(FwChanIdType& id, Time& timeTag, TlmBuff return Fw::FW_SERIALIZE_OK; } -SerializeStatus TlmPacket::serializeTo(SerializeBufferBase& buffer, Fw::Endianness mode) const { +SerializeStatus TlmPacket::serializeTo(SerialBufferBase& buffer, Fw::Endianness mode) const { // serialize the number of packets SerializeStatus stat = buffer.serializeFrom(this->m_numEntries, mode); if (stat != Fw::FW_SERIALIZE_OK) { return stat; } // Serialize the ComBuffer - return buffer.serializeFrom(this->m_tlmBuffer.getBuffAddr(), m_tlmBuffer.getBuffLength(), - Fw::Serialization::OMIT_LENGTH); + return buffer.serializeFrom(this->m_tlmBuffer.getBuffAddr(), m_tlmBuffer.getSize(), Fw::Serialization::OMIT_LENGTH); } -SerializeStatus TlmPacket::deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode) { +SerializeStatus TlmPacket::deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode) { // deserialize the number of packets SerializeStatus stat = buffer.deserializeTo(this->m_numEntries, mode); if (stat != Fw::FW_SERIALIZE_OK) { return stat; } // deserialize the channel value entry buffers - FwSizeType size = buffer.getBuffLeft(); + FwSizeType size = buffer.getDeserializeSizeLeft(); stat = buffer.deserializeTo(this->m_tlmBuffer.getBuffAddr(), size, Fw::Serialization::OMIT_LENGTH); if (stat == FW_SERIALIZE_OK) { // Shouldn't fail diff --git a/Fw/Tlm/TlmPacket.hpp b/Fw/Tlm/TlmPacket.hpp index 8773c84652..ecb31fd856 100644 --- a/Fw/Tlm/TlmPacket.hpp +++ b/Fw/Tlm/TlmPacket.hpp @@ -22,9 +22,9 @@ class TlmPacket : public ComPacket { //! Destructor virtual ~TlmPacket(); - SerializeStatus serializeTo(SerializeBufferBase& buffer, + SerializeStatus serializeTo(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override; //!< serialize contents - SerializeStatus deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override; + SerializeStatus deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override; //! Add telemetry value to buffer. SerializeStatus addValue(FwChanIdType id, Time& timeTag, TlmBuffer& buffer); //! extract telemetry value - since there are potentially multiple channel values in the packet, diff --git a/Fw/Types/PolyType.cpp b/Fw/Types/PolyType.cpp index 8f2fbfdaf4..741f37baae 100644 --- a/Fw/Types/PolyType.cpp +++ b/Fw/Types/PolyType.cpp @@ -480,7 +480,7 @@ bool PolyType::operator<=(const PolyType& other) const { return (this->operator<(other)) || (this->operator==(other)); } -SerializeStatus PolyType::serializeTo(SerializeBufferBase& buffer, Fw::Endianness mode) const { +SerializeStatus PolyType::serializeTo(SerialBufferBase& buffer, Fw::Endianness mode) const { // store type SerializeStatus stat = buffer.serializeFrom(static_cast(this->m_dataType), mode); if (stat != FW_SERIALIZE_OK) { @@ -539,7 +539,7 @@ SerializeStatus PolyType::serializeTo(SerializeBufferBase& buffer, Fw::Endiannes return stat; } -SerializeStatus PolyType::deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode) { +SerializeStatus PolyType::deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode) { // get type FwEnumStoreType des; SerializeStatus stat = buffer.deserializeTo(des, mode); diff --git a/Fw/Types/PolyType.hpp b/Fw/Types/PolyType.hpp index cc2b0e9fd8..5974c3c9f7 100644 --- a/Fw/Types/PolyType.hpp +++ b/Fw/Types/PolyType.hpp @@ -103,9 +103,9 @@ class PolyType : public Serializable { bool operator==(const PolyType& other) const; //!< PolyType operator== bool operator!=(const PolyType& other) const; //!< PolyType operator!= - SerializeStatus serializeTo(SerializeBufferBase& buffer, + SerializeStatus serializeTo(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override; //!< Serialize function - SerializeStatus deserializeFrom(SerializeBufferBase& buffer, + SerializeStatus deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override; //!< Deserialize function private: diff --git a/Fw/Types/SerialBuffer.cpp b/Fw/Types/SerialBuffer.cpp index c6025ecd4f..057ba593f2 100644 --- a/Fw/Types/SerialBuffer.cpp +++ b/Fw/Types/SerialBuffer.cpp @@ -17,10 +17,14 @@ namespace Fw { SerialBuffer ::SerialBuffer(U8* const data, const FwSizeType capacity) : m_data(data), m_capacity(capacity) {} -FwSizeType SerialBuffer ::getBuffCapacity() const { +FwSizeType SerialBuffer ::getCapacity() const { return m_capacity; } +FwSizeType SerialBuffer ::getBuffCapacity() const { + return this->getCapacity(); +} + U8* SerialBuffer ::getBuffAddr() { return m_data; } diff --git a/Fw/Types/SerialBuffer.hpp b/Fw/Types/SerialBuffer.hpp index d54176085e..c74b2582b6 100644 --- a/Fw/Types/SerialBuffer.hpp +++ b/Fw/Types/SerialBuffer.hpp @@ -38,7 +38,8 @@ class SerialBuffer final : public SerializeBufferBase { // Pure virtual methods from SerializeBufferBase // ---------------------------------------------------------------------- - FwSizeType getBuffCapacity() const; + DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead"); + FwSizeType getCapacity() const; U8* getBuffAddr(); diff --git a/Fw/Types/Serializable.cpp b/Fw/Types/Serializable.cpp index cebf74cff5..be764e01fc 100644 --- a/Fw/Types/Serializable.cpp +++ b/Fw/Types/Serializable.cpp @@ -37,32 +37,34 @@ std::ostream& operator<<(std::ostream& os, const Serializable& val) { } #endif -SerializeBufferBase::SerializeBufferBase() : m_serLoc(0), m_deserLoc(0) {} +SerialBufferBase::~SerialBufferBase() {} -SerializeBufferBase::~SerializeBufferBase() {} +LinearBufferBase::LinearBufferBase() : m_serLoc(0), m_deserLoc(0) {} -void SerializeBufferBase::copyFrom(const SerializeBufferBase& src) { +LinearBufferBase::~LinearBufferBase() {} + +void LinearBufferBase::copyFrom(const LinearBufferBase& src) { this->m_serLoc = src.m_serLoc; this->m_deserLoc = src.m_deserLoc; FW_ASSERT(src.getBuffAddr()); FW_ASSERT(this->getBuffAddr()); // destination has to be same or bigger - FW_ASSERT(src.getBuffLength() <= this->getBuffCapacity(), static_cast(src.getBuffLength()), - static_cast(this->getBuffLength())); + FW_ASSERT(src.getSize() <= this->getCapacity(), static_cast(src.getSize()), + static_cast(this->getSize())); (void)memcpy(this->getBuffAddr(), src.getBuffAddr(), static_cast(this->m_serLoc)); } // Copy constructor doesn't make sense in this virtual class as there is nothing to copy. Derived classes should // call the empty constructor and then call their own copy function -SerializeBufferBase& SerializeBufferBase::operator=(const SerializeBufferBase& src) { // lgtm[cpp/rule-of-two] +LinearBufferBase& LinearBufferBase::operator=(const LinearBufferBase& src) { // lgtm[cpp/rule-of-two] this->copyFrom(src); return *this; } // serialization routines -SerializeStatus SerializeBufferBase::serializeFrom(U8 val, Endianness mode) { - if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { +SerializeStatus LinearBufferBase::serializeFrom(U8 val, Endianness mode) { + if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getCapacity()) { return FW_SERIALIZE_NO_ROOM_LEFT; } FW_ASSERT(this->getBuffAddr()); @@ -73,13 +75,13 @@ SerializeStatus SerializeBufferBase::serializeFrom(U8 val, Endianness mode) { return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::serializeFrom(I8 val, Endianness mode) { +SerializeStatus LinearBufferBase::serializeFrom(I8 val, Endianness mode) { return serializeFrom(static_cast(val), mode); } #if FW_HAS_16_BIT == 1 -SerializeStatus SerializeBufferBase::serializeFrom(U16 val, Endianness mode) { - if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { +SerializeStatus LinearBufferBase::serializeFrom(U16 val, Endianness mode) { + if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getCapacity()) { return FW_SERIALIZE_NO_ROOM_LEFT; } FW_ASSERT(this->getBuffAddr()); @@ -103,13 +105,13 @@ SerializeStatus SerializeBufferBase::serializeFrom(U16 val, Endianness mode) { return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::serializeFrom(I16 val, Endianness mode) { +SerializeStatus LinearBufferBase::serializeFrom(I16 val, Endianness mode) { return serializeFrom(static_cast(val), mode); } #endif #if FW_HAS_32_BIT == 1 -SerializeStatus SerializeBufferBase::serializeFrom(U32 val, Endianness mode) { - if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { +SerializeStatus LinearBufferBase::serializeFrom(U32 val, Endianness mode) { + if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getCapacity()) { return FW_SERIALIZE_NO_ROOM_LEFT; } FW_ASSERT(this->getBuffAddr()); @@ -137,14 +139,14 @@ SerializeStatus SerializeBufferBase::serializeFrom(U32 val, Endianness mode) { return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::serializeFrom(I32 val, Endianness mode) { +SerializeStatus LinearBufferBase::serializeFrom(I32 val, Endianness mode) { return serializeFrom(static_cast(val), mode); } #endif #if FW_HAS_64_BIT == 1 -SerializeStatus SerializeBufferBase::serializeFrom(U64 val, Endianness mode) { - if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { +SerializeStatus LinearBufferBase::serializeFrom(U64 val, Endianness mode) { + if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getCapacity()) { return FW_SERIALIZE_NO_ROOM_LEFT; } FW_ASSERT(this->getBuffAddr()); @@ -180,27 +182,27 @@ SerializeStatus SerializeBufferBase::serializeFrom(U64 val, Endianness mode) { return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::serializeFrom(I64 val, Endianness mode) { +SerializeStatus LinearBufferBase::serializeFrom(I64 val, Endianness mode) { return serializeFrom(static_cast(val), mode); } #endif -SerializeStatus SerializeBufferBase::serializeFrom(F64 val, Endianness mode) { +SerializeStatus LinearBufferBase::serializeFrom(F64 val, Endianness mode) { // floating point values need to be byte-swapped as well, so copy to U64 and use that routine U64 u64Val; (void)memcpy(&u64Val, &val, sizeof(val)); return this->serializeFrom(u64Val, mode); } -SerializeStatus SerializeBufferBase::serializeFrom(F32 val, Endianness mode) { +SerializeStatus LinearBufferBase::serializeFrom(F32 val, Endianness mode) { // floating point values need to be byte-swapped as well, so copy to U32 and use that routine U32 u32Val; (void)memcpy(&u32Val, &val, sizeof(val)); return this->serializeFrom(u32Val, mode); } -SerializeStatus SerializeBufferBase::serializeFrom(bool val, Endianness mode) { - if (this->m_serLoc + static_cast(sizeof(U8)) - 1 >= this->getBuffCapacity()) { +SerializeStatus LinearBufferBase::serializeFrom(bool val, Endianness mode) { + if (this->m_serLoc + static_cast(sizeof(U8)) - 1 >= this->getCapacity()) { return FW_SERIALIZE_NO_ROOM_LEFT; } @@ -216,24 +218,22 @@ SerializeStatus SerializeBufferBase::serializeFrom(bool val, Endianness mode) { return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::serializeFrom(const void* val, Endianness mode) { - if (this->m_serLoc + static_cast(sizeof(void*)) - 1 >= this->getBuffCapacity()) { +SerializeStatus LinearBufferBase::serializeFrom(const void* val, Endianness mode) { + if (this->m_serLoc + static_cast(sizeof(void*)) - 1 >= this->getCapacity()) { return FW_SERIALIZE_NO_ROOM_LEFT; } return this->serializeFrom(reinterpret_cast(val), mode); } -SerializeStatus SerializeBufferBase::serializeFrom(const U8* buff, - Serializable::SizeType length, - Endianness endianMode) { +SerializeStatus LinearBufferBase::serializeFrom(const U8* buff, Serializable::SizeType length, Endianness endianMode) { return this->serializeFrom(buff, static_cast(length), Serialization::INCLUDE_LENGTH, endianMode); } -SerializeStatus SerializeBufferBase::serializeFrom(const U8* buff, - FwSizeType length, - Serialization::t lengthMode, - Endianness endianMode) { // First serialize length +SerializeStatus LinearBufferBase::serializeFrom(const U8* buff, + FwSizeType length, + Serialization::t lengthMode, + Endianness endianMode) { // First serialize length SerializeStatus stat; if (lengthMode == Serialization::INCLUDE_LENGTH) { stat = this->serializeFrom(static_cast(length), endianMode); @@ -243,7 +243,7 @@ SerializeStatus SerializeBufferBase::serializeFrom(const U8* buff, } // make sure we have enough space - if (this->m_serLoc + length > this->getBuffCapacity()) { + if (this->m_serLoc + length > this->getCapacity()) { return FW_SERIALIZE_NO_ROOM_LEFT; } @@ -255,14 +255,13 @@ SerializeStatus SerializeBufferBase::serializeFrom(const U8* buff, return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::serializeFrom(const Serializable& val, Endianness mode) { +SerializeStatus LinearBufferBase::serializeFrom(const Serializable& val, Endianness mode) { return val.serializeTo(*this, mode); } -SerializeStatus SerializeBufferBase::serializeFrom(const SerializeBufferBase& val, Endianness mode) { - Serializable::SizeType size = val.getBuffLength(); - if (this->m_serLoc + size + static_cast(sizeof(FwSizeStoreType)) > - this->getBuffCapacity()) { +SerializeStatus LinearBufferBase::serializeFrom(const LinearBufferBase& val, Endianness mode) { + Serializable::SizeType size = val.getSize(); + if (this->m_serLoc + size + static_cast(sizeof(FwSizeStoreType)) > this->getCapacity()) { return FW_SERIALIZE_NO_ROOM_LEFT; } @@ -282,7 +281,7 @@ SerializeStatus SerializeBufferBase::serializeFrom(const SerializeBufferBase& va return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::serializeSize(const FwSizeType size, Endianness mode) { +SerializeStatus LinearBufferBase::serializeSize(const FwSizeType size, Endianness mode) { SerializeStatus status = FW_SERIALIZE_OK; if ((size < std::numeric_limits::min()) || (size > std::numeric_limits::max())) { status = FW_SERIALIZE_FORMAT_ERROR; @@ -295,11 +294,11 @@ SerializeStatus SerializeBufferBase::serializeSize(const FwSizeType size, Endian // deserialization routines -SerializeStatus SerializeBufferBase::deserializeTo(U8& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(U8& val, Endianness mode) { // check for room - if (this->getBuffLength() == this->m_deserLoc) { + if (this->getSize() == this->m_deserLoc) { return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { + } else if (this->getSize() - this->m_deserLoc < static_cast(sizeof(val))) { return FW_DESERIALIZE_SIZE_MISMATCH; } // read from current location @@ -309,11 +308,11 @@ SerializeStatus SerializeBufferBase::deserializeTo(U8& val, Endianness mode) { return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::deserializeTo(I8& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(I8& val, Endianness mode) { // check for room - if (this->getBuffLength() == this->m_deserLoc) { + if (this->getSize() == this->m_deserLoc) { return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { + } else if (this->getSize() - this->m_deserLoc < static_cast(sizeof(val))) { return FW_DESERIALIZE_SIZE_MISMATCH; } // read from current location @@ -324,11 +323,11 @@ SerializeStatus SerializeBufferBase::deserializeTo(I8& val, Endianness mode) { } #if FW_HAS_16_BIT == 1 -SerializeStatus SerializeBufferBase::deserializeTo(U16& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(U16& val, Endianness mode) { // check for room - if (this->getBuffLength() == this->m_deserLoc) { + if (this->getSize() == this->m_deserLoc) { return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { + } else if (this->getSize() - this->m_deserLoc < static_cast(sizeof(val))) { return FW_DESERIALIZE_SIZE_MISMATCH; } // read from current location @@ -352,7 +351,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(U16& val, Endianness mode) { return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::deserializeTo(I16& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(I16& val, Endianness mode) { U16 unsignVal; SerializeStatus res = deserializeTo(unsignVal, mode); if (res == SerializeStatus::FW_SERIALIZE_OK) { @@ -362,11 +361,11 @@ SerializeStatus SerializeBufferBase::deserializeTo(I16& val, Endianness mode) { } #endif #if FW_HAS_32_BIT == 1 -SerializeStatus SerializeBufferBase::deserializeTo(U32& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(U32& val, Endianness mode) { // check for room - if (this->getBuffLength() == this->m_deserLoc) { + if (this->getSize() == this->m_deserLoc) { return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { + } else if (this->getSize() - this->m_deserLoc < static_cast(sizeof(val))) { return FW_DESERIALIZE_SIZE_MISMATCH; } // read from current location @@ -394,7 +393,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(U32& val, Endianness mode) { return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::deserializeTo(I32& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(I32& val, Endianness mode) { U32 unsignVal; SerializeStatus res = deserializeTo(unsignVal, mode); if (res == SerializeStatus::FW_SERIALIZE_OK) { @@ -406,11 +405,11 @@ SerializeStatus SerializeBufferBase::deserializeTo(I32& val, Endianness mode) { #if FW_HAS_64_BIT == 1 -SerializeStatus SerializeBufferBase::deserializeTo(U64& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(U64& val, Endianness mode) { // check for room - if (this->getBuffLength() == this->m_deserLoc) { + if (this->getSize() == this->m_deserLoc) { return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { + } else if (this->getSize() - this->m_deserLoc < static_cast(sizeof(val))) { return FW_DESERIALIZE_SIZE_MISMATCH; } // read from current location @@ -446,7 +445,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(U64& val, Endianness mode) { return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::deserializeTo(I64& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(I64& val, Endianness mode) { U64 unsignVal; SerializeStatus res = deserializeTo(unsignVal, mode); if (res == SerializeStatus::FW_SERIALIZE_OK) { @@ -456,7 +455,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(I64& val, Endianness mode) { } #endif -SerializeStatus SerializeBufferBase::deserializeTo(F64& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(F64& val, Endianness mode) { // deserialize as 64-bit int to handle endianness U64 tempVal; SerializeStatus stat = this->deserializeTo(tempVal, mode); @@ -469,11 +468,11 @@ SerializeStatus SerializeBufferBase::deserializeTo(F64& val, Endianness mode) { return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::deserializeTo(bool& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(bool& val, Endianness mode) { // check for room - if (this->getBuffLength() == this->m_deserLoc) { + if (this->getSize() == this->m_deserLoc) { return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(U8))) { + } else if (this->getSize() - this->m_deserLoc < static_cast(sizeof(U8))) { return FW_DESERIALIZE_SIZE_MISMATCH; } // read from current location @@ -490,7 +489,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(bool& val, Endianness mode) { return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::deserializeTo(void*& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(void*& val, Endianness mode) { // Deserialize as pointer cast, then convert to void* PlatformPointerCastType pointerCastVal = 0; const SerializeStatus stat = this->deserializeTo(pointerCastVal, mode); @@ -500,7 +499,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(void*& val, Endianness mode) return stat; } -SerializeStatus SerializeBufferBase::deserializeTo(F32& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(F32& val, Endianness mode) { // deserialize as 64-bit int to handle endianness U32 tempVal; SerializeStatus stat = this->deserializeTo(tempVal, mode); @@ -512,17 +511,17 @@ SerializeStatus SerializeBufferBase::deserializeTo(F32& val, Endianness mode) { return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::deserializeTo(U8* buff, Serializable::SizeType& length, Endianness endianMode) { +SerializeStatus LinearBufferBase::deserializeTo(U8* buff, Serializable::SizeType& length, Endianness endianMode) { FwSizeType length_in_out = static_cast(length); SerializeStatus status = this->deserializeTo(buff, length_in_out, Serialization::INCLUDE_LENGTH, endianMode); length = static_cast(length_in_out); return status; } -SerializeStatus SerializeBufferBase::deserializeTo(U8* buff, - Serializable::SizeType& length, - Serialization::t lengthMode, - Endianness endianMode) { +SerializeStatus LinearBufferBase::deserializeTo(U8* buff, + Serializable::SizeType& length, + Serialization::t lengthMode, + Endianness endianMode) { FW_ASSERT(this->getBuffAddr()); if (lengthMode == Serialization::INCLUDE_LENGTH) { @@ -535,7 +534,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(U8* buff, } // make sure it fits - if ((storedLength > this->getBuffLeft()) or (storedLength > length)) { + if ((storedLength > this->getDeserializeSizeLeft()) or (storedLength > length)) { return FW_DESERIALIZE_SIZE_MISMATCH; } @@ -545,7 +544,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(U8* buff, } else { // make sure enough is left - if (length > this->getBuffLeft()) { + if (length > this->getDeserializeSizeLeft()) { return FW_DESERIALIZE_SIZE_MISMATCH; } @@ -556,11 +555,11 @@ SerializeStatus SerializeBufferBase::deserializeTo(U8* buff, return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::deserializeTo(Serializable& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(Serializable& val, Endianness mode) { return val.deserializeFrom(*this, mode); } -SerializeStatus SerializeBufferBase::deserializeTo(SerializeBufferBase& val, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeTo(LinearBufferBase& val, Endianness mode) { FW_ASSERT(val.getBuffAddr()); SerializeStatus stat = FW_SERIALIZE_OK; @@ -574,7 +573,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(SerializeBufferBase& val, End // make sure destination has enough room - if ((storedLength > val.getBuffCapacity()) or (storedLength > this->getBuffLeft())) { + if ((storedLength > val.getCapacity()) or (storedLength > this->getDeserializeSizeLeft())) { return FW_DESERIALIZE_SIZE_MISMATCH; } @@ -592,7 +591,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(SerializeBufferBase& val, End return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::deserializeSize(FwSizeType& size, Endianness mode) { +SerializeStatus LinearBufferBase::deserializeSize(FwSizeType& size, Endianness mode) { FwSizeStoreType storedSize = 0; Fw::SerializeStatus status = this->deserializeTo(storedSize, mode); if (status == FW_SERIALIZE_OK) { @@ -601,21 +600,21 @@ SerializeStatus SerializeBufferBase::deserializeSize(FwSizeType& size, Endiannes return status; } -void SerializeBufferBase::resetSer() { +void LinearBufferBase::resetSer() { this->m_deserLoc = 0; this->m_serLoc = 0; } -void SerializeBufferBase::resetDeser() { +void LinearBufferBase::resetDeser() { this->m_deserLoc = 0; } -SerializeStatus SerializeBufferBase::serializeSkip(FwSizeType numBytesToSkip) { +SerializeStatus LinearBufferBase::serializeSkip(FwSizeType numBytesToSkip) { Fw::SerializeStatus status = FW_SERIALIZE_OK; // compute new deser loc const FwSizeType newSerLoc = this->m_serLoc + numBytesToSkip; // check for room - if (newSerLoc <= this->getBuffCapacity()) { + if (newSerLoc <= this->getCapacity()) { // update deser loc this->m_serLoc = static_cast(newSerLoc); } else { @@ -624,11 +623,11 @@ SerializeStatus SerializeBufferBase::serializeSkip(FwSizeType numBytesToSkip) { return status; } -SerializeStatus SerializeBufferBase::deserializeSkip(FwSizeType numBytesToSkip) { +SerializeStatus LinearBufferBase::deserializeSkip(FwSizeType numBytesToSkip) { // check for room - if (this->getBuffLength() == this->m_deserLoc) { + if (this->getSize() == this->m_deserLoc) { return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < numBytesToSkip) { + } else if (this->getSize() - this->m_deserLoc < numBytesToSkip) { return FW_DESERIALIZE_SIZE_MISMATCH; } // update location in buffer to skip the value @@ -636,25 +635,25 @@ SerializeStatus SerializeBufferBase::deserializeSkip(FwSizeType numBytesToSkip) return FW_SERIALIZE_OK; } -SerializeStatus SerializeBufferBase::moveSerToOffset(FwSizeType offset) { +SerializeStatus LinearBufferBase::moveSerToOffset(FwSizeType offset) { // Reset serialization this->resetSer(); // Advance to offset return this->serializeSkip(offset); } -SerializeStatus SerializeBufferBase::moveDeserToOffset(FwSizeType offset) { +SerializeStatus LinearBufferBase::moveDeserToOffset(FwSizeType offset) { // Reset deserialization this->resetDeser(); // Advance to offset return this->deserializeSkip(offset); } -Serializable::SizeType SerializeBufferBase::getBuffLength() const { +Serializable::SizeType LinearBufferBase::getSize() const { return this->m_serLoc; } -SerializeStatus SerializeBufferBase::setBuff(const U8* src, Serializable::SizeType length) { - if (this->getBuffCapacity() < length) { +SerializeStatus LinearBufferBase::setBuff(const U8* src, Serializable::SizeType length) { + if (this->getCapacity() < length) { return FW_SERIALIZE_NO_ROOM_LEFT; } else { FW_ASSERT(src); @@ -666,8 +665,8 @@ SerializeStatus SerializeBufferBase::setBuff(const U8* src, Serializable::SizeTy } } -SerializeStatus SerializeBufferBase::setBuffLen(Serializable::SizeType length) { - if (this->getBuffCapacity() < length) { +SerializeStatus LinearBufferBase::setBuffLen(Serializable::SizeType length) { + if (this->getCapacity() < length) { return FW_SERIALIZE_NO_ROOM_LEFT; } else { this->m_serLoc = length; @@ -676,17 +675,27 @@ SerializeStatus SerializeBufferBase::setBuffLen(Serializable::SizeType length) { } } -Serializable::SizeType SerializeBufferBase::getBuffLeft() const { +Serializable::SizeType LinearBufferBase::getDeserializeSizeLeft() const { FW_ASSERT(this->m_serLoc >= this->m_deserLoc, static_cast(this->m_serLoc), static_cast(this->m_deserLoc)); return this->m_serLoc - this->m_deserLoc; } -SerializeStatus SerializeBufferBase::copyRaw(SerializeBufferBase& dest, Serializable::SizeType size) { +Serializable::SizeType LinearBufferBase::getSerializeSizeLeft() const { + FW_ASSERT(static_cast(this->m_serLoc)); + return this->getCapacity() - this->m_serLoc; +} + +SerializeStatus LinearBufferBase::copyRaw(SerialBufferBase& dest, Serializable::SizeType size) { // make sure there is sufficient size in destination - if (dest.getBuffCapacity() < size) { + if (dest.getCapacity() < size) { return FW_SERIALIZE_NO_ROOM_LEFT; } + // make sure there is sufficient buffer in source + if (this->getDeserializeSizeLeft() < size) { + return FW_DESERIALIZE_SIZE_MISMATCH; + } + // otherwise, set destination buffer to data from deserialization pointer plus size SerializeStatus stat = dest.setBuff(&this->getBuffAddr()[this->m_deserLoc], size); if (stat == FW_SERIALIZE_OK) { @@ -695,13 +704,13 @@ SerializeStatus SerializeBufferBase::copyRaw(SerializeBufferBase& dest, Serializ return stat; } -SerializeStatus SerializeBufferBase::copyRawOffset(SerializeBufferBase& dest, Serializable::SizeType size) { +SerializeStatus LinearBufferBase::copyRawOffset(SerialBufferBase& dest, Serializable::SizeType size) { // make sure there is sufficient size in destination - if (dest.getBuffCapacity() < size + dest.getBuffLength()) { + if (dest.getCapacity() < size + dest.getSize()) { return FW_SERIALIZE_NO_ROOM_LEFT; } // make sure there is sufficient buffer in source - if (this->getBuffLeft() < size) { + if (this->getDeserializeSizeLeft() < size) { return FW_DESERIALIZE_SIZE_MISMATCH; } @@ -715,18 +724,18 @@ SerializeStatus SerializeBufferBase::copyRawOffset(SerializeBufferBase& dest, Se // return address of buffer not yet deserialized. This is used // to copy the remainder of a buffer. -const U8* SerializeBufferBase::getBuffAddrLeft() const { +const U8* LinearBufferBase::getBuffAddrLeft() const { return &this->getBuffAddr()[this->m_deserLoc]; } //!< gets address of end of serialization. Used to manually place data at the end -U8* SerializeBufferBase::getBuffAddrSer() { +U8* LinearBufferBase::getBuffAddrSer() { return &this->getBuffAddr()[this->m_serLoc]; } #ifdef BUILD_UT -bool SerializeBufferBase::operator==(const SerializeBufferBase& other) const { - if (this->getBuffLength() != other.getBuffLength()) { +bool LinearBufferBase::operator==(const SerializeBufferBase& other) const { + if (this->getSize() != other.getSize()) { return false; } @@ -736,7 +745,7 @@ bool SerializeBufferBase::operator==(const SerializeBufferBase& other) const { FW_ASSERT(us); FW_ASSERT(them); - for (Serializable::SizeType byte = 0; byte < this->getBuffLength(); byte++) { + for (Serializable::SizeType byte = 0; byte < this->getSize(); byte++) { if (us[byte] != them[byte]) { return false; } @@ -745,12 +754,12 @@ bool SerializeBufferBase::operator==(const SerializeBufferBase& other) const { return true; } -std::ostream& operator<<(std::ostream& os, const SerializeBufferBase& buff) { +std::ostream& operator<<(std::ostream& os, const LinearBufferBase& buff) { const U8* us = buff.getBuffAddr(); FW_ASSERT(us); - for (Serializable::SizeType byte = 0; byte < buff.getBuffLength(); byte++) { + for (Serializable::SizeType byte = 0; byte < buff.getSize(); byte++) { os << "[" << std::setw(2) << std::hex << std::setfill('0') << us[byte] << "]" << std::dec; } @@ -780,7 +789,7 @@ void ExternalSerializeBuffer::clear() { this->m_buffSize = 0; } -Serializable::SizeType ExternalSerializeBuffer::getBuffCapacity() const { +Serializable::SizeType ExternalSerializeBuffer::getCapacity() const { return this->m_buffSize; } @@ -796,130 +805,142 @@ const U8* ExternalSerializeBuffer::getBuffAddr() const { // Deprecated method implementations for backward compatibility // ---------------------------------------------------------------------- -SerializeStatus SerializeBufferBase::serialize(U8 val) { +Serializable::SizeType LinearBufferBase::getBuffLength() const { + return this->getSize(); +} + +Serializable::SizeType LinearBufferBase::getBuffLeft() { + return this->getDeserializeSizeLeft(); +} + +SerializeStatus LinearBufferBase::serialize(U8 val) { return this->serializeFrom(val); } -SerializeStatus SerializeBufferBase::serialize(I8 val) { +SerializeStatus LinearBufferBase::serialize(I8 val) { return this->serializeFrom(val); } #if FW_HAS_16_BIT == 1 -SerializeStatus SerializeBufferBase::serialize(U16 val) { +SerializeStatus LinearBufferBase::serialize(U16 val) { return this->serializeFrom(val); } -SerializeStatus SerializeBufferBase::serialize(I16 val) { +SerializeStatus LinearBufferBase::serialize(I16 val) { return this->serializeFrom(val); } #endif #if FW_HAS_32_BIT == 1 -SerializeStatus SerializeBufferBase::serialize(U32 val) { +SerializeStatus LinearBufferBase::serialize(U32 val) { return this->serializeFrom(val); } -SerializeStatus SerializeBufferBase::serialize(I32 val) { +SerializeStatus LinearBufferBase::serialize(I32 val) { return this->serializeFrom(val); } #endif #if FW_HAS_64_BIT == 1 -SerializeStatus SerializeBufferBase::serialize(U64 val) { +SerializeStatus LinearBufferBase::serialize(U64 val) { return this->serializeFrom(val); } -SerializeStatus SerializeBufferBase::serialize(I64 val) { +SerializeStatus LinearBufferBase::serialize(I64 val) { return this->serializeFrom(val); } #endif -SerializeStatus SerializeBufferBase::serialize(F32 val) { +SerializeStatus LinearBufferBase::serialize(F32 val) { return this->serializeFrom(val); } -SerializeStatus SerializeBufferBase::serialize(F64 val) { +SerializeStatus LinearBufferBase::serialize(F64 val) { return this->serializeFrom(val); } -SerializeStatus SerializeBufferBase::serialize(bool val) { +SerializeStatus LinearBufferBase::serialize(bool val) { return this->serializeFrom(val); } -SerializeStatus SerializeBufferBase::serialize(const void* val) { +SerializeStatus LinearBufferBase::serialize(const void* val) { return this->serializeFrom(val); } // Deprecated method for backward compatibility -SerializeStatus SerializeBufferBase::serialize(const U8* buff, FwSizeType length, bool noLength) { +SerializeStatus LinearBufferBase::serialize(const U8* buff, FwSizeType length, bool noLength) { const Serialization::t mode = noLength ? Serialization::OMIT_LENGTH : Serialization::INCLUDE_LENGTH; return this->serializeFrom(buff, length, mode); } -SerializeStatus SerializeBufferBase::serialize(const U8* buff, FwSizeType length) { +SerializeStatus LinearBufferBase::serialize(const U8* buff, FwSizeType length) { return this->serializeFrom(buff, length); } -SerializeStatus SerializeBufferBase::serialize(const U8* buff, FwSizeType length, Serialization::t mode) { +SerializeStatus LinearBufferBase::serialize(const U8* buff, FwSizeType length, Serialization::t mode) { return this->serializeFrom(buff, length, mode); } -SerializeStatus SerializeBufferBase::serialize(const Serializable& val) { +SerializeStatus LinearBufferBase::serialize(const Serializable& val) { return this->serializeFrom(val); } -SerializeStatus SerializeBufferBase::serialize(const SerializeBufferBase& val) { +SerializeStatus LinearBufferBase::serialize(const LinearBufferBase& val) { return this->serializeFrom(val); } -SerializeStatus SerializeBufferBase::deserialize(U8& val) { +SerializeStatus LinearBufferBase::deserialize(U8& val) { return this->deserializeTo(val); } -SerializeStatus SerializeBufferBase::deserialize(I8& val) { +SerializeStatus LinearBufferBase::deserialize(I8& val) { return this->deserializeTo(val); } #if FW_HAS_16_BIT == 1 -SerializeStatus SerializeBufferBase::deserialize(U16& val) { +SerializeStatus LinearBufferBase::deserialize(U16& val) { return this->deserializeTo(val); } -SerializeStatus SerializeBufferBase::deserialize(I16& val) { +SerializeStatus LinearBufferBase::deserialize(I16& val) { return this->deserializeTo(val); } #endif #if FW_HAS_32_BIT == 1 -SerializeStatus SerializeBufferBase::deserialize(U32& val) { +SerializeStatus LinearBufferBase::deserialize(U32& val) { return this->deserializeTo(val); } -SerializeStatus SerializeBufferBase::deserialize(I32& val) { +SerializeStatus LinearBufferBase::deserialize(I32& val) { return this->deserializeTo(val); } #endif #if FW_HAS_64_BIT == 1 -SerializeStatus SerializeBufferBase::deserialize(U64& val) { +SerializeStatus LinearBufferBase::deserialize(U64& val) { return this->deserializeTo(val); } -SerializeStatus SerializeBufferBase::deserialize(I64& val) { +SerializeStatus LinearBufferBase::deserialize(I64& val) { return this->deserializeTo(val); } #endif -SerializeStatus SerializeBufferBase::deserialize(F32& val) { +SerializeStatus LinearBufferBase::deserialize(F32& val) { return this->deserializeTo(val); } -SerializeStatus SerializeBufferBase::deserialize(F64& val) { +SerializeStatus LinearBufferBase::deserialize(F64& val) { return this->deserializeTo(val); } -SerializeStatus SerializeBufferBase::deserialize(bool& val) { +SerializeStatus LinearBufferBase::deserialize(bool& val) { return this->deserializeTo(val); } -SerializeStatus SerializeBufferBase::deserialize(void*& val) { +SerializeStatus LinearBufferBase::deserialize(void*& val) { return this->deserializeTo(val); } // Deprecated method for backward compatibility -SerializeStatus SerializeBufferBase::deserialize(U8* buff, FwSizeType& length, bool noLength) { +SerializeStatus LinearBufferBase::deserialize(U8* buff, FwSizeType& length, bool noLength) { const Serialization::t mode = noLength ? Serialization::OMIT_LENGTH : Serialization::INCLUDE_LENGTH; return this->deserializeTo(buff, length, mode); } -SerializeStatus SerializeBufferBase::deserialize(U8* buff, FwSizeType& length) { +SerializeStatus LinearBufferBase::deserialize(U8* buff, FwSizeType& length) { return this->deserializeTo(buff, length, Serialization::INCLUDE_LENGTH); } -SerializeStatus SerializeBufferBase::deserialize(U8* buff, FwSizeType& length, Serialization::t mode) { +SerializeStatus LinearBufferBase::deserialize(U8* buff, FwSizeType& length, Serialization::t mode) { return this->deserializeTo(buff, length, mode); } -SerializeStatus SerializeBufferBase::deserialize(Serializable& val) { +SerializeStatus LinearBufferBase::deserialize(Serializable& val) { return this->deserializeTo(val); } -SerializeStatus SerializeBufferBase::deserialize(SerializeBufferBase& val) { +SerializeStatus LinearBufferBase::deserialize(LinearBufferBase& val) { return this->deserializeTo(val); } +Serializable::SizeType ExternalSerializeBuffer::getBuffCapacity() const { + return this->getCapacity(); +} + } // namespace Fw diff --git a/Fw/Types/Serializable.hpp b/Fw/Types/Serializable.hpp index 46096eb8ba..80da7be8c5 100644 --- a/Fw/Types/Serializable.hpp +++ b/Fw/Types/Serializable.hpp @@ -20,7 +20,12 @@ typedef enum { FW_DESERIALIZE_SIZE_MISMATCH, //!< Data was left in the buffer, but not enough to deserialize FW_DESERIALIZE_TYPE_MISMATCH //!< Deserialized type ID didn't match } SerializeStatus; -class SerializeBufferBase; //!< forward declaration + +class SerialBufferBase; //!< forward declaration +class LinearBufferBase; //!< forward declaration + +// TODO: Temporary backwards-compatibility hack. Remove this when all references to SerializeBufferBase are migrated. +using SerializeBufferBase = LinearBufferBase; struct Serialization { enum t { @@ -40,29 +45,52 @@ class Serializable { using SizeType = FwSizeType; public: - virtual SerializeStatus serializeTo(SerializeBufferBase& buffer, - Endianness mode = Endianness::BIG) const = 0; //!< serialize contents to buffer + //! \brief Serialize the contents of this object to a buffer + //! + //! This method serializes the object's data into the provided buffer. + //! The serialization process converts the object's data into a format + //! that can be stored or transmitted, and then writes it to the buffer. + //! + //! \param buffer Reference to the SerialBufferBase where data will be serialized + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeTo(SerialBufferBase& buffer, Endianness mode = Endianness::BIG) const = 0; - virtual SerializeStatus deserializeFrom( - SerializeBufferBase& buffer, - Endianness mode = Endianness::BIG) = 0; //!< deserialize contents from buffer + //! \brief Deserialize the contents of this object from a buffer + //! + //! This method reads serialized data from the provided buffer and + //! reconstructs the object's data from it. The buffer should contain + //! data in the format produced by serializeTo(). + //! + //! \param buffer Reference to the SerialBufferBase from which data will be deserialized + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeFrom(SerialBufferBase& buffer, Endianness mode = Endianness::BIG) = 0; // ---------------------------------------------------------------------- // Legacy methods for backward compatibility // ---------------------------------------------------------------------- - DEPRECATED(SerializeStatus serialize(SerializeBufferBase& buffer) const, - "Use serializeTo(SerializeBufferBase& buffer) instead") { + DEPRECATED(SerializeStatus serialize(SerialBufferBase& buffer) const, + "Use serializeTo(SerialBufferBase& buffer) instead") { return this->serializeTo(buffer); } - DEPRECATED(SerializeStatus deserialize(SerializeBufferBase& buffer), - "Use deserializeFrom(SerializeBufferBase& buffer) instead") { + DEPRECATED(SerializeStatus deserialize(SerialBufferBase& buffer), + "Use deserializeFrom(SerialBufferBase& buffer) instead") { return this->deserializeFrom(buffer); } #if FW_SERIALIZABLE_TO_STRING || FW_ENABLE_TEXT_LOGGING || BUILD_UT - virtual void toString(StringBase& text) const; //!< generate text from serializable + //! \brief Generate a human-readable string representation of this object + //! + //! This method converts the object's data into a textual representation + //! that can be used for logging, debugging, or display purposes. The + //! exact format of the string may vary depending on the implementation + //! of the derived class. + //! + //! \param text Reference to a StringBase object where the text representation will be stored + virtual void toString(StringBase& text) const; #endif #ifdef BUILD_UT @@ -70,124 +98,1173 @@ class Serializable { #endif protected: - Serializable(); //!< Default constructor - virtual ~Serializable(); //!< destructor + //! \brief Default constructor + //! + //! Initializes a Serializable object with default values. + Serializable(); + + //! \brief Virtual destructor + //! + //! Ensures proper cleanup of derived classes. + virtual ~Serializable(); }; -class SerializeBufferBase { - friend class SerializeBufferBaseTester; - - protected: - SerializeBufferBase& operator=(const SerializeBufferBase& src); //!< copy assignment operator - +class SerialBufferBase { public: - virtual ~SerializeBufferBase(); //!< destructor + //! \brief Virtual destructor + //! + //! Ensures proper cleanup of derived classes. + virtual ~SerialBufferBase(); // Serialization for built-in types - SerializeStatus serializeFrom(U8 val, Endianness mode = Endianness::BIG); //!< serialize 8-bit unsigned int - SerializeStatus serializeFrom(I8 val, Endianness mode = Endianness::BIG); //!< serialize 8-bit signed int + //! \brief Serialize an 8-bit unsigned integer value + //! + //! This method serializes a single 8-bit unsigned integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! NOTE: The 'mode' argument here for endianness has no effect as there is no + //! concept of endianness for a U8. It has been left in for compatibility. + //! + //! \param val The 8-bit unsigned integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(U8 val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Serialize an 8-bit signed integer value + //! + //! This method serializes a single 8-bit signed integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! NOTE: The 'mode' argument here for endianness has no effect as there is no + //! concept of endianness for an I8. It has been left in for compatibility. + //! + //! \param val The 8-bit signed integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(I8 val, Endianness mode = Endianness::BIG) = 0; #if FW_HAS_16_BIT == 1 - SerializeStatus serializeFrom(U16 val, Endianness mode = Endianness::BIG); //!< serialize 16-bit unsigned int - SerializeStatus serializeFrom(I16 val, Endianness mode = Endianness::BIG); //!< serialize 16-bit signed int + //! \brief Serialize a 16-bit unsigned integer value + //! + //! This method serializes a single 16-bit unsigned integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 16-bit unsigned integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(U16 val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Serialize a 16-bit signed integer value + //! + //! This method serializes a single 16-bit signed integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 16-bit signed integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(I16 val, Endianness mode = Endianness::BIG) = 0; #endif #if FW_HAS_32_BIT == 1 - SerializeStatus serializeFrom(U32 val, Endianness mode = Endianness::BIG); //!< serialize 32-bit unsigned int - SerializeStatus serializeFrom(I32 val, Endianness mode = Endianness::BIG); //!< serialize 32-bit signed int + //! \brief Serialize a 32-bit unsigned integer value + //! + //! This method serializes a single 32-bit unsigned integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 32-bit unsigned integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(U32 val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Serialize a 32-bit signed integer value + //! + //! This method serializes a single 32-bit signed integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 32-bit signed integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(I32 val, Endianness mode = Endianness::BIG) = 0; #endif #if FW_HAS_64_BIT == 1 - SerializeStatus serializeFrom(U64 val, Endianness mode = Endianness::BIG); //!< serialize 64-bit unsigned int - SerializeStatus serializeFrom(I64 val, Endianness mode = Endianness::BIG); //!< serialize 64-bit signed int + //! \brief Serialize a 64-bit unsigned integer value + //! + //! This method serializes a single 64-bit unsigned integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 64-bit unsigned integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(U64 val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Serialize a 64-bit signed integer value + //! + //! This method serializes a single 64-bit signed integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 64-bit signed integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(I64 val, Endianness mode = Endianness::BIG) = 0; #endif - SerializeStatus serializeFrom(F32 val, Endianness mode = Endianness::BIG); //!< serialize 32-bit floating point - SerializeStatus serializeFrom(F64 val, Endianness mode = Endianness::BIG); //!< serialize 64-bit floating point - SerializeStatus serializeFrom(bool val, Endianness mode = Endianness::BIG); //!< serialize boolean - - SerializeStatus serializeFrom(const void* val, - Endianness mode = Endianness::BIG); //!< serialize pointer (careful, only pointer - //!< value, not contents are serialized) - - //! serialize data buffer - SerializeStatus serializeFrom(const U8* buff, FwSizeType length, Endianness endianMode = Endianness::BIG); - - //! \brief serialize a byte buffer of a given length + //! \brief Serialize a 32-bit floating point value //! - //! Serialize bytes from `buff` up to `length`. If `serializationMode` is set to `INCLUDE_LENGTH` then the - //! length is included as the first token. Length may be omitted with `OMIT_LENGTH`. + //! This method serializes a single 32-bit floating point value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. //! - //! \param buff: buffer to serialize - //! \param length: length of data to serialize - //! \param mode: serialization type - //! \return status of serialization - SerializeStatus serializeFrom(const U8* buff, - FwSizeType length, - Serialization::t lengthMode, - Endianness endianMode = Endianness::BIG); + //! \param val The 32-bit floating point value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(F32 val, Endianness mode = Endianness::BIG) = 0; - SerializeStatus serializeFrom(const SerializeBufferBase& val, - Endianness mode = Endianness::BIG); //!< serialize a serialized buffer + //! \brief Serialize a 64-bit floating point value + //! + //! This method serializes a single 64-bit floating point value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 64-bit floating point value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(F64 val, Endianness mode = Endianness::BIG) = 0; - SerializeStatus serializeFrom( - const Serializable& val, - Endianness mode = Endianness::BIG); //!< serialize an object derived from serializable base class + //! \brief Serialize a boolean value + //! + //! This method serializes a single boolean value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The boolean value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(bool val, Endianness mode = Endianness::BIG) = 0; - SerializeStatus serializeSize(const FwSizeType size, - Endianness mode = Endianness::BIG); //!< serialize a size value + //! \brief Serialize a pointer value + //! + //! This method serializes a pointer value into the buffer. Note that only + //! the pointer value itself is serialized, not the contents it points to. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The pointer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(const void* val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Serialize a data buffer + //! + //! This method serializes a buffer of bytes into the serialization buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param buff Pointer to the buffer containing data to serialize + //! \param length Number of bytes to serialize from the buffer + //! \param endianMode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(const U8* buff, + FwSizeType length, + Endianness endianMode = Endianness::BIG) = 0; + + //! \brief Serialize a byte buffer with optional length prefix + //! + //! This method serializes a buffer of bytes into the serialization buffer. + //! If lengthMode is set to INCLUDE_LENGTH, the length is included as the first token. + //! The endianness of the serialization can be controlled via the endianMode parameter. + //! + //! \param buff Pointer to the buffer containing data to serialize + //! \param length Number of bytes to serialize from the buffer + //! \param lengthMode Specifies whether to include length in serialization (INCLUDE_LENGTH or OMIT_LENGTH) + //! \param endianMode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(const U8* buff, + FwSizeType length, + Serialization::t lengthMode, + Endianness endianMode = Endianness::BIG) = 0; + + //! \brief Serialize another LinearBufferBase object + //! + //! This method serializes the contents of another LinearBufferBase object + //! into this buffer. The endianness of the serialization can be controlled + //! via the mode parameter. + //! + //! \param val Reference to the LinearBufferBase object to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(const LinearBufferBase& val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Serialize a Serializable object + //! + //! This method serializes an object derived from the Serializable base class + //! into this buffer. The endianness of the serialization can be controlled + //! via the mode parameter. + //! + //! \param val Reference to the Serializable object to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeFrom(const Serializable& val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Serialize a size value + //! + //! This method serializes a size value (typically used for buffer sizes) + //! into this buffer. The endianness of the serialization can be controlled + //! via the mode parameter. + //! + //! \param size The size value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeSize(const FwSizeType size, Endianness mode = Endianness::BIG) = 0; // Deserialization for built-in types - SerializeStatus deserializeTo(U8& val, Endianness mode = Endianness::BIG); //!< deserialize 8-bit unsigned int - SerializeStatus deserializeTo(I8& val, Endianness mode = Endianness::BIG); //!< deserialize 8-bit signed int + //! \brief Deserialize an 8-bit unsigned integer value + //! + //! This method reads an 8-bit unsigned integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 8-bit unsigned integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(U8& val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Deserialize an 8-bit signed integer value + //! + //! This method reads an 8-bit signed integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 8-bit signed integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(I8& val, Endianness mode = Endianness::BIG) = 0; #if FW_HAS_16_BIT == 1 - SerializeStatus deserializeTo(U16& val, Endianness mode = Endianness::BIG); //!< deserialize 16-bit unsigned int - SerializeStatus deserializeTo(I16& val, Endianness mode = Endianness::BIG); //!< deserialize 16-bit signed int + //! \brief Deserialize a 16-bit unsigned integer value + //! + //! This method reads a 16-bit unsigned integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 16-bit unsigned integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(U16& val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Deserialize a 16-bit signed integer value + //! + //! This method reads a 16-bit signed integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 16-bit signed integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(I16& val, Endianness mode = Endianness::BIG) = 0; #endif #if FW_HAS_32_BIT == 1 - SerializeStatus deserializeTo(U32& val, Endianness mode = Endianness::BIG); //!< deserialize 32-bit unsigned int - SerializeStatus deserializeTo(I32& val, Endianness mode = Endianness::BIG); //!< deserialize 32-bit signed int + //! \brief Deserialize a 32-bit unsigned integer value + //! + //! This method reads a 32-bit unsigned integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 32-bit unsigned integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(U32& val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Deserialize a 32-bit signed integer value + //! + //! This method reads a 32-bit signed integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 32-bit signed integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(I32& val, Endianness mode = Endianness::BIG) = 0; #endif #if FW_HAS_64_BIT == 1 - SerializeStatus deserializeTo(U64& val, Endianness mode = Endianness::BIG); //!< deserialize 64-bit unsigned int - SerializeStatus deserializeTo(I64& val, Endianness mode = Endianness::BIG); //!< deserialize 64-bit signed int -#endif - SerializeStatus deserializeTo(F32& val, Endianness mode = Endianness::BIG); //!< deserialize 32-bit floating point - SerializeStatus deserializeTo(F64& val, Endianness mode = Endianness::BIG); //!< deserialize 64-bit floating point - SerializeStatus deserializeTo(bool& val, Endianness mode = Endianness::BIG); //!< deserialize boolean - - SerializeStatus deserializeTo( - void*& val, - Endianness mode = Endianness::BIG); //!< deserialize point value (careful, pointer value only, not contents) - - SerializeStatus deserializeTo(U8* buff, - FwSizeType& length, - Endianness endianMode = Endianness::BIG); //!< deserialize data buffer - - //! \brief deserialize a byte buffer of a given length + //! \brief Deserialize a 64-bit unsigned integer value //! - //! The `mode` parameter specifies whether the serialized length should be read from the buffer. - //! \param buff: buffer to deserialize into - //! \param length: length of the buffer, updated with the actual deserialized length - //! \param mode: deserialization type - //! \return status of serialization + //! This method reads a 64-bit unsigned integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 64-bit unsigned integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(U64& val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Deserialize a 64-bit signed integer value + //! + //! This method reads a 64-bit signed integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 64-bit signed integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(I64& val, Endianness mode = Endianness::BIG) = 0; +#endif + //! \brief Deserialize a 32-bit floating point value + //! + //! This method reads a 32-bit floating point value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 32-bit floating point value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(F32& val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Deserialize a 64-bit floating point value + //! + //! This method reads a 64-bit floating point value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 64-bit floating point value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(F64& val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Deserialize a boolean value + //! + //! This method reads a boolean value from the deserialization buffer + //! and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized boolean value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(bool& val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Deserialize a pointer value + //! + //! This method reads a pointer value from the deserialization buffer + //! and stores it in the provided reference. Note that only the pointer + //! value itself is deserialized, not the contents it points to. The + //! endianness of the deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized pointer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(void*& val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Deserialize a data buffer + //! + //! This method reads a buffer of bytes from the deserialization buffer + //! and stores them in the provided buffer. The endianness of the + //! deserialization can be controlled via the endianMode parameter. + //! + //! \param buff Pointer to the buffer where deserialized data will be stored + //! \param length Reference to store the actual number of bytes deserialized + //! \param endianMode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(U8* buff, FwSizeType& length, Endianness endianMode = Endianness::BIG) = 0; + + //! \brief Deserialize a byte buffer with optional length prefix + //! + //! This method reads a buffer of bytes from the deserialization buffer + //! and stores them in the provided buffer. If lengthMode indicates that + //! a length prefix was included, it will be read from the buffer first. + //! The endianness of the deserialization can be controlled via the + //! endianMode parameter. + //! + //! \param buff Pointer to the buffer where deserialized data will be stored + //! \param length Reference to store the actual number of bytes deserialized + //! \param lengthMode Specifies whether length was included in serialization (INCLUDE_LENGTH or OMIT_LENGTH) + //! \param endianMode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(U8* buff, + FwSizeType& length, + Serialization::t lengthMode, + Endianness endianMode = Endianness::BIG) = 0; + + //! \brief Deserialize a Serializable object + //! + //! This method reads data from the deserialization buffer and reconstructs + //! a Serializable object from it. The endianness of the deserialization + //! can be controlled via the mode parameter. + //! + //! \param val Reference to the Serializable object that will be populated with deserialized data + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(Serializable& val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Deserialize a LinearBufferBase object + //! + //! This method reads data from the deserialization buffer and reconstructs + //! a LinearBufferBase object from it. The endianness of the deserialization + //! can be controlled via the mode parameter. + //! + //! \param val Reference to the LinearBufferBase object that will be populated with deserialized data + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeTo(LinearBufferBase& val, Endianness mode = Endianness::BIG) = 0; + + //! \brief Deserialize a size value + //! + //! This method reads a size value (typically used for buffer sizes) + //! from the deserialization buffer. The endianness of the deserialization + //! can be controlled via the mode parameter. + //! + //! \param size Reference to store the deserialized size value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeSize(FwSizeType& size, Endianness mode = Endianness::BIG) = 0; + + //! \brief Copy raw bytes from the source (this) into a destination buffer and advance source offset + //! + //! Copies exactly `size` bytes starting at the current deserialization pointer of `this` into `dest`. + //! This operation does not prepend a length field and does not interpret the data. + //! + //! Preconditions: + //! - `size` bytes must remain in the source (`getDeserializeSizeLeft() >= size`). + //! - Destination must have sufficient capacity (`dest.getCapacity() >= size`). + //! + //! Post-conditions on success: + //! - `dest` contains exactly the copied bytes and its previous contents are discarded. + //! - `this` has advanced its deserialization pointer by `size` bytes. + //! + //! \param dest Destination serialization buffer to receive the bytes (its contents are replaced) + //! \param size Number of bytes to copy from the source + //! \return `FW_SERIALIZE_OK` on success; `FW_SERIALIZE_NO_ROOM_LEFT` if destination capacity is insufficient; + //! `FW_DESERIALIZE_SIZE_MISMATCH` if source does not contain `size` bytes remaining + virtual SerializeStatus copyRaw(SerialBufferBase& dest, Serializable::SizeType size) = 0; + + //! \brief Append raw bytes to destination (no length) and advance source offset + //! + //! Appends exactly `size` bytes from the current deserialization pointer of `this` into `dest` using + //! `Serialization::OMIT_LENGTH`, preserving any existing bytes already serialized in `dest`. + //! + //! Preconditions: + //! - `size` bytes must remain in the source (`getDeserializeSizeLeft() >= size`). + //! - Destination must have space for the append (`dest.getCapacity() >= dest.getSize() + size`). + //! + //! Post-conditions on success: + //! - `dest` gains `size` additional bytes at the end; no length token is written. + //! - `this` has advanced its deserialization pointer by `size` bytes. + //! + //! \param dest Destination serialization buffer to append to + //! \param size Number of bytes to copy from the source and append to dest + //! \return `FW_SERIALIZE_OK` on success; `FW_SERIALIZE_NO_ROOM_LEFT` if destination capacity is insufficient; + //! `FW_DESERIALIZE_SIZE_MISMATCH` if source does not contain `size` bytes remaining + virtual SerializeStatus copyRawOffset(SerialBufferBase& dest, Serializable::SizeType size) = 0; + + //! \brief Reset serialization pointer to beginning of buffer + //! + //! This method resets the serialization pointer to the beginning of the buffer, + //! allowing the buffer to be reused for new serialization operations. Any + //! data that was previously serialized in the buffer will be overwritten. + virtual void resetSer() = 0; + + //! \brief Reset deserialization pointer to beginning of buffer + //! + //! This method resets the deserialization pointer to the beginning of the buffer, + //! allowing the buffer to be reused for new deserialization operations. The buffer + //! contents are not modified, but the pointer is reset to allow reading from the + //! start of the data. + virtual void resetDeser() = 0; + + //! \brief Move serialization pointer to specified offset + //! + //! This method moves the serialization pointer to the specified offset within + //! the buffer. This allows for skipping over data or positioning the serializer + //! at a specific location in the buffer. + //! + //! \param offset The offset to move the serialization pointer to + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus moveSerToOffset(FwSizeType offset) = 0; + + //! \brief Move deserialization pointer to specified offset + //! + //! This method moves the deserialization pointer to the specified offset within + //! the buffer. This allows for skipping over data or positioning the deserializer + //! at a specific location in the buffer. + //! + //! \param offset The offset to move the deserialization pointer to + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus moveDeserToOffset(FwSizeType offset) = 0; + + //! \brief Skip specified number of bytes during serialization + //! + //! This method advances the serialization pointer by the specified number of bytes + //! without writing any data. This can be used to reserve space in the buffer or skip + //! over data that will be written later. + //! + //! \param numBytesToSkip Number of bytes to skip during serialization + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus serializeSkip(FwSizeType numBytesToSkip) = 0; + + //! \brief Skip specified number of bytes during deserialization + //! + //! This method advances the deserialization pointer by the specified number of bytes + //! without reading any data. This can be used to skip over data in the buffer that + //! is not needed or to advance to the next relevant data segment. + //! + //! \param numBytesToSkip Number of bytes to skip during deserialization + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus deserializeSkip(FwSizeType numBytesToSkip) = 0; + + //! \brief Get buffer capacity + //! + //! This method returns the total capacity of the buffer, which is the maximum + //! amount of data that can be stored in the buffer. This is not the same as + //! the current size, which indicates how much data is currently in the buffer. + //! + //! \return The capacity of the buffer in bytes + virtual Serializable::SizeType getCapacity() const = 0; + + //! \brief Get current buffer size + //! + //! This method returns the current size of the buffer, which indicates how + //! much data is currently stored in the buffer. This may be less than or + //! equal to the buffer's capacity. + //! + //! \return The current size of the buffer in bytes + virtual Serializable::SizeType getSize() const = 0; + + //! \brief Get remaining deserialization buffer size + //! + //! This method returns the amount of data that remains to be deserialized + //! from the buffer. It indicates how much data is left starting from the + //! current deserialization pointer to the end of the valid size (returned by getSize()). + //! + //! \return The remaining size of the deserialization buffer in bytes + virtual Serializable::SizeType getDeserializeSizeLeft() const = 0; + + //! \brief Get remaining serialization buffer size + //! + //! This method returns the amount of space available for serialization + //! in the buffer. It indicates how much data can still be written to the + //! buffer starting from the current serialization pointer to the end of + //! the buffer's capacity. + //! + //! \return The remaining size of the serialization buffer in bytes + virtual Serializable::SizeType getSerializeSizeLeft() const = 0; + + //! \brief Set buffer contents from external source + //! + //! This method sets the contents of the buffer from an external source. + //! It copies the specified number of bytes from the source pointer into + //! the buffer and updates the buffer size accordingly. + //! + //! \param src Pointer to the external data source + //! \param length Number of bytes to copy from the source + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus setBuff(const U8* src, Serializable::SizeType length) = 0; + + //! \brief Set buffer length manually + //! + //! This method manually sets the length of the buffer without modifying + //! its contents. This can be used after filling the buffer with data through + //! other means to indicate how much valid data is in the buffer. + //! + //! \param length The new length to set for the buffer + //! \return SerializeStatus indicating the result of the operation + virtual SerializeStatus setBuffLen(Serializable::SizeType length) = 0; +}; + +class LinearBufferBase : public SerialBufferBase { + friend class SerializeBufferBaseTester; + + protected: + //! \brief Copy assignment operator + //! + //! Assigns the contents of another LinearBufferBase instance to this one. + //! This includes copying the buffer data, serialization location, and + //! deserialization location from the source to this instance. + //! + //! \param src Reference to the source LinearBufferBase to copy from + //! \return Reference to this instance after assignment + LinearBufferBase& operator=(const LinearBufferBase& src); + + public: + //! \brief Destructor + //! + //! Destroys a LinearBufferBase instance. This is a virtual destructor + //! that allows proper cleanup of derived classes. + virtual ~LinearBufferBase(); + + // Serialization for built-in types + + //! \brief Serialize an 8-bit unsigned integer value + //! + //! This method serializes a single 8-bit unsigned integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! NOTE: The 'mode' argument here for endianness has no effect as there is no + //! concept of endianness for an U8. It has been left in for compatibility. + //! + //! \param val The 8-bit unsigned integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(U8 val, Endianness mode = Endianness::BIG) override; + + //! \brief Serialize an 8-bit signed integer value + //! + //! This method serializes a single 8-bit signed integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! NOTE: The 'mode' argument here for endianness has no effect as there is no + //! concept of endianness for an I8. It has been left in for compatibility. + //! + //! \param val The 8-bit signed integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(I8 val, Endianness mode = Endianness::BIG) override; + +#if FW_HAS_16_BIT == 1 + //! \brief Serialize a 16-bit unsigned integer value + //! + //! This method serializes a single 16-bit unsigned integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 16-bit unsigned integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(U16 val, Endianness mode = Endianness::BIG) override; + + //! \brief Serialize a 16-bit signed integer value + //! + //! This method serializes a single 16-bit signed integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 16-bit signed integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(I16 val, Endianness mode = Endianness::BIG) override; +#endif +#if FW_HAS_32_BIT == 1 + //! \brief Serialize a 32-bit unsigned integer value + //! + //! This method serializes a single 32-bit unsigned integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 32-bit unsigned integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(U32 val, Endianness mode = Endianness::BIG) override; + + //! \brief Serialize a 32-bit signed integer value + //! + //! This method serializes a single 32-bit signed integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 32-bit signed integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(I32 val, Endianness mode = Endianness::BIG) override; +#endif +#if FW_HAS_64_BIT == 1 + //! \brief Serialize a 64-bit unsigned integer value + //! + //! This method serializes a single 64-bit unsigned integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 64-bit unsigned integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(U64 val, Endianness mode = Endianness::BIG) override; + + //! \brief Serialize a 64-bit signed integer value + //! + //! This method serializes a single 64-bit signed integer value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 64-bit signed integer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(I64 val, Endianness mode = Endianness::BIG) override; +#endif + //! \brief Serialize a 32-bit floating point value + //! + //! This method serializes a single 32-bit floating point value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 32-bit floating point value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(F32 val, Endianness mode = Endianness::BIG) override; + + //! \brief Serialize a 64-bit floating point value + //! + //! This method serializes a single 64-bit floating point value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The 64-bit floating point value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(F64 val, Endianness mode = Endianness::BIG) override; + + //! \brief Serialize a boolean value + //! + //! This method serializes a single boolean value into the buffer. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The boolean value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(bool val, Endianness mode = Endianness::BIG) override; + + //! \brief Serialize a pointer value + //! + //! This method serializes a pointer value into the buffer. Note that only + //! the pointer value itself is serialized, not the contents it points to. + //! The endianness of the serialization can be controlled via the mode parameter. + //! + //! \param val The pointer value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(const void* val, Endianness mode = Endianness::BIG) override; + + //! \brief Serialize a data buffer + //! + //! This method serializes a buffer of bytes into the serialization buffer. + //! The endianness of the serialization can be controlled via the endianMode parameter. + //! + //! \param buff Pointer to the buffer containing data to serialize + //! \param length Number of bytes to serialize from the buffer + //! \param endianMode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(const U8* buff, FwSizeType length, Endianness endianMode = Endianness::BIG) override; + + //! \brief Serialize a byte buffer with optional length prefix + //! + //! This method serializes a buffer of bytes into the serialization buffer. + //! If lengthMode is set to INCLUDE_LENGTH, the length is included as the first token. + //! The endianness of the serialization can be controlled via the endianMode parameter. + //! + //! \param buff Pointer to the buffer containing data to serialize + //! \param length Number of bytes to serialize from the buffer + //! \param lengthMode Specifies whether to include length in serialization (INCLUDE_LENGTH or OMIT_LENGTH) + //! \param endianMode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(const U8* buff, + FwSizeType length, + Serialization::t lengthMode, + Endianness endianMode = Endianness::BIG) override; + + //! \brief Serialize another LinearBufferBase object + //! + //! This method serializes the contents of another LinearBufferBase object + //! into this buffer. The endianness of the serialization can be controlled + //! via the mode parameter. + //! + //! \param val Reference to the LinearBufferBase object to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(const LinearBufferBase& val, Endianness mode = Endianness::BIG) override; + + //! \brief Serialize a Serializable object + //! + //! This method serializes an object derived from the Serializable base class + //! into this buffer. The endianness of the serialization can be controlled + //! via the mode parameter. + //! + //! \param val Reference to the Serializable object to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeFrom(const Serializable& val, Endianness mode = Endianness::BIG) override; + + //! \brief Serialize a size value + //! + //! This method serializes a size value (typically used for buffer sizes) + //! into this buffer. The endianness of the serialization can be controlled + //! via the mode parameter. + //! + //! \param size The size value to serialize + //! \param mode Endianness mode for serialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeSize(const FwSizeType size, Endianness mode = Endianness::BIG) override; + + // Deserialization for built-in types + + //! \brief Deserialize an 8-bit unsigned integer value + //! + //! This method reads an 8-bit unsigned integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 8-bit unsigned integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(U8& val, Endianness mode = Endianness::BIG) override; + + //! \brief Deserialize an 8-bit signed integer value + //! + //! This method reads an 8-bit signed integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 8-bit signed integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(I8& val, Endianness mode = Endianness::BIG) override; + +#if FW_HAS_16_BIT == 1 + //! \brief Deserialize a 16-bit unsigned integer value + //! + //! This method reads a 16-bit unsigned integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 16-bit unsigned integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(U16& val, Endianness mode = Endianness::BIG) override; + + //! \brief Deserialize a 16-bit signed integer value + //! + //! This method reads a 16-bit signed integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 16-bit signed integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(I16& val, Endianness mode = Endianness::BIG) override; +#endif + +#if FW_HAS_32_BIT == 1 + //! \brief Deserialize a 32-bit unsigned integer value + //! + //! This method reads a 32-bit unsigned integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 32-bit unsigned integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(U32& val, Endianness mode = Endianness::BIG) override; + + //! \brief Deserialize a 32-bit signed integer value + //! + //! This method reads a 32-bit signed integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 32-bit signed integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(I32& val, Endianness mode = Endianness::BIG) override; +#endif +#if FW_HAS_64_BIT == 1 + //! \brief Deserialize a 64-bit unsigned integer value + //! + //! This method reads a 64-bit unsigned integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 64-bit unsigned integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(U64& val, Endianness mode = Endianness::BIG) override; + + //! \brief Deserialize a 64-bit signed integer value + //! + //! This method reads a 64-bit signed integer value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 64-bit signed integer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(I64& val, Endianness mode = Endianness::BIG) override; +#endif + //! \brief Deserialize a 32-bit floating point value + //! + //! This method reads a 32-bit floating point value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 32-bit floating point value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(F32& val, Endianness mode = Endianness::BIG) override; + + //! \brief Deserialize a 64-bit floating point value + //! + //! This method reads a 64-bit floating point value from the deserialization + //! buffer and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized 64-bit floating point value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(F64& val, Endianness mode = Endianness::BIG) override; + + //! \brief Deserialize a boolean value + //! + //! This method reads a boolean value from the deserialization buffer + //! and stores it in the provided reference. The endianness of the + //! deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized boolean value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(bool& val, Endianness mode = Endianness::BIG) override; + + //! \brief Deserialize a pointer value + //! + //! This method reads a pointer value from the deserialization buffer + //! and stores it in the provided reference. Note that only the pointer + //! value itself is deserialized, not the contents it points to. The + //! endianness of the deserialization can be controlled via the mode parameter. + //! + //! \param val Reference to store the deserialized pointer value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(void*& val, Endianness mode = Endianness::BIG) override; + + //! \brief Deserialize a data buffer + //! + //! This method reads a buffer of bytes from the deserialization buffer + //! and stores them in the provided buffer. The endianness of the + //! deserialization can be controlled via the endianMode parameter. + //! + //! \param buff Pointer to the buffer where deserialized data will be stored + //! \param length Reference to store the actual number of bytes deserialized + //! \param endianMode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(U8* buff, FwSizeType& length, Endianness endianMode = Endianness::BIG) override; + + //! \brief Deserialize a byte buffer with optional length prefix + //! + //! This method reads a buffer of bytes from the deserialization buffer + //! and stores them in the provided buffer. If lengthMode indicates that + //! a length prefix was included, it will be read from the buffer first. + //! The endianness of the deserialization can be controlled via the + //! endianMode parameter. + //! + //! \param buff Pointer to the buffer where deserialized data will be stored + //! \param length Reference to store the actual number of bytes deserialized + //! \param lengthMode Specifies whether length was included in serialization (INCLUDE_LENGTH or OMIT_LENGTH) + //! \param endianMode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation SerializeStatus deserializeTo(U8* buff, FwSizeType& length, Serialization::t lengthMode, - Endianness endianMode = Endianness::BIG); + Endianness endianMode = Endianness::BIG) override; - SerializeStatus deserializeTo( - Serializable& val, - Endianness mode = Endianness::BIG); //!< deserialize an object derived from serializable base class + //! \brief Deserialize a Serializable object + //! + //! This method reads data from the deserialization buffer and reconstructs + //! a Serializable object from it. The endianness of the deserialization + //! can be controlled via the mode parameter. + //! + //! \param val Reference to the Serializable object that will be populated with deserialized data + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(Serializable& val, Endianness mode = Endianness::BIG) override; - SerializeStatus deserializeTo(SerializeBufferBase& val, - Endianness mode = Endianness::BIG); //!< serialize a serialized buffer + //! \brief Deserialize a LinearBufferBase object + //! + //! This method reads data from the deserialization buffer and reconstructs + //! a LinearBufferBase object from it. The endianness of the deserialization + //! can be controlled via the mode parameter. + //! + //! \param val Reference to the LinearBufferBase object that will be populated with deserialized data + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeTo(LinearBufferBase& val, Endianness mode = Endianness::BIG) override; - SerializeStatus deserializeSize(FwSizeType& size, Endianness mode = Endianness::BIG); //!< deserialize a size value + //! \brief Deserialize a size value + //! + //! This method reads a size value (typically used for buffer sizes) + //! from the deserialization buffer. The endianness of the deserialization + //! can be controlled via the mode parameter. + //! + //! \param size Reference to store the deserialized size value + //! \param mode Endianness mode for deserialization (default is Endianness::BIG) + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeSize(FwSizeType& size, Endianness mode = Endianness::BIG) override; + + DEPRECATED(SerializeStatus serialize(const LinearBufferBase& val), + "Use serializeFrom(const SerialBufferBase& val) instead"); + DEPRECATED(SerializeStatus deserialize(LinearBufferBase& val), "Use deserializeTo(SerialBufferBase& val) instead"); + + //! \brief Reset serialization pointer to beginning of buffer + //! + //! This method resets the serialization pointer to the beginning of the buffer, + //! allowing the buffer to be reused for new serialization operations. Any + //! data that was previously serialized in the buffer will be overwritten. + //! + //! \return None + void resetSer() override; + + //! \brief Reset deserialization pointer to beginning of buffer + //! + //! This method resets the deserialization pointer to the beginning of the buffer, + //! allowing the buffer to be reused for new deserialization operations. The buffer + //! contents are not modified, but the pointer is reset to allow reading from the + //! start of the data. + //! + //! \return None + void resetDeser() override; + + //! \brief Move serialization pointer to specified offset + //! + //! This method moves the serialization pointer to the specified offset within + //! the buffer. This allows for skipping over data or positioning the serializer + //! at a specific location in the buffer. + //! + //! \param offset The offset to move the serialization pointer to + //! \return SerializeStatus indicating the result of the operation + SerializeStatus moveSerToOffset(FwSizeType offset) override; + + //! \brief Move deserialization pointer to specified offset + //! + //! This method moves the deserialization pointer to the specified offset within + //! the buffer. This allows for skipping over data or positioning the deserializer + //! at a specific location in the buffer. + //! + //! \param offset The offset to move the deserialization pointer to + //! \return SerializeStatus indicating the result of the operation + SerializeStatus moveDeserToOffset(FwSizeType offset) override; + + //! \brief Skip specified number of bytes during serialization + //! + //! This method advances the serialization pointer by the specified number of bytes + //! without writing any data. This can be used to reserve space in the buffer or skip + //! over data that will be written later. + //! + //! \param numBytesToSkip Number of bytes to skip during serialization + //! \return SerializeStatus indicating the result of the operation + SerializeStatus serializeSkip(FwSizeType numBytesToSkip) override; + + //! \brief Skip specified number of bytes during deserialization + //! + //! This method advances the deserialization pointer by the specified number of bytes + //! without reading any data. This can be used to skip over data in the buffer that + //! is not needed or to advance to the next relevant data segment. + //! + //! \param numBytesToSkip Number of bytes to skip during deserialization + //! \return SerializeStatus indicating the result of the operation + SerializeStatus deserializeSkip(FwSizeType numBytesToSkip) override; + + DEPRECATED(Serializable::SizeType getBuffCapacity() const, "Use getCapacity() instead"); + DEPRECATED(Serializable::SizeType getBuffLength() const, "Use getSize() instead"); + DEPRECATED(Serializable::SizeType getBuffLeft(), "Use getDeserializeSizeLeft() instead"); + + //! \brief Get buffer capacity + //! + //! This method returns the total capacity of the buffer, which is the maximum + //! amount of data that can be stored in the buffer. This is not the same as + //! the current size, which indicates how much data is currently in the buffer. + //! + //! \return The capacity of the buffer in bytes + Serializable::SizeType getCapacity() const override = 0; + + //! \brief Get current buffer size + //! + //! This method returns the current size of the buffer, which indicates how + //! much data is currently stored in the buffer. This may be less than or + //! equal to the buffer's capacity. + //! + //! \return The current size of the buffer in bytes + Serializable::SizeType getSize() const override; + + //! \brief Get remaining deserialization buffer size + //! + //! This method returns the amount of data that remains to be deserialized + //! from the buffer. It indicates how much data is left starting from the + //! current deserialization pointer to the end of the buffer. + //! + //! \return The remaining size of the deserialization buffer in bytes + Serializable::SizeType getDeserializeSizeLeft() const override; + + //! \brief Get remaining serialization buffer size + //! + //! This method returns the amount of space available for serialization + //! in the buffer. It indicates how much data can still be written to the + //! buffer starting from the current serialization pointer to the end of + //! the buffer's capacity. + //! + //! \return The remaining size of the serialization buffer in bytes + Serializable::SizeType getSerializeSizeLeft() const override; + + //! \brief Get buffer address for data filling (non-const version) + //! + //! This method returns a pointer to the buffer's data area where data can + //! be written. This is the non-const version of the method, allowing the + //! buffer contents to be modified. + //! + //! \return Pointer to the buffer's data area + virtual U8* getBuffAddr() = 0; + + //! \brief Get buffer address for data reading (const version) + //! + //! This method returns a const pointer to the buffer's data area where data + //! can be read. This is the const version of the method, preventing modification + //! of the buffer contents. + //! + //! \return Const pointer to the buffer's data area + virtual const U8* getBuffAddr() const = 0; + + //! \brief Get address of remaining non-deserialized data + //! + //! This method returns a const pointer to the portion of the buffer that + //! has not yet been deserialized. This can be used to examine remaining + //! data or to determine how much data is left to process. + //! + //! \return Const pointer to the remaining non-deserialized data + const U8* getBuffAddrLeft() const; + + //! \brief Get address of end of serialization (DANGEROUS!) + //! + //! This method returns a pointer to the current end of serialized data + //! in the buffer. This is a dangerous operation as it requires knowledge + //! of the maximum buffer size and proper adjustment when done. + //! + //! \return Pointer to the end of serialized data + U8* getBuffAddrSer(); + + //! \brief Set buffer contents from external source + //! + //! This method sets the contents of the buffer from an external source. + //! It copies the specified number of bytes from the source pointer into + //! the buffer and updates the buffer size accordingly. + //! + //! \param src Pointer to the external data source + //! \param length Number of bytes to copy from the source + //! \return SerializeStatus indicating the result of the operation + SerializeStatus setBuff(const U8* src, Serializable::SizeType length) override; + + //! \brief Set buffer length manually + //! + //! This method manually sets the length of the buffer without modifying + //! its contents. This can be used after filling the buffer with data through + //! other means to indicate how much valid data is in the buffer. + //! + //! \param length The new length to set for the buffer + //! \return SerializeStatus indicating the result of the operation + SerializeStatus setBuffLen(Serializable::SizeType length) override; + + //! \brief Copy raw bytes from this buffer to destination and advance source offset + //! + //! This method copies exactly `size` bytes from the current position in this + //! buffer to the destination buffer. It advances the source buffer's position + //! by the number of bytes copied. + //! + //! \param dest Destination buffer to receive the copied data + //! \param size Number of bytes to copy + //! \return SerializeStatus indicating the result of the operation + SerializeStatus copyRaw(SerialBufferBase& dest, Serializable::SizeType size) override; + + //! \brief Append raw bytes to destination from this buffer and advance source offset + //! + //! This method appends exactly `size` bytes from the current position in this + //! buffer to the destination buffer. It uses `Serialization::OMIT_LENGTH` mode, + //! meaning no length token is written. The source buffer's position is advanced + //! by the number of bytes copied. + //! + //! \param dest Destination buffer to append data to + //! \param size Number of bytes to append + //! \return SerializeStatus indicating the result of the operation + SerializeStatus copyRawOffset(SerialBufferBase& dest, Serializable::SizeType size) override; // ---------------------------------------------------------------------- - // Serialization methods + // Deprecated Serialization methods // ---------------------------------------------------------------------- DEPRECATED(SerializeStatus serialize(U8 val), "Use serializeFrom(U8 val) instead"); @@ -217,8 +1294,6 @@ class SerializeBufferBase { "Use serializeFrom(const U8* buff, FwSizeType length, Serialization::t mode) instead"); DEPRECATED(SerializeStatus serialize(const Serializable& val), "Use serializeFrom(const Serializable& val) instead"); - DEPRECATED(SerializeStatus serialize(const SerializeBufferBase& val), - "Use serializeFrom(const SerializeBufferBase& val) instead"); DEPRECATED(SerializeStatus deserialize(U8& val), "Use deserializeTo(U8& val) instead"); DEPRECATED(SerializeStatus deserialize(I8& val), "Use deserializeTo(I8& val) instead"); @@ -246,76 +1321,154 @@ class SerializeBufferBase { DEPRECATED(SerializeStatus deserialize(U8* buff, FwSizeType& length, Serialization::t mode), "Use deserializeTo(U8* buff, FwSizeType& length, Serialization::t mode) instead"); DEPRECATED(SerializeStatus deserialize(Serializable& val), "Use deserializeTo(Serializable& val) instead"); - DEPRECATED(SerializeStatus deserialize(SerializeBufferBase& val), - "Use deserializeTo(SerializeBufferBase& val) instead"); - - void resetSer(); //!< reset to beginning of buffer to reuse for serialization - void resetDeser(); //!< reset deserialization to beginning - - SerializeStatus moveSerToOffset(FwSizeType offset); //!< Moves serialization to the specified offset - SerializeStatus moveDeserToOffset(FwSizeType offset); //!< Moves deserialization to the specified offset - - SerializeStatus serializeSkip( - FwSizeType numBytesToSkip); //!< Skips the number of specified bytes for serialization - SerializeStatus deserializeSkip( - FwSizeType numBytesToSkip); //!< Skips the number of specified bytes for deserialization - virtual Serializable::SizeType getBuffCapacity() const = 0; //!< returns capacity, not current size, of buffer - Serializable::SizeType getBuffLength() const; //!< returns current buffer size - Serializable::SizeType getBuffLeft() const; //!< returns how much deserialization buffer is left - virtual U8* getBuffAddr() = 0; //!< gets buffer address for data filling - virtual const U8* getBuffAddr() const = 0; //!< gets buffer address for data reading, const version - const U8* getBuffAddrLeft() const; //!< gets address of remaining non-deserialized data. - U8* getBuffAddrSer(); //!< gets address of end of serialization. DANGEROUS! Need to know max buffer size and adjust - //!< when done - SerializeStatus setBuff(const U8* src, Serializable::SizeType length); //!< sets buffer contents and size - SerializeStatus setBuffLen(Serializable::SizeType length); //!< sets buffer length manually after filling with data - SerializeStatus copyRaw( - SerializeBufferBase& dest, - Serializable::SizeType size); //!< directly copies buffer without looking for a size in the stream. - // Will increment deserialization pointer - SerializeStatus copyRawOffset( - SerializeBufferBase& dest, - Serializable::SizeType size); //!< directly copies buffer without looking for a size in the stream. - // Will increment deserialization pointer #ifdef BUILD_UT - bool operator==(const SerializeBufferBase& other) const; - friend std::ostream& operator<<(std::ostream& os, const SerializeBufferBase& buff); + //! \brief Equality comparison operator + //! + //! Compares this LinearBufferBase instance with another for equality. + //! Two buffers are considered equal if they have the same contents and size. + //! + //! \param other Reference to the other LinearBufferBase instance to compare with + //! \return true if the buffers are equal, false otherwise + bool operator==(const LinearBufferBase& other) const; + + //! \brief Stream insertion operator for LinearBufferBase + //! + //! Allows a LinearBufferBase instance to be output to a stream (e.g., for debugging). + //! This provides a human-readable representation of the buffer's contents. + //! + //! \param os Reference to the output stream + //! \param buff Reference to the LinearBufferBase instance to output + //! \return Reference to the output stream + friend std::ostream& operator<<(std::ostream& os, const LinearBufferBase& buff); #endif protected: - SerializeBufferBase(); //!< default constructor + //! \brief Default constructor + //! + //! Initializes a LinearBufferBase instance with default values. + //! Sets the serialization and deserialization locations to zero. + LinearBufferBase(); + + //! \brief Copy constructor (protected) + //! + //! Creates a copy of another LinearBufferBase instance. This constructor + //! is protected and intended for use only by derived classes or internal + //! implementation details. + //! + //! \param src Reference to the source LinearBufferBase to copy from + LinearBufferBase(const LinearBufferBase& src); + + //! \brief Copy data from source buffer + //! + //! Copies the contents from another LinearBufferBase instance to this one. + //! This includes copying the buffer data, serialization location, and + //! deserialization location. + //! + //! \param src Reference to the source LinearBufferBase to copy data from + void copyFrom(const LinearBufferBase& src); + Serializable::SizeType m_serLoc; //!< current offset in buffer of serialized data Serializable::SizeType m_deserLoc; //!< current offset for deserialization private: - // Copy constructor can be used only by the implementation - SerializeBufferBase(const SerializeBufferBase& src); //!< constructor with buffer as source - - void copyFrom(const SerializeBufferBase& src); //!< copy data from source buffer }; // Helper classes for building buffers with external storage -//! External serialize buffer with no copy semantics -class ExternalSerializeBuffer : public SerializeBufferBase { +//! \brief External serialize buffer with no copy semantics +//! +//! This class provides a serialization buffer that uses an external buffer +//! without copying data. It is designed for scenarios where you want to avoid +//! data copying for performance reasons and are willing to manage the buffer +//! lifetime manually. +//! +//! \note The external buffer must remain valid for the lifetime of the +//! ExternalSerializeBuffer instance. The class does not take ownership of +//! the buffer or copy its contents. +class ExternalSerializeBuffer : public LinearBufferBase { public: - ExternalSerializeBuffer(U8* buffPtr, Serializable::SizeType size); //!< construct with external buffer - ExternalSerializeBuffer(); //!< default constructor - ~ExternalSerializeBuffer() {} //!< destructor - //! Set the external buffer - //! This action also resets the serialization and deserialization pointers - void setExtBuffer(U8* buffPtr, Serializable::SizeType size); - void clear(); //!< clear external buffer - ExternalSerializeBuffer(const ExternalSerializeBuffer& src) = delete; //!< deleted copy constructor + //! \brief Construct with external buffer + //! + //! Creates an ExternalSerializeBuffer instance that uses the provided + //! external buffer. The buffer must remain valid for the lifetime of + //! this instance. + //! + //! \param buffPtr Pointer to the external buffer + //! \param size Size of the external buffer in bytes + ExternalSerializeBuffer(U8* buffPtr, Serializable::SizeType size); - // pure virtual functions - Serializable::SizeType getBuffCapacity() const; + //! \brief Default constructor + //! + //! Creates an ExternalSerializeBuffer instance without an external buffer. + //! The buffer must be set later using setExtBuffer(). + ExternalSerializeBuffer(); + + //! \brief Destructor + //! + //! Destroys the ExternalSerializeBuffer instance. Note that this does + //! not free the external buffer if one was set. + ~ExternalSerializeBuffer() {} + + //! \brief Set the external buffer + //! + //! Sets a new external buffer for this instance. This action also resets + //! the serialization and deserialization pointers to the beginning of + //! the new buffer. + //! + //! \param buffPtr Pointer to the new external buffer + //! \param size Size of the new external buffer in bytes + void setExtBuffer(U8* buffPtr, Serializable::SizeType size); + + //! \brief Clear external buffer + //! + //! Clears the external buffer reference. After calling this method, + //! the buffer is effectively empty and cannot be used for serialization + //! or deserialization until a new buffer is set. + void clear(); + + //! \brief Deleted copy constructor + //! + //! The copy constructor is deleted to prevent copying instances of + //! ExternalSerializeBuffer, as this could lead to issues with buffer + //! management. + ExternalSerializeBuffer(const ExternalSerializeBuffer& src) = delete; + + DEPRECATED(Serializable::SizeType getBuffCapacity() const, "Use getCapacity() instead"); + + //! \brief Get buffer capacity + //! + //! This method returns the total capacity of the buffer, which is the maximum + //! amount of data that can be stored in the buffer. This is not the same as + //! the current size, which indicates how much data is currently in the buffer. + //! + //! \return The capacity of the buffer in bytes + Serializable::SizeType getCapacity() const; + + //! \brief Get buffer address for data filling (non-const version) + //! + //! This method returns a pointer to the buffer's data area where data can + //! be written. This is the non-const version of the method, allowing the + //! buffer contents to be modified. + //! + //! \return Pointer to the buffer's data area U8* getBuffAddr(); + + //! \brief Get buffer address for data reading (const version) + //! + //! This method returns a const pointer to the buffer's data area where data + //! can be read. This is the const version of the method, preventing modification + //! of the buffer contents. + //! + //! \return Const pointer to the buffer's data area const U8* getBuffAddr() const; - //! deleted copy assignment operator - ExternalSerializeBuffer& operator=(const SerializeBufferBase& src) = delete; + //! \brief Deleted copy assignment operator + //! + //! The copy assignment operator is deleted to prevent copying instances of + //! ExternalSerializeBuffer, as this could lead to issues with buffer + //! management. + ExternalSerializeBuffer& operator=(const LinearBufferBase& src) = delete; protected: // data members @@ -323,39 +1476,118 @@ class ExternalSerializeBuffer : public SerializeBufferBase { Serializable::SizeType m_buffSize; //!< size of external buffer }; -//! External serialize buffer with data copy semantics +//! \brief External serialize buffer with data copy semantics //! -//! Use this when the object esb on the left-hand side of an assignment esb = sbb -//! is guaranteed to have a valid buffer +//! This class provides a serialization buffer that uses an external buffer +//! and performs data copying during assignment operations. It is designed +//! for scenarios where you want to ensure that the buffer always contains +//! valid data and are willing to pay the performance cost of copying. +//! +//! \note This class should be used when the object on the left-hand side of +//! an assignment (esb = sbb) is guaranteed to have a valid buffer. +//! +//! \see ExternalSerializeBuffer for a version without data copying class ExternalSerializeBufferWithDataCopy final : public ExternalSerializeBuffer { public: + //! \brief Construct with external buffer + //! + //! Creates an ExternalSerializeBufferWithDataCopy instance that uses the + //! provided external buffer. + //! + //! \param buffPtr Pointer to the external buffer + //! \param size Size of the external buffer in bytes ExternalSerializeBufferWithDataCopy(U8* buffPtr, Serializable::SizeType size) : ExternalSerializeBuffer(buffPtr, size) {} + + //! \brief Default constructor + //! + //! Creates an ExternalSerializeBufferWithDataCopy instance without an + //! external buffer. The buffer must be set later using setExtBuffer(). ExternalSerializeBufferWithDataCopy() : ExternalSerializeBuffer() {} + + //! \brief Destructor + //! + //! Destroys the ExternalSerializeBufferWithDataCopy instance. ~ExternalSerializeBufferWithDataCopy() {} - ExternalSerializeBufferWithDataCopy(const SerializeBufferBase& src) = delete; - ExternalSerializeBufferWithDataCopy& operator=(SerializeBufferBase& src) { - (void)SerializeBufferBase::operator=(src); + + //! \brief Deleted copy constructor + //! + //! The copy constructor is deleted to prevent copying instances of + //! ExternalSerializeBufferWithDataCopy, as this could lead to issues + //! with buffer management. + ExternalSerializeBufferWithDataCopy(const LinearBufferBase& src) = delete; + + //! \brief Copy assignment operator with data copying + //! + //! This assignment operator copies data from the source buffer to the + //! destination buffer. It ensures that the destination buffer always + //! contains valid data after the assignment. + //! + //! \param src Reference to the source buffer to copy data from + //! \return Reference to this instance + ExternalSerializeBufferWithDataCopy& operator=(LinearBufferBase& src) { + (void)LinearBufferBase::operator=(src); return *this; } }; -//! External serialize buffer with member copy semantics +//! \brief External serialize buffer with member copy semantics //! -//! Use this when the object esb1 on the left-hand side of an assignment esb1 = esb2 -//! has an invalid buffer, and you want to move the buffer of esb2 into it. -//! In this case there should usually be no more uses of esb2 after the assignment. +//! This class provides a serialization buffer that uses an external buffer +//! and performs member copying during assignment operations. It is designed +//! for scenarios where you want to move data between buffers efficiently. +//! +//! \note This class should be used when the object on the left-hand side of +//! an assignment (esb1 = esb2) has an invalid buffer, and you want to move +//! the buffer of esb2 into it. In this case, there should usually be no more +//! uses of esb2 after the assignment. +//! +//! \see ExternalSerializeBuffer for a version without data copying +//! \see ExternalSerializeBufferWithDataCopy for a version with data copying class ExternalSerializeBufferWithMemberCopy final : public ExternalSerializeBuffer { public: + //! \brief Construct with external buffer + //! + //! Creates an ExternalSerializeBufferWithMemberCopy instance that uses the + //! provided external buffer. + //! + //! \param buffPtr Pointer to the external buffer + //! \param size Size of the external buffer in bytes ExternalSerializeBufferWithMemberCopy(U8* buffPtr, Serializable::SizeType size) : ExternalSerializeBuffer(buffPtr, size) {} + + //! \brief Default constructor + //! + //! Creates an ExternalSerializeBufferWithMemberCopy instance without an + //! external buffer. The buffer must be set later using setExtBuffer(). ExternalSerializeBufferWithMemberCopy() : ExternalSerializeBuffer() {} + + //! \brief Destructor + //! + //! Destroys the ExternalSerializeBufferWithMemberCopy instance. ~ExternalSerializeBufferWithMemberCopy() {} + + //! \brief Copy constructor with member copying + //! + //! This constructor copies members from the source instance, including + //! the buffer pointer, size, serialization location, and deserialization + //! location. + //! + //! \param src Reference to the source instance to copy from ExternalSerializeBufferWithMemberCopy(const ExternalSerializeBufferWithMemberCopy& src) : ExternalSerializeBuffer(src.m_buff, src.m_buffSize) { this->m_serLoc = src.m_serLoc; this->m_deserLoc = src.m_deserLoc; } + + //! \brief Copy assignment operator with member copying + //! + //! This assignment operator copies members from the source instance, + //! including the buffer pointer, size, serialization location, and + //! deserialization location. It guards against self-assignment. + //! + //! \param src Reference to the source instance to copy from + //! \return Reference to this instance ExternalSerializeBufferWithMemberCopy& operator=(const ExternalSerializeBufferWithMemberCopy& src) { // Ward against self-assignment if (this != &src) { diff --git a/Fw/Types/StringBase.cpp b/Fw/Types/StringBase.cpp index bf74f5803d..55c08f4944 100644 --- a/Fw/Types/StringBase.cpp +++ b/Fw/Types/StringBase.cpp @@ -139,17 +139,17 @@ StringBase::SizeType StringBase::serializedTruncatedSize(FwSizeType maxLength) c return static_cast(sizeof(FwSizeStoreType)) + static_cast(FW_MIN(this->length(), maxLength)); } -SerializeStatus StringBase::serializeTo(SerializeBufferBase& buffer, Fw::Endianness mode) const { +SerializeStatus StringBase::serializeTo(SerialBufferBase& buffer, Fw::Endianness mode) const { return buffer.serializeFrom(reinterpret_cast(this->toChar()), this->length()); } -SerializeStatus StringBase::serializeTo(SerializeBufferBase& buffer, SizeType maxLength, Fw::Endianness mode) const { +SerializeStatus StringBase::serializeTo(SerialBufferBase& buffer, SizeType maxLength, Fw::Endianness mode) const { const FwSizeType len = FW_MIN(maxLength, this->length()); // Serialize length and then bytes return buffer.serializeFrom(reinterpret_cast(this->toChar()), len, Serialization::INCLUDE_LENGTH); } -SerializeStatus StringBase::deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode) { +SerializeStatus StringBase::deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode) { // Get the max size of the deserialized string const SizeType maxSize = this->maxLength(); // Initial estimate of actual size is max size diff --git a/Fw/Types/StringBase.hpp b/Fw/Types/StringBase.hpp index b31248634c..4341e33da1 100644 --- a/Fw/Types/StringBase.hpp +++ b/Fw/Types/StringBase.hpp @@ -66,18 +66,18 @@ class StringBase : public Serializable { FormatStatus format(const CHAR* formatString, ...); //!< write formatted string to buffer FormatStatus vformat(const CHAR* formatString, va_list args); //!< write formatted string to buffer using va_list - SerializeStatus serializeTo(SerializeBufferBase& buffer, Endianness mode = Endianness::BIG) const override; - virtual SerializeStatus serializeTo(SerializeBufferBase& buffer, + SerializeStatus serializeTo(SerialBufferBase& buffer, Endianness mode = Endianness::BIG) const override; + virtual SerializeStatus serializeTo(SerialBufferBase& buffer, SizeType maxLen, Endianness mode = Endianness::BIG) const; - SerializeStatus deserializeFrom(SerializeBufferBase& buffer, Endianness mode = Endianness::BIG) override; + SerializeStatus deserializeFrom(SerialBufferBase& buffer, Endianness mode = Endianness::BIG) override; - DEPRECATED(SerializeStatus serialize(SerializeBufferBase& buffer) const, + DEPRECATED(SerializeStatus serialize(SerialBufferBase& buffer) const, "Use serializeTo(SerializeBufferBase& buffer) instead") { return this->serializeTo(buffer); } - DEPRECATED(SerializeStatus serialize(SerializeBufferBase& buffer, SizeType maxLen) const, + DEPRECATED(SerializeStatus serialize(SerialBufferBase& buffer, SizeType maxLen) const, "Use serializeTo(SerializeBufferBase& buffer, SizeType maxLen) instead") { return this->serializeTo(buffer, maxLen); } diff --git a/Fw/Types/test/ut/ExternalSerializeBufferTest.cpp b/Fw/Types/test/ut/ExternalSerializeBufferTest.cpp index 5d91b26299..35ded9aa78 100644 --- a/Fw/Types/test/ut/ExternalSerializeBufferTest.cpp +++ b/Fw/Types/test/ut/ExternalSerializeBufferTest.cpp @@ -12,37 +12,37 @@ constexpr SizeType BUFFER_SIZE = 10; U8 buffer[BUFFER_SIZE]; void serializeOK(Fw::ExternalSerializeBuffer& esb) { - const SizeType buffCapacity = esb.getBuffCapacity(); - ASSERT_EQ(esb.getBuffLength(), 0); + const SizeType buffCapacity = esb.getCapacity(); + ASSERT_EQ(esb.getSize(), 0); for (SizeType i = 0; i < buffCapacity; i++) { const U8 value = static_cast(i); const Fw::SerializeStatus status = esb.serializeFrom(value); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); } - ASSERT_EQ(esb.getBuffLength(), buffCapacity); + ASSERT_EQ(esb.getSize(), buffCapacity); } void serializeFail(Fw::ExternalSerializeBuffer& esb) { - ASSERT_EQ(esb.getBuffLength(), esb.getBuffCapacity()); + ASSERT_EQ(esb.getSize(), esb.getCapacity()); const Fw::SerializeStatus status = esb.serializeFrom(static_cast(0)); ASSERT_EQ(status, Fw::FW_SERIALIZE_NO_ROOM_LEFT); } void deserializeOK(Fw::ExternalSerializeBuffer& esb) { - const SizeType buffCapacity = esb.getBuffCapacity(); - ASSERT_EQ(esb.getBuffLeft(), buffCapacity); + const SizeType buffCapacity = esb.getCapacity(); + ASSERT_EQ(esb.getDeserializeSizeLeft(), buffCapacity); for (SizeType i = 0; i < buffCapacity; i++) { U8 value = 0; const Fw::SerializeStatus status = esb.deserializeTo(value); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); ASSERT_EQ(value, static_cast(i)); } - ASSERT_EQ(esb.getBuffLeft(), 0); + ASSERT_EQ(esb.getDeserializeSizeLeft(), 0); } void deserializeFail(Fw::ExternalSerializeBuffer& esb) { U8 value = 0; - ASSERT_EQ(esb.getBuffLeft(), 0); + ASSERT_EQ(esb.getDeserializeSizeLeft(), 0); const Fw::SerializeStatus status = esb.deserializeTo(value); ASSERT_EQ(status, Fw::FW_DESERIALIZE_BUFFER_EMPTY); } diff --git a/Fw/Types/test/ut/TypesTest.cpp b/Fw/Types/test/ut/TypesTest.cpp index aea40a293a..877b3a29a7 100644 --- a/Fw/Types/test/ut/TypesTest.cpp +++ b/Fw/Types/test/ut/TypesTest.cpp @@ -30,7 +30,7 @@ class SerializeTestBuffer : public Fw::SerializeBufferBase { public: - FwSizeType getBuffCapacity() const { // !< returns capacity, not current size, of buffer + FwSizeType getCapacity() const { // !< returns capacity, not current size, of buffer return sizeof(m_testBuff); } @@ -887,7 +887,7 @@ struct TestStruct { class MySerializable : public Fw::Serializable { public: - Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase& buffer, + Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override { buffer.serializeFrom(m_testStruct.m_u32, mode); buffer.serializeFrom(m_testStruct.m_u16, mode); @@ -897,7 +897,7 @@ class MySerializable : public Fw::Serializable { return Fw::FW_SERIALIZE_OK; } - Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase& buffer, + Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override { buffer.serializeFrom(m_testStruct.m_buff, sizeof(m_testStruct.m_buff)); buffer.serializeFrom(m_testStruct.m_f32, mode); diff --git a/Os/Posix/RawTime.cpp b/Os/Posix/RawTime.cpp index 6b452b16ee..7b56a0e3ff 100644 --- a/Os/Posix/RawTime.cpp +++ b/Os/Posix/RawTime.cpp @@ -44,7 +44,7 @@ PosixRawTime::Status PosixRawTime::getTimeInterval(const Os::RawTime& other, Fw: return Status::OP_OK; } -Fw::SerializeStatus PosixRawTime::serializeTo(Fw::SerializeBufferBase& buffer, Fw::Endianness mode) const { +Fw::SerializeStatus PosixRawTime::serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode) const { static_assert(PosixRawTime::SERIALIZED_SIZE >= 2 * sizeof(U32), "PosixRawTime implementation requires at least 2*sizeof(U32) serialization size"); Fw::SerializeStatus status = buffer.serializeFrom(static_cast(this->m_handle.m_timespec.tv_sec), mode); @@ -54,7 +54,7 @@ Fw::SerializeStatus PosixRawTime::serializeTo(Fw::SerializeBufferBase& buffer, F return buffer.serializeFrom(static_cast(this->m_handle.m_timespec.tv_nsec), mode); } -Fw::SerializeStatus PosixRawTime::deserializeFrom(Fw::SerializeBufferBase& buffer, Fw::Endianness mode) { +Fw::SerializeStatus PosixRawTime::deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode) { static_assert(PosixRawTime::SERIALIZED_SIZE >= 2 * sizeof(U32), "PosixRawTime implementation requires at least 2*sizeof(U32) serialization size"); U32 sec = 0; diff --git a/Os/Posix/RawTime.hpp b/Os/Posix/RawTime.hpp index 436f45f73b..48478bd68f 100644 --- a/Os/Posix/RawTime.hpp +++ b/Os/Posix/RawTime.hpp @@ -65,7 +65,7 @@ class PosixRawTime : public RawTimeInterface { //! //! \param buffer The buffer to serialize the contents into. //! \return Fw::SerializeStatus indicating the result of the serialization. - Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase& buffer, + Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override; //! \brief Deserialize the contents of the RawTimeInterface object from a buffer. @@ -80,7 +80,7 @@ class PosixRawTime : public RawTimeInterface { //! //! \param buffer The buffer to deserialize the contents from. //! \return Fw::SerializeStatus indicating the result of the deserialization. - Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase& buffer, + Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override; private: diff --git a/Os/Queue.cpp b/Os/Queue.cpp index 8d881f3e60..247a44efba 100644 --- a/Os/Queue.cpp +++ b/Os/Queue.cpp @@ -93,19 +93,19 @@ QueueHandle* Queue::getHandle() { return this->m_delegate.getHandle(); } -QueueInterface::Status Queue::send(const Fw::SerializeBufferBase& message, +QueueInterface::Status Queue::send(const Fw::LinearBufferBase& message, FwQueuePriorityType priority, QueueInterface::BlockingType blockType) { - return this->send(message.getBuffAddr(), message.getBuffLength(), priority, blockType); + return this->send(message.getBuffAddr(), message.getSize(), priority, blockType); } -QueueInterface::Status Queue::receive(Fw::SerializeBufferBase& destination, +QueueInterface::Status Queue::receive(Fw::LinearBufferBase& destination, QueueInterface::BlockingType blockType, FwQueuePriorityType& priority) { FwSizeType actualSize = 0; destination.resetSer(); // Reset the buffer QueueInterface::Status status = - this->receive(destination.getBuffAddrSer(), destination.getBuffCapacity(), blockType, actualSize, priority); + this->receive(destination.getBuffAddrSer(), destination.getCapacity(), blockType, actualSize, priority); if (status == QueueInterface::Status::OP_OK) { Fw::SerializeStatus serializeStatus = destination.setBuffLen(static_cast(actualSize)); diff --git a/Os/Queue.hpp b/Os/Queue.hpp index aa861e83fb..5e4733beb4 100644 --- a/Os/Queue.hpp +++ b/Os/Queue.hpp @@ -248,7 +248,7 @@ class Queue final : public QueueInterface { //! \param priority: priority of the message //! \param blockType: BLOCKING to block for space or NONBLOCKING to return error when queue is full //! \return status of the send - Status send(const Fw::SerializeBufferBase& message, FwQueuePriorityType priority, BlockingType blockType); + Status send(const Fw::LinearBufferBase& message, FwQueuePriorityType priority, BlockingType blockType); //! \brief receive a message from a queue //! @@ -261,7 +261,7 @@ class Queue final : public QueueInterface { //! \param priority: (output) priority of the message //! \param blockType: BLOCKING to block for space or NONBLOCKING to return error when queue is full //! \return status of the send - Status receive(Fw::SerializeBufferBase& destination, BlockingType blockType, FwQueuePriorityType& priority); + Status receive(Fw::LinearBufferBase& destination, BlockingType blockType, FwQueuePriorityType& priority); //! \brief get the queue's depth in messages FwSizeType getDepth() const; diff --git a/Os/RawTime.cpp b/Os/RawTime.cpp index b891495b4e..06d6b1f39d 100644 --- a/Os/RawTime.cpp +++ b/Os/RawTime.cpp @@ -43,12 +43,12 @@ RawTime::Status RawTime::getTimeInterval(const Os::RawTime& other, Fw::TimeInter return this->m_delegate.getTimeInterval(other, result); } -Fw::SerializeStatus RawTime::serializeTo(Fw::SerializeBufferBase& buffer, Fw::Endianness mode) const { +Fw::SerializeStatus RawTime::serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode) const { FW_ASSERT(&this->m_delegate == reinterpret_cast(&this->m_handle_storage[0])); return this->m_delegate.serializeTo(buffer, mode); } -Fw::SerializeStatus RawTime::deserializeFrom(Fw::SerializeBufferBase& buffer, Fw::Endianness mode) { +Fw::SerializeStatus RawTime::deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode) { FW_ASSERT(&this->m_delegate == reinterpret_cast(&this->m_handle_storage[0])); return this->m_delegate.deserializeFrom(buffer, mode); } diff --git a/Os/RawTime.hpp b/Os/RawTime.hpp index e865d3734b..fdccfd7b9c 100644 --- a/Os/RawTime.hpp +++ b/Os/RawTime.hpp @@ -77,7 +77,7 @@ class RawTimeInterface : public Fw::Serializable { //! //! \param buffer The buffer to serialize the contents into. //! \return Fw::SerializeStatus indicating the result of the serialization. - virtual Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase& buffer, + virtual Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const = 0; //! \brief Deserialize the contents of the RawTimeInterface object from a buffer. @@ -92,7 +92,7 @@ class RawTimeInterface : public Fw::Serializable { //! //! \param buffer The buffer to deserialize the contents from. //! \return Fw::SerializeStatus indicating the result of the deserialization. - virtual Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase& buffer, + virtual Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) = 0; }; @@ -145,7 +145,7 @@ class RawTime final : public RawTimeInterface { //! //! \param buffer The buffer to serialize the contents into. //! \return Fw::SerializeStatus indicating the result of the serialization. - Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase& buffer, + Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override; //! \brief Deserialize the contents of the RawTimeInterface object from a buffer. @@ -160,7 +160,7 @@ class RawTime final : public RawTimeInterface { //! //! \param buffer The buffer to deserialize the contents from. //! \return Fw::SerializeStatus indicating the result of the deserialization. - Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase& buffer, + Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override; // ------------------------------------------------------------ diff --git a/Os/Stub/RawTime.cpp b/Os/Stub/RawTime.cpp index 8c889952a4..72fe970721 100644 --- a/Os/Stub/RawTime.cpp +++ b/Os/Stub/RawTime.cpp @@ -21,11 +21,11 @@ StubRawTime::Status StubRawTime::getTimeInterval(const Os::RawTime& other, Fw::T return Status::OP_OK; } -Fw::SerializeStatus StubRawTime::serializeTo(Fw::SerializeBufferBase& buffer, Fw::Endianness mode) const { +Fw::SerializeStatus StubRawTime::serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode) const { return Fw::FW_SERIALIZE_OK; } -Fw::SerializeStatus StubRawTime::deserializeFrom(Fw::SerializeBufferBase& buffer, Fw::Endianness mode) { +Fw::SerializeStatus StubRawTime::deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode) { return Fw::FW_SERIALIZE_OK; } diff --git a/Os/Stub/RawTime.hpp b/Os/Stub/RawTime.hpp index 0291cfe33f..d79d172e30 100644 --- a/Os/Stub/RawTime.hpp +++ b/Os/Stub/RawTime.hpp @@ -64,7 +64,7 @@ class StubRawTime : public RawTimeInterface { //! //! \param buffer The buffer to serialize the contents into. //! \return Fw::SerializeStatus indicating the result of the serialization. - Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase& buffer, + Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override; //! \brief Deserialize the contents of the RawTimeInterface object from a buffer. @@ -79,7 +79,7 @@ class StubRawTime : public RawTimeInterface { //! //! \param buffer The buffer to deserialize the contents from. //! \return Fw::SerializeStatus indicating the result of the deserialization. - Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase& buffer, + Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override; private: diff --git a/Os/Stub/test/RawTime.cpp b/Os/Stub/test/RawTime.cpp index 33264f87ec..b4899134a8 100644 --- a/Os/Stub/test/RawTime.cpp +++ b/Os/Stub/test/RawTime.cpp @@ -38,12 +38,12 @@ TestRawTime::Status TestRawTime::getTimeInterval(const Os::RawTime& other, Fw::T return Status::OP_OK; } -Fw::SerializeStatus TestRawTime::serializeTo(Fw::SerializeBufferBase& buffer, Fw::Endianness mode) const { +Fw::SerializeStatus TestRawTime::serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode) const { StaticData::data.lastCalled = StaticData::LastFn::SERIALIZE_FN; return Fw::FW_SERIALIZE_OK; } -Fw::SerializeStatus TestRawTime::deserializeFrom(Fw::SerializeBufferBase& buffer, Fw::Endianness mode) { +Fw::SerializeStatus TestRawTime::deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode) { StaticData::data.lastCalled = StaticData::LastFn::DESERIALIZE_FN; return Fw::FW_SERIALIZE_OK; } diff --git a/Os/Stub/test/RawTime.hpp b/Os/Stub/test/RawTime.hpp index 4eda7c9f31..2b591c719c 100644 --- a/Os/Stub/test/RawTime.hpp +++ b/Os/Stub/test/RawTime.hpp @@ -67,9 +67,9 @@ class TestRawTime : public RawTimeInterface { // ------------------------------------------------------------ Status now() override; Status getTimeInterval(const Os::RawTime& other, Fw::TimeInterval& interval) const override; - Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase& buffer, + Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override; - Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase& buffer, + Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override; private: diff --git a/Os/ValidateFileCommon.cpp b/Os/ValidateFileCommon.cpp index cdbcc822e4..3685dd2165 100644 --- a/Os/ValidateFileCommon.cpp +++ b/Os/ValidateFileCommon.cpp @@ -71,12 +71,12 @@ File::Status readHash(const char* hashFileName, Utils::HashBuffer& hashBuffer) { // Read hash from checksum file: unsigned char savedHash[HASH_DIGEST_LENGTH]; - FwSizeType size = static_cast(hashBuffer.getBuffCapacity()); + FwSizeType size = static_cast(hashBuffer.getCapacity()); status = hashFile.read(savedHash, size); if (File::OP_OK != status) { return status; } - if (static_cast(size) != hashBuffer.getBuffCapacity()) { + if (static_cast(size) != hashBuffer.getCapacity()) { return File::BAD_SIZE; } hashFile.close(); @@ -98,12 +98,12 @@ File::Status writeHash(const char* hashFileName, Utils::HashBuffer hashBuffer) { } // Write out the hash - FwSizeType size = static_cast(hashBuffer.getBuffLength()); + FwSizeType size = static_cast(hashBuffer.getSize()); status = hashFile.write(hashBuffer.getBuffAddr(), size, Os::File::WaitType::NO_WAIT); if (File::OP_OK != status) { return status; } - if (static_cast(size) != hashBuffer.getBuffLength()) { + if (static_cast(size) != hashBuffer.getSize()) { return File::BAD_SIZE; } hashFile.close(); diff --git a/Os/test/ut/OsValidateFileTest.cpp b/Os/test/ut/OsValidateFileTest.cpp index 4cc0ffdf90..6efd1219b8 100644 --- a/Os/test/ut/OsValidateFileTest.cpp +++ b/Os/test/ut/OsValidateFileTest.cpp @@ -59,7 +59,7 @@ void testValidateFile(const char* fileName) { return; } Utils::HashBuffer buf; - EXPECT_TRUE(static_cast(fileSize) == buf.getBuffCapacity()); + EXPECT_TRUE(static_cast(fileSize) == buf.getCapacity()); // Validate file: printf("Validating file %s against hash file %s\n", fileName, hashFileName); diff --git a/Svc/BufferLogger/BufferLogger.cpp b/Svc/BufferLogger/BufferLogger.cpp index 35157cf45c..913001f334 100644 --- a/Svc/BufferLogger/BufferLogger.cpp +++ b/Svc/BufferLogger/BufferLogger.cpp @@ -50,7 +50,7 @@ void BufferLogger ::bufferSendIn_handler(const FwIndexType portNum, Fw::Buffer& void BufferLogger ::comIn_handler(FwIndexType portNum, Fw::ComBuffer& data, U32 context) { if (m_state == LogState::LOGGING_ON) { const U8* const addr = data.getBuffAddr(); - const FwSizeType size = data.getBuffLength(); + const FwSizeType size = data.getSize(); m_file.logBuffer(addr, size); } } diff --git a/Svc/Ccsds/TmFramer/TmFramer.cpp b/Svc/Ccsds/TmFramer/TmFramer.cpp index e61b936f71..fe59882b33 100644 --- a/Svc/Ccsds/TmFramer/TmFramer.cpp +++ b/Svc/Ccsds/TmFramer/TmFramer.cpp @@ -108,7 +108,7 @@ void TmFramer ::dataReturnIn_handler(FwIndexType portNum, void TmFramer ::fill_with_idle_packet(Fw::SerializeBufferBase& serializer) { constexpr U16 endIndex = ComCfg::TmFrameFixedSize - TMTrailer::SERIALIZED_SIZE; constexpr U16 idleApid = static_cast(ComCfg::Apid::SPP_IDLE_PACKET); - const U16 startIndex = static_cast(serializer.getBuffLength()); + const U16 startIndex = static_cast(serializer.getSize()); const U16 idlePacketSize = static_cast(endIndex - startIndex); // Length token is defined as the number of bytes of payload data minus 1 const U16 lengthToken = static_cast(idlePacketSize - SpacePacketHeader::SERIALIZED_SIZE - 1); diff --git a/Svc/CmdSequencer/FPrimeSequence.cpp b/Svc/CmdSequencer/FPrimeSequence.cpp index 8ee84540c6..dbe3c62faa 100644 --- a/Svc/CmdSequencer/FPrimeSequence.cpp +++ b/Svc/CmdSequencer/FPrimeSequence.cpp @@ -58,7 +58,7 @@ bool CmdSequencerComponentImpl::FPrimeSequence ::loadFile(const Fw::StringBase& } bool CmdSequencerComponentImpl::FPrimeSequence ::hasMoreRecords() const { - return this->m_buffer.getBuffLeft() > 0; + return this->m_buffer.getDeserializeSizeLeft() > 0; } void CmdSequencerComponentImpl::FPrimeSequence ::nextRecord(Record& record) { @@ -102,7 +102,7 @@ bool CmdSequencerComponentImpl::FPrimeSequence ::readOpenFile() { status = this->deserializeHeader() and this->readRecordsAndCRC() and this->extractCRC(); } if (status) { - const FwSizeType buffLen = this->m_buffer.getBuffLength(); + const FwSizeType buffLen = this->m_buffer.getSize(); this->m_crc.update(buffAddr, buffLen); this->m_crc.finalize(); } @@ -116,7 +116,7 @@ bool CmdSequencerComponentImpl::FPrimeSequence ::readHeader() { FwSizeType readLen = Sequence::Header::SERIALIZED_SIZE; - const FwSizeType capacity = buffer.getBuffCapacity(); + const FwSizeType capacity = buffer.getCapacity(); FW_ASSERT(capacity >= readLen, static_cast(capacity), static_cast(readLen)); Os::File::Status fileStatus = file.read(buffer.getBuffAddr(), readLen); @@ -148,7 +148,7 @@ bool CmdSequencerComponentImpl::FPrimeSequence ::deserializeHeader() { this->m_events.fileInvalid(CmdSequencer_FileReadStage::DESER_SIZE, serializeStatus); return false; } - if (header.m_fileSize > buffer.getBuffCapacity()) { + if (header.m_fileSize > buffer.getCapacity()) { this->m_events.fileSizeError(header.m_fileSize); return false; } @@ -203,7 +203,7 @@ bool CmdSequencerComponentImpl::FPrimeSequence ::extractCRC() { U32& crc = this->m_crc.m_stored; // Compute the data size - const FwSizeType buffSize = buffer.getBuffLength(); + const FwSizeType buffSize = buffer.getSize(); const FwSizeType crcSize = sizeof(crc); U8* const buffAddr = buffer.getBuffAddr(); if (buffSize < crcSize) { @@ -280,7 +280,7 @@ Fw::SerializeStatus CmdSequencerComponentImpl::FPrimeSequence ::deserializeTimeT Fw::SerializeStatus CmdSequencerComponentImpl::FPrimeSequence ::deserializeRecordSize(U32& recordSize) { Fw::SerializeBufferBase& buffer = this->m_buffer; Fw::SerializeStatus status = buffer.deserializeTo(recordSize); - if (status == Fw::FW_SERIALIZE_OK and recordSize > buffer.getBuffLeft()) { + if (status == Fw::FW_SERIALIZE_OK and recordSize > buffer.getDeserializeSizeLeft()) { // Not enough data left status = Fw::FW_DESERIALIZE_SIZE_MISMATCH; } @@ -322,7 +322,7 @@ bool CmdSequencerComponentImpl::FPrimeSequence ::validateRecords() { } } // Check there is no data left - const FwSizeType buffLeftSize = buffer.getBuffLeft(); + const FwSizeType buffLeftSize = buffer.getDeserializeSizeLeft(); if (buffLeftSize > 0) { this->m_events.recordMismatch(numRecords, static_cast(buffLeftSize)); return false; diff --git a/Svc/CmdSequencer/formats/AMPCSSequence.cpp b/Svc/CmdSequencer/formats/AMPCSSequence.cpp index 6fbf11d8d9..9d308f56e9 100644 --- a/Svc/CmdSequencer/formats/AMPCSSequence.cpp +++ b/Svc/CmdSequencer/formats/AMPCSSequence.cpp @@ -108,7 +108,7 @@ bool AMPCSSequence ::validateRecords() { Sequence::Record record; // Deserialize all records and count the records - const U32 loopBound = static_cast(buffer.getBuffLeft()); + const U32 loopBound = static_cast(buffer.getDeserializeSizeLeft()); U32 numRecords = 0; for (; numRecords < loopBound; ++numRecords) { if (not this->hasMoreRecords()) { @@ -129,7 +129,7 @@ bool AMPCSSequence ::validateRecords() { } bool AMPCSSequence ::hasMoreRecords() const { - return this->m_buffer.getBuffLeft() > 0; + return this->m_buffer.getDeserializeSizeLeft() > 0; } void AMPCSSequence ::nextRecord(Sequence::Record& record) { @@ -186,7 +186,7 @@ bool AMPCSSequence ::readOpenSequenceFile() { } if (status) { U8* const buffAddr = this->m_buffer.getBuffAddr(); - const FwSizeType buffLen = this->m_buffer.getBuffLength(); + const FwSizeType buffLen = this->m_buffer.getSize(); FW_ASSERT(buffLen == this->m_header.m_fileSize, static_cast(buffLen), static_cast(this->m_header.m_fileSize)); this->m_crc.update(buffAddr, buffLen); @@ -223,7 +223,7 @@ bool AMPCSSequence ::readRecords() { U8* const addr = buffer.getBuffAddr(); // Check file size - if (size > this->m_buffer.getBuffCapacity()) { + if (size > this->m_buffer.getCapacity()) { this->m_events.fileSizeError(static_cast(size)); return false; } @@ -298,7 +298,7 @@ Fw::SerializeStatus AMPCSSequence ::deserializeTime(Fw::Time& timeTag) { Fw::SerializeStatus AMPCSSequence ::deserializeCmdLength(Record::CmdLength::t& cmdLength) { Fw::SerializeBufferBase& buffer = this->m_buffer; Fw::SerializeStatus status = buffer.deserializeTo(cmdLength); - if (status == Fw::FW_SERIALIZE_OK and cmdLength > buffer.getBuffLeft()) { + if (status == Fw::FW_SERIALIZE_OK and cmdLength > buffer.getDeserializeSizeLeft()) { // Not enough data left status = Fw::FW_DESERIALIZE_SIZE_MISMATCH; } @@ -328,7 +328,7 @@ Fw::SerializeStatus AMPCSSequence ::translateCommand(Fw::ComBuffer& comBuffer, c sizeOfZeros += static_cast(sizeof(zeros)); } // Set the buffer length - const U32 fixedBuffLen = static_cast(comBuffer.getBuffLength()); + const U32 fixedBuffLen = static_cast(comBuffer.getSize()); FW_ASSERT(fixedBuffLen == sizeof(cmdDescriptor) + sizeOfZeros, static_cast(fixedBuffLen)); const U32 totalBuffLen = fixedBuffLen + cmdLength; status = comBuffer.setBuffLen(totalBuffLen); diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/AMPCS/CRCs.cpp b/Svc/CmdSequencer/test/ut/SequenceFiles/AMPCS/CRCs.cpp index 9612114fd8..e54df5c3d2 100644 --- a/Svc/CmdSequencer/test/ut/SequenceFiles/AMPCS/CRCs.cpp +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/AMPCS/CRCs.cpp @@ -61,7 +61,7 @@ void createFile(Fw::SerializeBufferBase& buffer, const char* const fileName) { void computeCRC(Fw::SerializeBufferBase& buffer, CRC& crc) { crc.init(); const U8* const addr = buffer.getBuffAddr(); - const U32 size = buffer.getBuffLength(); + const U32 size = buffer.getSize(); crc.update(addr, size); crc.finalize(); } diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/AMPCS/Records.cpp b/Svc/CmdSequencer/test/ut/SequenceFiles/AMPCS/Records.cpp index b9360a6646..71088acf11 100644 --- a/Svc/CmdSequencer/test/ut/SequenceFiles/AMPCS/Records.cpp +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/AMPCS/Records.cpp @@ -24,7 +24,7 @@ void serialize(const AMPCSSequence::Record::TimeFlag::t timeFlag, const Fw::SerializeBufferBase& cmdField, Fw::SerializeBufferBase& dest) { const AMPCSSequence::Record::TimeFlag::Serial::t serialTimeFlag = timeFlag; - const AMPCSSequence::Record::CmdLength::t cmdLength = cmdField.getBuffLength(); + const AMPCSSequence::Record::CmdLength::t cmdLength = cmdField.getSize(); const U8* const addr = cmdField.getBuffAddr(); ASSERT_EQ(Fw::FW_SERIALIZE_OK, dest.serializeFrom(serialTimeFlag)); ASSERT_EQ(Fw::FW_SERIALIZE_OK, dest.serializeFrom(time)); diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/BadCRCFile.cpp b/Svc/CmdSequencer/test/ut/SequenceFiles/BadCRCFile.cpp index a212fe149a..8441d8aa8c 100644 --- a/Svc/CmdSequencer/test/ut/SequenceFiles/BadCRCFile.cpp +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/BadCRCFile.cpp @@ -33,7 +33,7 @@ void BadCRCFile ::serializeFPrime(Fw::SerializeBufferBase& buffer) { ASSERT_EQ(Fw::FW_SERIALIZE_OK, buffer.serializeFrom(recordData)); // CRC const U8* const addr = buffer.getBuffAddr(); - const U32 size = buffer.getBuffLength(); + const U32 size = buffer.getSize(); this->crc.init(); this->crc.update(addr, size); this->crc.finalize(); diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.cpp b/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.cpp index 91da870226..c638ede57e 100644 --- a/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.cpp +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.cpp @@ -19,10 +19,14 @@ namespace SequenceFiles { namespace Buffers { -FwSizeType FileBuffer ::getBuffCapacity() const { +FwSizeType FileBuffer ::getCapacity() const { return sizeof(m_buff); } +FwSizeType FileBuffer ::getBuffCapacity() const { + return this->getCapacity(); +} + U8* FileBuffer ::getBuffAddr() { return m_buff; } @@ -34,7 +38,7 @@ const U8* FileBuffer ::getBuffAddr() const { void write(const Fw::SerializeBufferBase& buffer, const char* fileName) { Os::File file; ASSERT_EQ(file.open(fileName, Os::File::OPEN_WRITE), Os::File::OP_OK); - FwSizeType size = buffer.getBuffLength(); + FwSizeType size = buffer.getSize(); const U32 expectedSize = size; const U8* const buffAddr = buffer.getBuffAddr(); ASSERT_EQ(file.write(buffAddr, size, Os::File::WaitType::WAIT), Os::File::OP_OK); diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.hpp b/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.hpp index 9f02dee1df..f11b755435 100644 --- a/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.hpp +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.hpp @@ -26,7 +26,8 @@ class FileBuffer : public Fw::SerializeBufferBase { enum Constants { CAPACITY = 4096 }; public: - FwSizeType getBuffCapacity() const; + DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead"); + FwSizeType getCapacity() const; U8* getBuffAddr(); diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/FPrime/CRCs.cpp b/Svc/CmdSequencer/test/ut/SequenceFiles/FPrime/CRCs.cpp index 6072350987..bfb5512073 100644 --- a/Svc/CmdSequencer/test/ut/SequenceFiles/FPrime/CRCs.cpp +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/FPrime/CRCs.cpp @@ -22,7 +22,7 @@ namespace CRCs { void serialize(Fw::SerializeBufferBase& destBuffer) { CmdSequencerComponentImpl::FPrimeSequence::CRC crc; crc.init(); - crc.update(destBuffer.getBuffAddr(), destBuffer.getBuffLength()); + crc.update(destBuffer.getBuffAddr(), destBuffer.getSize()); crc.finalize(); ASSERT_EQ(destBuffer.serializeFrom(crc.m_computed), Fw::FW_SERIALIZE_OK); } diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/FPrime/Records.cpp b/Svc/CmdSequencer/test/ut/SequenceFiles/FPrime/Records.cpp index e00bbed67e..a916dc4a0a 100644 --- a/Svc/CmdSequencer/test/ut/SequenceFiles/FPrime/Records.cpp +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/FPrime/Records.cpp @@ -27,7 +27,7 @@ void serialize(Records::Descriptor desc, ASSERT_EQ(Fw::FW_SERIALIZE_OK, destBuffer.serializeFrom(descU8)); if (desc != CmdSequencerComponentImpl::Sequence::Record::END_OF_SEQUENCE) { const U8* const buffAddr = opcodeAndArgument.getBuffAddr(); - const U32 size = opcodeAndArgument.getBuffLength(); + const U32 size = opcodeAndArgument.getSize(); const U32 recSize = sizeof(FwPacketDescriptorType) + size; const FwPacketDescriptorType cmdDescriptor = Fw::ComPacketType::FW_PACKET_COMMAND; const U32 seconds = time.getSeconds(); diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/TooLargeFile.cpp b/Svc/CmdSequencer/test/ut/SequenceFiles/TooLargeFile.cpp index be89104f61..e6fec077a4 100644 --- a/Svc/CmdSequencer/test/ut/SequenceFiles/TooLargeFile.cpp +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/TooLargeFile.cpp @@ -45,7 +45,7 @@ void TooLargeFile ::serializeAMPCS(Fw::SerializeBufferBase& buffer) { Fw::SerialBuffer cmdField(cmdFieldBuffer, sizeof(cmdFieldBuffer)); cmdField.setBuffLen(cmdFieldSize); AMPCS::Records::serialize(timeFlag, time, cmdField, buffer); - ASSERT_EQ(sizeof(AMPCSSequence::SequenceHeader::t) + dataSize, buffer.getBuffLength()); + ASSERT_EQ(sizeof(AMPCSSequence::SequenceHeader::t) + dataSize, buffer.getSize()); // CRC AMPCS::CRCs::createFile(buffer, this->getName().toChar()); } diff --git a/Svc/CmdSplitter/test/ut/CmdSplitterTester.cpp b/Svc/CmdSplitter/test/ut/CmdSplitterTester.cpp index 29bff57dcc..d729c5f1ea 100644 --- a/Svc/CmdSplitter/test/ut/CmdSplitterTester.cpp +++ b/Svc/CmdSplitter/test/ut/CmdSplitterTester.cpp @@ -36,7 +36,7 @@ Fw::ComBuffer CmdSplitterTester ::build_command_around_opcode(FwOpcodeType opcod Fw::CmdArgBuffer args; - U32 random_size = STest::Pick::lowerUpper(0, static_cast(args.getBuffCapacity())); + U32 random_size = STest::Pick::lowerUpper(0, static_cast(args.getCapacity())); args.resetSer(); for (FwSizeType i = 0; i < random_size; i++) { args.serializeFrom(static_cast(STest::Pick::any())); diff --git a/Svc/ComAggregator/ComAggregator.cpp b/Svc/ComAggregator/ComAggregator.cpp index 796ce228f7..9061552780 100644 --- a/Svc/ComAggregator/ComAggregator.cpp +++ b/Svc/ComAggregator/ComAggregator.cpp @@ -76,9 +76,9 @@ void ComAggregator ::Svc_AggregationMachine_action_doFill(SmId smId, void ComAggregator ::Svc_AggregationMachine_action_doSend(SmId smId, Svc_AggregationMachine::Signal signal) { // Send only when the buffer will be valid - if (this->m_frameSerializer.getBuffLength() > 0) { + if (this->m_frameSerializer.getSize() > 0) { this->m_bufferState = Fw::Buffer::OwnershipState::NOT_OWNED; - this->m_frameBuffer.setSize(this->m_frameSerializer.getBuffLength()); + this->m_frameBuffer.setSize(this->m_frameSerializer.getSize()); this->dataOut_out(0, this->m_frameBuffer, this->m_lastContext); } } @@ -103,12 +103,12 @@ bool ComAggregator ::Svc_AggregationMachine_guard_isFull(SmId smId, Svc_AggregationMachine::Signal signal, const Svc::ComDataContextPair& value) const { FW_ASSERT(value.get_data().getSize() <= ComCfg::AggregationSize); - const FwSizeType remaining = this->m_frameSerializer.getBuffCapacity() - this->m_frameSerializer.getBuffLength(); + const FwSizeType remaining = this->m_frameSerializer.getCapacity() - this->m_frameSerializer.getSize(); return (remaining <= value.get_data().getSize()); } bool ComAggregator ::Svc_AggregationMachine_guard_isNotEmpty(SmId smId, Svc_AggregationMachine::Signal signal) const { - return this->m_frameSerializer.getBuffLength() > 0; + return this->m_frameSerializer.getSize() > 0; } bool ComAggregator ::Svc_AggregationMachine_guard_isGood(SmId smId, diff --git a/Svc/ComAggregator/test/ut/ComAggregatorTester.cpp b/Svc/ComAggregator/test/ut/ComAggregatorTester.cpp index d9f7ee4c76..5be0b19e1f 100644 --- a/Svc/ComAggregator/test/ut/ComAggregatorTester.cpp +++ b/Svc/ComAggregator/test/ut/ComAggregatorTester.cpp @@ -53,7 +53,7 @@ void ComAggregatorTester ::validate_aggregation(const Fw::Buffer& buffer) { } void ComAggregatorTester ::validate_buffer_aggregated(const Fw::Buffer& buffer, const ComCfg::FrameContext& context) { - FwSizeType start = this->component.m_frameSerializer.getBuffLength() - buffer.getSize(); + FwSizeType start = this->component.m_frameSerializer.getSize() - buffer.getSize(); for (FwSizeType i = 0; i < buffer.getSize(); i++) { ASSERT_EQ(buffer.getData()[i], this->component.m_frameBuffer.getData()[start + i]); } @@ -64,7 +64,7 @@ void ComAggregatorTester ::validate_buffer_aggregated(const Fw::Buffer& buffer, void ComAggregatorTester ::test_initial() { // Initial state should have empty buffer - ASSERT_EQ(this->component.m_frameSerializer.getBuffLength(), 0); + ASSERT_EQ(this->component.m_frameSerializer.getSize(), 0); ASSERT_EQ(this->component.m_bufferState, Fw::Buffer::OwnershipState::OWNED); this->component.preamble(); ASSERT_from_comStatusOut(0, Fw::Success::SUCCESS); @@ -77,7 +77,7 @@ void ComAggregatorTester ::test_initial() { //! Tests fill operation Fw::Buffer ComAggregatorTester ::test_fill(bool expect_hold) { // Precondition: initial has run - const FwSizeType ORIGINAL_LENGTH = this->component.m_frameSerializer.getBuffLength(); + const FwSizeType ORIGINAL_LENGTH = this->component.m_frameSerializer.getSize(); if (ORIGINAL_LENGTH == ComCfg::AggregationSize) { // Nothing to fill return Fw::Buffer(); @@ -90,9 +90,9 @@ Fw::Buffer ComAggregatorTester ::test_fill(bool expect_hold) { EXPECT_EQ(this->dispatchOne(this->component), Svc::ComAggregatorComponentBase::MsgDispatchStatus::MSG_DISPATCH_OK); // Dispatch the state machine if (expect_hold) { - EXPECT_EQ(ORIGINAL_LENGTH, this->component.m_frameSerializer.getBuffLength()); + EXPECT_EQ(ORIGINAL_LENGTH, this->component.m_frameSerializer.getSize()); } else { - EXPECT_EQ(ORIGINAL_LENGTH + BUFFER_LENGTH, this->component.m_frameSerializer.getBuffLength()); + EXPECT_EQ(ORIGINAL_LENGTH + BUFFER_LENGTH, this->component.m_frameSerializer.getSize()); this->validate_buffer_aggregated(buffer, context); } this->clearHistory(); @@ -110,7 +110,7 @@ void ComAggregatorTester ::test_fill_multi() { void ComAggregatorTester ::test_full() { // Precondition: fill has run // Chose a buffer that will be too large to fit but still will fit after being aggregated - const FwSizeType ORIGINAL_LENGTH = this->component.m_frameSerializer.getBuffLength(); + const FwSizeType ORIGINAL_LENGTH = this->component.m_frameSerializer.getSize(); const U32 BUFFER_LENGTH = STest::Pick::lowerUpper(static_cast(ComCfg::AggregationSize - ORIGINAL_LENGTH + 1), static_cast(ComCfg::AggregationSize)); Fw::Buffer buffer = fill_buffer(BUFFER_LENGTH); diff --git a/Svc/ComLogger/ComLogger.cpp b/Svc/ComLogger/ComLogger.cpp index 501ead61a8..db800ea32d 100644 --- a/Svc/ComLogger/ComLogger.cpp +++ b/Svc/ComLogger/ComLogger.cpp @@ -87,7 +87,7 @@ void ComLogger ::comIn_handler(FwIndexType portNum, Fw::ComBuffer& data, U32 con FW_ASSERT(portNum == 0); // Get length of buffer: - FwSizeType sizeNative = data.getBuffLength(); + FwSizeType sizeNative = data.getSize(); // ComLogger only writes 16-bit sizes to save space // on disk: FW_ASSERT(sizeNative < 65536, static_cast(sizeNative)); @@ -182,8 +182,8 @@ void ComLogger ::writeComBufferToFile(Fw::ComBuffer& data, U16 size) { U8 buffer[sizeof(size)]; Fw::SerialBuffer serialLength(&buffer[0], sizeof(size)); serialLength.serializeFrom(size); - if (this->writeToFile(serialLength.getBuffAddr(), static_cast(serialLength.getBuffLength()))) { - this->m_byteCount += static_cast(serialLength.getBuffLength()); + if (this->writeToFile(serialLength.getBuffAddr(), static_cast(serialLength.getSize()))) { + this->m_byteCount += static_cast(serialLength.getSize()); } else { return; } diff --git a/Svc/ComQueue/ComQueue.cpp b/Svc/ComQueue/ComQueue.cpp index 587f7368d7..209e5754eb 100644 --- a/Svc/ComQueue/ComQueue.cpp +++ b/Svc/ComQueue/ComQueue.cpp @@ -253,7 +253,7 @@ bool ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8 void ComQueue::sendComBuffer(Fw::ComBuffer& comBuffer, FwIndexType queueIndex) { FW_ASSERT(this->m_state == READY); - Fw::Buffer outBuffer(comBuffer.getBuffAddr(), static_cast(comBuffer.getBuffLength())); + Fw::Buffer outBuffer(comBuffer.getBuffAddr(), static_cast(comBuffer.getSize())); // Context value is used to determine what to do when the buffer returns on the dataReturnIn port ComCfg::FrameContext context; diff --git a/Svc/ComQueue/test/ut/ComQueueTester.cpp b/Svc/ComQueue/test/ut/ComQueueTester.cpp index d859c1bdd0..dd775f76c9 100644 --- a/Svc/ComQueue/test/ut/ComQueueTester.cpp +++ b/Svc/ComQueue/test/ut/ComQueueTester.cpp @@ -85,7 +85,7 @@ void ComQueueTester ::testQueueSend() { for (FwIndexType portNum = 0; portNum < ComQueue::COM_PORT_COUNT; portNum++) { invoke_to_comPacketQueueIn(portNum, comBuffer, 0); - emitOneAndCheck(portNum, comBuffer.getBuffAddr(), comBuffer.getBuffLength()); + emitOneAndCheck(portNum, comBuffer.getBuffAddr(), comBuffer.getSize()); } clearFromPortHistory(); @@ -112,7 +112,7 @@ void ComQueueTester ::testQueuePause() { invoke_to_comStatusIn(0, state); invoke_to_comStatusIn(0, state); invoke_to_comStatusIn(0, state); - emitOneAndCheck(portNum, comBuffer.getBuffAddr(), comBuffer.getBuffLength()); + emitOneAndCheck(portNum, comBuffer.getBuffAddr(), comBuffer.getSize()); } clearFromPortHistory(); @@ -299,7 +299,7 @@ void ComQueueTester ::testReadyFirst() { dispatchAll(); Fw::Buffer emittedBuffer = this->fromPortHistory_dataOut->at(portNum).data; - ASSERT_EQ(emittedBuffer.getSize(), comBuffer.getBuffLength()); + ASSERT_EQ(emittedBuffer.getSize(), comBuffer.getSize()); for (FwSizeType i = 0; i < emittedBuffer.getSize(); i++) { ASSERT_EQ(emittedBuffer.getData()[i], comBuffer.getBuffAddr()[i]); } diff --git a/Svc/ComSplitter/test/ut/ComSplitterTester.cpp b/Svc/ComSplitter/test/ut/ComSplitterTester.cpp index 00efb89688..c299b68d0e 100644 --- a/Svc/ComSplitter/test/ut/ComSplitterTester.cpp +++ b/Svc/ComSplitter/test/ut/ComSplitterTester.cpp @@ -53,9 +53,9 @@ void ComSplitterTester ::test_nominal() { void ComSplitterTester ::assert_comOut(const U32 index, const Fw::ComBuffer& data) const { ASSERT_GT(fromPortHistory_comOut->size(), index); const FromPortEntry_comOut& e = fromPortHistory_comOut->at(index); - ASSERT_EQ(data.getBuffLength(), e.data.getBuffLength()); - ASSERT_EQ(memcmp(data.getBuffAddr(), e.data.getBuffAddr(), data.getBuffLength()), 0); - // for(int k=0; k < e.data.getBuffLength(); k++) + ASSERT_EQ(data.getSize(), e.data.getSize()); + ASSERT_EQ(memcmp(data.getBuffAddr(), e.data.getBuffAddr(), data.getSize()), 0); + // for(int k=0; k < e.data.getSize(); k++) // printf("0x%02x ", e.data.getBuffAddr()[k]); // printf("\n"); } diff --git a/Svc/DpCatalog/DpCatalog.cpp b/Svc/DpCatalog/DpCatalog.cpp index a2f5e28b5b..db1d1b672d 100644 --- a/Svc/DpCatalog/DpCatalog.cpp +++ b/Svc/DpCatalog/DpCatalog.cpp @@ -281,7 +281,7 @@ void DpCatalog::pruneAndWriteStateFile() { // Should always fit FW_ASSERT(Fw::FW_SERIALIZE_OK == serStat, serStat); // write the entry - FwSizeType size = entryBuffer.getBuffLength(); + FwSizeType size = entryBuffer.getSize(); // Protect against overflow stat = stateFile.write(buffer, size); if (stat != Os::File::OP_OK) { @@ -326,7 +326,7 @@ void DpCatalog::appendFileState(const DpStateEntry& entry) { // should fit FW_ASSERT(serStat == Fw::FW_SERIALIZE_OK, serStat); // write the entry - FwSizeType size = entryBuffer.getBuffLength(); + FwSizeType size = entryBuffer.getSize(); stat = stateFile.write(buffer, size); if (stat != Os::File::OP_OK) { this->log_WARNING_HI_StateFileWriteError(this->m_stateFile, stat); diff --git a/Svc/EventManager/test/ut/EventManagerTester.cpp b/Svc/EventManager/test/ut/EventManagerTester.cpp index 93dc02d236..d250657a5d 100644 --- a/Svc/EventManager/test/ut/EventManagerTester.cpp +++ b/Svc/EventManager/test/ut/EventManagerTester.cpp @@ -125,7 +125,7 @@ void EventManagerTester::runWithFilters(Fw::LogSeverity filter) { ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat); ASSERT_EQ(readVal, val); // packet should be empty - ASSERT_EQ(this->m_sentPacket.getBuffLeft(), 0u); + ASSERT_EQ(this->m_sentPacket.getDeserializeSizeLeft(), 0u); // Disable severity filter this->clearHistory(); @@ -395,7 +395,7 @@ void EventManagerTester::runEventFatal() { ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat); ASSERT_EQ(readVal, val); // packet should be empty - ASSERT_EQ(this->m_sentPacket.getBuffLeft(), 0u); + ASSERT_EQ(this->m_sentPacket.getDeserializeSizeLeft(), 0u); // Turn on all filters and make sure FATAL still gets through this->clearHistory(); @@ -438,7 +438,7 @@ void EventManagerTester::runEventFatal() { ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat); ASSERT_EQ(readVal, val); // packet should be empty - ASSERT_EQ(this->m_sentPacket.getBuffLeft(), 0u); + ASSERT_EQ(this->m_sentPacket.getDeserializeSizeLeft(), 0u); // turn off filters @@ -489,7 +489,7 @@ void EventManagerTester::writeEvent(FwEventIdType id, Fw::LogSeverity severity, ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat); ASSERT_EQ(readVal, value); // packet should be empty - ASSERT_EQ(this->m_sentPacket.getBuffLeft(), 0u); + ASSERT_EQ(this->m_sentPacket.getDeserializeSizeLeft(), 0u); } void EventManagerTester::readEvent(FwEventIdType id, Fw::LogSeverity severity, U32 value, Os::File& file) { diff --git a/Svc/FprimeDeframer/FprimeDeframer.cpp b/Svc/FprimeDeframer/FprimeDeframer.cpp index bf3c26f541..916ae61fdc 100644 --- a/Svc/FprimeDeframer/FprimeDeframer.cpp +++ b/Svc/FprimeDeframer/FprimeDeframer.cpp @@ -59,7 +59,8 @@ void FprimeDeframer ::dataIn_handler(FwIndexType portNum, Fw::Buffer& data, cons } // -------- Attempt to extract APID from Payload -------- ComCfg::FrameContext contextCopy = context; - if (deserializer.getBuffLeft() < FprimeProtocol::FrameTrailer::SERIALIZED_SIZE + sizeof(FwPacketDescriptorType)) { + if (deserializer.getDeserializeSizeLeft() < + FprimeProtocol::FrameTrailer::SERIALIZED_SIZE + sizeof(FwPacketDescriptorType)) { // Not enough data to read a valid FwPacketDescriptor, emit event and skip attempting to read an APID this->log_WARNING_LO_PayloadTooShort(); } else { diff --git a/Svc/FpySequencer/FpySequencerDirectives.cpp b/Svc/FpySequencer/FpySequencerDirectives.cpp index 3e6f9bc49e..f767536d0d 100644 --- a/Svc/FpySequencer/FpySequencerDirectives.cpp +++ b/Svc/FpySequencer/FpySequencerDirectives.cpp @@ -335,11 +335,11 @@ Signal FpySequencer::pushTlmVal_directiveHandler(const FpySequencer_PushTlmValDi return Signal::stmtResponse_failure; } - if (Fpy::MAX_STACK_SIZE - tlmValue.getBuffLength() < this->m_runtime.stack.size) { + if (Fpy::MAX_STACK_SIZE - tlmValue.getSize() < this->m_runtime.stack.size) { error = DirectiveError::STACK_OVERFLOW; return Signal::stmtResponse_failure; } - this->m_runtime.stack.push(tlmValue.getBuffAddr(), static_cast(tlmValue.getBuffLength())); + this->m_runtime.stack.push(tlmValue.getBuffAddr(), static_cast(tlmValue.getSize())); return Signal::stmtResponse_success; } @@ -368,15 +368,15 @@ Signal FpySequencer::pushTlmValAndTime_directiveHandler(const FpySequencer_PushT FW_ASSERT(stat == Fw::SerializeStatus::FW_SERIALIZE_OK, static_cast(stat)); // check that our stack won't overflow if we put both val and time on it - if (Fpy::MAX_STACK_SIZE - tlmValue.getBuffLength() - timeEsb.getBuffLength() < this->m_runtime.stack.size) { + if (Fpy::MAX_STACK_SIZE - tlmValue.getSize() - timeEsb.getSize() < this->m_runtime.stack.size) { error = DirectiveError::STACK_OVERFLOW; return Signal::stmtResponse_failure; } // push tlm to end of stack - this->m_runtime.stack.push(tlmValue.getBuffAddr(), static_cast(tlmValue.getBuffLength())); + this->m_runtime.stack.push(tlmValue.getBuffAddr(), static_cast(tlmValue.getSize())); // now push time to end of stack - this->m_runtime.stack.push(timeEsb.getBuffAddr(), static_cast(timeEsb.getBuffLength())); + this->m_runtime.stack.push(timeEsb.getBuffAddr(), static_cast(timeEsb.getSize())); return Signal::stmtResponse_success; } @@ -395,12 +395,12 @@ Signal FpySequencer::pushPrm_directiveHandler(const FpySequencer_PushPrmDirectiv return Signal::stmtResponse_failure; } - if (Fpy::MAX_STACK_SIZE - prmValue.getBuffLength() < this->m_runtime.stack.size) { + if (Fpy::MAX_STACK_SIZE - prmValue.getSize() < this->m_runtime.stack.size) { error = DirectiveError::STACK_OVERFLOW; return Signal::stmtResponse_failure; } - this->m_runtime.stack.push(prmValue.getBuffAddr(), static_cast(prmValue.getBuffLength())); + this->m_runtime.stack.push(prmValue.getBuffAddr(), static_cast(prmValue.getSize())); return Signal::stmtResponse_success; } @@ -1225,8 +1225,8 @@ Signal FpySequencer::pushTime_directiveHandler(const FpySequencer_PushTimeDirect FW_ASSERT(stat == Fw::SerializeStatus::FW_SERIALIZE_OK, static_cast(stat)); // push time to end of stack - memcpy(this->m_runtime.stack.bytes + this->m_runtime.stack.size, timeEsb.getBuffAddr(), timeEsb.getBuffLength()); - this->m_runtime.stack.size += static_cast(timeEsb.getBuffLength()); + memcpy(this->m_runtime.stack.bytes + this->m_runtime.stack.size, timeEsb.getBuffAddr(), timeEsb.getSize()); + this->m_runtime.stack.size += static_cast(timeEsb.getSize()); return Signal::stmtResponse_success; } diff --git a/Svc/FpySequencer/FpySequencerRunState.cpp b/Svc/FpySequencer/FpySequencerRunState.cpp index 9eee76cfd1..81bd5a0963 100644 --- a/Svc/FpySequencer/FpySequencerRunState.cpp +++ b/Svc/FpySequencer/FpySequencerRunState.cpp @@ -57,19 +57,18 @@ Signal FpySequencer::dispatchStatement() { Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, DirectiveUnion& deserializedDirective) { Fw::SerializeStatus status; // make our own esb so we can deser from stmt without breaking its constness - Fw::ExternalSerializeBuffer argBuf(const_cast(stmt.get_argBuf().getBuffAddr()), - stmt.get_argBuf().getBuffLength()); - argBuf.setBuffLen(stmt.get_argBuf().getBuffLength()); + Fw::ExternalSerializeBuffer argBuf(const_cast(stmt.get_argBuf().getBuffAddr()), stmt.get_argBuf().getSize()); + argBuf.setBuffLen(stmt.get_argBuf().getSize()); switch (stmt.get_opCode()) { case Fpy::DirectiveId::WAIT_REL: { // in order to use a type with non trivial ctor in cpp union, have to manually construct and destruct it new (&deserializedDirective.waitRel) FpySequencer_WaitRelDirective(); // wait rel does not need deser - if (argBuf.getBuffLeft() != 0) { + if (argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), Fw::SerializeStatus::FW_DESERIALIZE_SIZE_MISMATCH, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -77,10 +76,10 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::WAIT_ABS: { new (&deserializedDirective.waitAbs) FpySequencer_WaitAbsDirective(); // wait abs does not need deser - if (argBuf.getBuffLeft() != 0) { + if (argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), Fw::SerializeStatus::FW_DESERIALIZE_SIZE_MISMATCH, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -88,9 +87,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::GOTO: { new (&deserializedDirective.gotoDirective) FpySequencer_GotoDirective(); status = argBuf.deserializeTo(deserializedDirective.gotoDirective); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -98,9 +97,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::IF: { new (&deserializedDirective.ifDirective) FpySequencer_IfDirective(); status = argBuf.deserializeTo(deserializedDirective.ifDirective); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -108,10 +107,10 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::NO_OP: { new (&deserializedDirective.noOp) FpySequencer_NoOpDirective(); // no op does not need deser - if (argBuf.getBuffLeft() != 0) { + if (argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), Fw::SerializeStatus::FW_DESERIALIZE_SIZE_MISMATCH, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -119,9 +118,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::PUSH_TLM_VAL: { new (&deserializedDirective.pushTlmVal) FpySequencer_PushTlmValDirective(); status = argBuf.deserializeTo(deserializedDirective.pushTlmVal); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -129,9 +128,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::PUSH_TLM_VAL_AND_TIME: { new (&deserializedDirective.pushTlmValAndTime) FpySequencer_PushTlmValAndTimeDirective(); status = argBuf.deserializeTo(deserializedDirective.pushTlmValAndTime); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -139,9 +138,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::PUSH_PRM: { new (&deserializedDirective.pushPrm) FpySequencer_PushPrmDirective(); status = argBuf.deserializeTo(deserializedDirective.pushPrm); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -154,19 +153,19 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc status = argBuf.deserializeTo(opcode); if (status != Fw::SerializeStatus::FW_SERIALIZE_OK) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } deserializedDirective.constCmd.set_opCode(opcode); // how many bytes are left? - FwSizeType cmdArgBufSize = argBuf.getBuffLeft(); + FwSizeType cmdArgBufSize = argBuf.getDeserializeSizeLeft(); // check to make sure the value will fit in the FpySequencer_ConstCmdDirective::argBuf if (cmdArgBufSize > Fpy::MAX_DIRECTIVE_SIZE) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), Fw::SerializeStatus::FW_DESERIALIZE_FORMAT_ERROR, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } @@ -176,12 +175,13 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc if (status != Fw::SerializeStatus::FW_SERIALIZE_OK) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } // now there should be nothing left, otherwise coding err - FW_ASSERT(argBuf.getBuffLeft() == 0, static_cast(argBuf.getBuffLeft())); + FW_ASSERT(argBuf.getDeserializeSizeLeft() == 0, + static_cast(argBuf.getDeserializeSizeLeft())); // and set the buf size now that we know it deserializedDirective.constCmd.set__argBufSize(cmdArgBufSize); @@ -238,10 +238,10 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::ITRUNC_64_16: case Fpy::DirectiveId::ITRUNC_64_32: { new (&deserializedDirective.stackOp) FpySequencer_StackOpDirective(); - if (argBuf.getBuffLeft() != 0) { + if (argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), Fw::SerializeStatus::FW_DESERIALIZE_SIZE_MISMATCH, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } deserializedDirective.stackOp.set__op(stmt.get_opCode()); @@ -249,10 +249,10 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc } case Fpy::DirectiveId::EXIT: { new (&deserializedDirective.exit) FpySequencer_ExitDirective(); - if (argBuf.getBuffLeft() != 0) { + if (argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), Fw::SerializeStatus::FW_DESERIALIZE_SIZE_MISMATCH, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -260,9 +260,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::ALLOCATE: { new (&deserializedDirective.allocate) FpySequencer_AllocateDirective(); status = argBuf.deserializeTo(deserializedDirective.allocate); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -270,9 +270,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::STORE_CONST_OFFSET: { new (&deserializedDirective.storeConstOffset) FpySequencer_StoreConstOffsetDirective(); status = argBuf.deserializeTo(deserializedDirective.storeConstOffset); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -280,9 +280,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::LOAD: { new (&deserializedDirective.load) FpySequencer_LoadDirective(); status = argBuf.deserializeTo(deserializedDirective.load); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -291,13 +291,13 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc new (&deserializedDirective.pushVal) FpySequencer_PushValDirective(); // how many bytes are left? - FwSizeType bufSize = argBuf.getBuffLeft(); + FwSizeType bufSize = argBuf.getDeserializeSizeLeft(); // check to make sure the value will fit in the FpySequencer_PushValDirective::val buf if (bufSize > Fpy::MAX_DIRECTIVE_SIZE) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), Fw::SerializeStatus::FW_DESERIALIZE_FORMAT_ERROR, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } @@ -307,12 +307,13 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc if (status != Fw::SerializeStatus::FW_SERIALIZE_OK) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } // now there should be nothing left, otherwise coding err - FW_ASSERT(argBuf.getBuffLeft() == 0, static_cast(argBuf.getBuffLeft())); + FW_ASSERT(argBuf.getDeserializeSizeLeft() == 0, + static_cast(argBuf.getDeserializeSizeLeft())); // and set the buf size now that we know it deserializedDirective.pushVal.set__valSize(bufSize); @@ -321,9 +322,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::DISCARD: { new (&deserializedDirective.discard) FpySequencer_DiscardDirective(); status = argBuf.deserializeTo(deserializedDirective.discard); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -331,9 +332,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::MEMCMP: { new (&deserializedDirective.memCmp) FpySequencer_MemCmpDirective(); status = argBuf.deserializeTo(deserializedDirective.memCmp); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -341,19 +342,19 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::STACK_CMD: { new (&deserializedDirective.stackCmd) FpySequencer_StackCmdDirective(); status = argBuf.deserializeTo(deserializedDirective.stackCmd); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; } case Fpy::DirectiveId::PUSH_TIME: { new (&deserializedDirective.pushTime) FpySequencer_PushTimeDirective(); - if (argBuf.getBuffLeft() != 0) { + if (argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), Fw::SerializeStatus::FW_DESERIALIZE_SIZE_MISMATCH, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -361,9 +362,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::SET_FLAG: { new (&deserializedDirective.setFlag) FpySequencer_SetFlagDirective(); status = argBuf.deserializeTo(deserializedDirective.setFlag); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -371,9 +372,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::GET_FLAG: { new (&deserializedDirective.getFlag) FpySequencer_GetFlagDirective(); status = argBuf.deserializeTo(deserializedDirective.getFlag); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -381,29 +382,29 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::GET_FIELD: { new (&deserializedDirective.getField) FpySequencer_GetFieldDirective(); status = argBuf.deserializeTo(deserializedDirective.getField); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; } case Fpy::DirectiveId::PEEK: { new (&deserializedDirective.peek) FpySequencer_PeekDirective(); - if (argBuf.getBuffLeft() != 0) { + if (argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), Fw::SerializeStatus::FW_DESERIALIZE_SIZE_MISMATCH, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; } case Fpy::DirectiveId::ASSERT: { new (&deserializedDirective.assert) FpySequencer_AssertDirective(); - if (argBuf.getBuffLeft() != 0) { + if (argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), Fw::SerializeStatus::FW_DESERIALIZE_SIZE_MISMATCH, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; @@ -411,9 +412,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc case Fpy::DirectiveId::STORE: { new (&deserializedDirective.store) FpySequencer_StoreDirective(); status = argBuf.deserializeTo(deserializedDirective.store); - if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getBuffLeft() != 0) { + if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) { this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status, - argBuf.getBuffLeft(), argBuf.getBuffLength()); + argBuf.getDeserializeSizeLeft(), argBuf.getSize()); return Fw::Success::FAILURE; } break; diff --git a/Svc/FpySequencer/FpySequencerValidationState.cpp b/Svc/FpySequencer/FpySequencerValidationState.cpp index 29ce74f719..fdf2edc03e 100644 --- a/Svc/FpySequencer/FpySequencerValidationState.cpp +++ b/Svc/FpySequencer/FpySequencerValidationState.cpp @@ -110,7 +110,7 @@ Fw::Success FpySequencer::readHeader() { if (deserStatus != Fw::SerializeStatus::FW_SERIALIZE_OK) { this->log_WARNING_HI_FileReadDeserializeError( FpySequencer_FileReadStage::HEADER, this->m_sequenceFilePath, static_cast(deserStatus), - this->m_sequenceBuffer.getBuffLeft(), this->m_sequenceBuffer.getBuffLength()); + this->m_sequenceBuffer.getDeserializeSizeLeft(), this->m_sequenceBuffer.getSize()); return Fw::Success::FAILURE; } @@ -148,7 +148,7 @@ Fw::Success FpySequencer::readBody() { if (deserStatus != Fw::FW_SERIALIZE_OK) { this->log_WARNING_HI_FileReadDeserializeError( FpySequencer_FileReadStage::BODY, this->m_sequenceFilePath, static_cast(deserStatus), - this->m_sequenceBuffer.getBuffLeft(), this->m_sequenceBuffer.getBuffLength()); + this->m_sequenceBuffer.getDeserializeSizeLeft(), this->m_sequenceBuffer.getSize()); return Fw::Success::FAILURE; } } @@ -160,7 +160,7 @@ Fw::Success FpySequencer::readBody() { if (deserStatus != Fw::FW_SERIALIZE_OK) { this->log_WARNING_HI_FileReadDeserializeError( FpySequencer_FileReadStage::BODY, this->m_sequenceFilePath, static_cast(deserStatus), - this->m_sequenceBuffer.getBuffLeft(), this->m_sequenceBuffer.getBuffLength()); + this->m_sequenceBuffer.getDeserializeSizeLeft(), this->m_sequenceBuffer.getSize()); return Fw::Success::FAILURE; } } @@ -174,7 +174,7 @@ Fw::Success FpySequencer::readFooter() { if (deserStatus != Fw::FW_SERIALIZE_OK) { this->log_WARNING_HI_FileReadDeserializeError( FpySequencer_FileReadStage::FOOTER, this->m_sequenceFilePath, static_cast(deserStatus), - this->m_sequenceBuffer.getBuffLeft(), this->m_sequenceBuffer.getBuffLength()); + this->m_sequenceBuffer.getDeserializeSizeLeft(), this->m_sequenceBuffer.getSize()); return Fw::Success::FAILURE; } @@ -199,7 +199,7 @@ Fw::Success FpySequencer::readBytes(Os::File& file, // this has to be declared a var because file.read must take a ref FwSizeType actualReadLen = expectedReadLen; - const FwSizeType capacity = this->m_sequenceBuffer.getBuffCapacity(); + const FwSizeType capacity = this->m_sequenceBuffer.getCapacity(); // if this fails, then you need to give the sequencer more buffer memory. pass in a bigger number // to fpySeq.allocateBuffer(). This is usually done in topology setup CPP diff --git a/Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp b/Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp index 2d980f6647..abc846f5d0 100644 --- a/Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp +++ b/Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp @@ -142,7 +142,7 @@ TEST_F(FpySequencerTester, pushTlmVal) { ASSERT_from_getTlmChan(0, 456, Fw::Time(), Fw::TlmBuffer()); ASSERT_EQ(tester_get_m_runtime_ptr()->stack.bytes[1], nextTlmValue.getBuffAddr()[0]); ASSERT_EQ(tester_get_m_runtime_ptr()->stack.bytes[2], nextTlmValue.getBuffAddr()[1]); - ASSERT_EQ(tester_get_m_runtime_ptr()->stack.size, nextTlmValue.getBuffLength() + 1); + ASSERT_EQ(tester_get_m_runtime_ptr()->stack.size, nextTlmValue.getSize() + 1); clearHistory(); // try getting a nonexistent chan @@ -175,7 +175,7 @@ TEST_F(FpySequencerTester, pushTlmValAndTime) { ASSERT_from_getTlmChan_SIZE(1); ASSERT_from_getTlmChan(0, 456, Fw::Time(), Fw::TlmBuffer()); ASSERT_EQ(tester_get_m_runtime_ptr()->stack.bytes[0], nextTlmValue.getBuffAddr()[0]); - ASSERT_EQ(tester_get_m_runtime_ptr()->stack.size, nextTlmValue.getBuffLength() + Fw::Time::SERIALIZED_SIZE); + ASSERT_EQ(tester_get_m_runtime_ptr()->stack.size, nextTlmValue.getSize() + Fw::Time::SERIALIZED_SIZE); Fw::Time deserTime; Fw::ExternalSerializeBuffer esb(tester_get_m_runtime_ptr()->stack.bytes + 1, Fw::Time::SERIALIZED_SIZE); esb.setBuffLen(Fw::Time::SERIALIZED_SIZE); @@ -215,7 +215,7 @@ TEST_F(FpySequencerTester, pushPrm) { ASSERT_from_getParam(0, 456, Fw::ParamBuffer()); ASSERT_EQ(tester_get_m_runtime_ptr()->stack.bytes[1], nextPrmValue.getBuffAddr()[0]); ASSERT_EQ(tester_get_m_runtime_ptr()->stack.bytes[2], nextPrmValue.getBuffAddr()[1]); - ASSERT_EQ(tester_get_m_runtime_ptr()->stack.size, nextPrmValue.getBuffLength() + 1); + ASSERT_EQ(tester_get_m_runtime_ptr()->stack.size, nextPrmValue.getSize() + 1); clearHistory(); // try getting a nonexistent param @@ -1755,7 +1755,7 @@ TEST_F(FpySequencerTester, readHeader) { // check not enough bytes tester_get_m_sequenceBuffer_ptr()->resetDeser(); - tester_get_m_sequenceBuffer_ptr()->setBuffLen(tester_get_m_sequenceBuffer_ptr()->getBuffLength() - 1); + tester_get_m_sequenceBuffer_ptr()->setBuffLen(tester_get_m_sequenceBuffer_ptr()->getSize() - 1); ASSERT_EQ(tester_readHeader(), Fw::Success::FAILURE); ASSERT_EVENTS_FileReadDeserializeError_SIZE(1); @@ -1859,7 +1859,7 @@ TEST_F(FpySequencerTester, readFooter) { ASSERT_EVENTS_WrongCRC_SIZE(1); // try not enough remaining - ASSERT_EQ(tester_get_m_sequenceBuffer_ptr()->setBuffLen(tester_get_m_sequenceBuffer_ptr()->getBuffLength() - 1), + ASSERT_EQ(tester_get_m_sequenceBuffer_ptr()->setBuffLen(tester_get_m_sequenceBuffer_ptr()->getSize() - 1), Fw::SerializeStatus::FW_SERIALIZE_OK); ASSERT_EQ(tester_readFooter(), Fw::Success::FAILURE); } @@ -1965,10 +1965,10 @@ TEST_F(FpySequencerTester, allocateBuffer) { Fw::MallocAllocator alloc; cmp.allocateBuffer(0, alloc, 100); ASSERT_NE(tester_get_m_sequenceBuffer_ptr()->getBuffAddr(), nullptr); - ASSERT_EQ(tester_get_m_sequenceBuffer_ptr()->getBuffCapacity(), 100); + ASSERT_EQ(tester_get_m_sequenceBuffer_ptr()->getCapacity(), 100); cmp.deallocateBuffer(alloc); ASSERT_EQ(tester_get_m_sequenceBuffer_ptr()->getBuffAddr(), nullptr); - ASSERT_EQ(tester_get_m_sequenceBuffer_ptr()->getBuffCapacity(), 0); + ASSERT_EQ(tester_get_m_sequenceBuffer_ptr()->getCapacity(), 0); } // caught a bug diff --git a/Svc/FpySequencer/test/ut/FpySequencerTester.cpp b/Svc/FpySequencer/test/ut/FpySequencerTester.cpp index 7ea16b8b75..1c245ba134 100644 --- a/Svc/FpySequencer/test/ut/FpySequencerTester.cpp +++ b/Svc/FpySequencer/test/ut/FpySequencerTester.cpp @@ -69,7 +69,7 @@ void FpySequencerTester::writeToFile(const char* name, FwSizeType maxBytes) { for (U32 ii = 0; ii < seq.get_header().get_statementCount(); ii++) { ASSERT_EQ(buf.serializeFrom(seq.get_statements()[ii]), Fw::SerializeStatus::FW_SERIALIZE_OK); } - seq.get_header().set_bodySize(static_cast(buf.getBuffLength())); + seq.get_header().set_bodySize(static_cast(buf.getSize())); buf.resetSer(); ASSERT_EQ(buf.serializeFrom(seq.get_header()), Fw::SerializeStatus::FW_SERIALIZE_OK); @@ -81,13 +81,13 @@ void FpySequencerTester::writeToFile(const char* name, FwSizeType maxBytes) { } U32 crc = FpySequencer::CRC_INITIAL_VALUE; - FpySequencer::updateCrc(crc, buf.getBuffAddr(), buf.getBuffLength()); + FpySequencer::updateCrc(crc, buf.getBuffAddr(), buf.getSize()); seq.get_footer().set_crc(~crc); ASSERT_EQ(buf.serializeFrom(seq.get_footer()), Fw::SerializeStatus::FW_SERIALIZE_OK); - FwSizeType intendedWriteSize = buf.getBuffLength(); + FwSizeType intendedWriteSize = buf.getSize(); if (intendedWriteSize > maxBytes) { intendedWriteSize = maxBytes; } diff --git a/Svc/FramingProtocol/test/ut/DeframingTester.cpp b/Svc/FramingProtocol/test/ut/DeframingTester.cpp index 7730b542fa..b3d6afa716 100644 --- a/Svc/FramingProtocol/test/ut/DeframingTester.cpp +++ b/Svc/FramingProtocol/test/ut/DeframingTester.cpp @@ -68,7 +68,7 @@ Fw::ByteArray DeframingTester ::constructRandomFrame(U32 packetSize) { status = sb.serializeFrom(byte); FW_ASSERT(status == Fw::FW_SERIALIZE_OK); } - const FwSizeType buffLength = sb.getBuffLength(); + const FwSizeType buffLength = sb.getSize(); const FwSizeType dataSize = FpFrameHeader::SIZE + packetSize; FW_ASSERT(buffLength == dataSize, static_cast(buffLength), static_cast(dataSize)); // Compute the hash value diff --git a/Svc/GenericHub/GenericHubComponentImpl.cpp b/Svc/GenericHub/GenericHubComponentImpl.cpp index 55a6bde515..af667a096e 100644 --- a/Svc/GenericHub/GenericHubComponentImpl.cpp +++ b/Svc/GenericHub/GenericHubComponentImpl.cpp @@ -45,7 +45,7 @@ void GenericHubComponentImpl ::send_data(const HubType type, FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast(status)); status = serialize.serializeFrom(data, size); FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast(status)); - outgoing.setSize(static_cast(serialize.getBuffLength())); + outgoing.setSize(static_cast(serialize.getSize())); dataOut_out(0, outgoing); } @@ -152,7 +152,7 @@ void GenericHubComponentImpl ::LogRecv_handler(const FwIndexType portNum, FW_ASSERT(status == Fw::SerializeStatus::FW_SERIALIZE_OK); status = serializer.serializeFrom(args); FW_ASSERT(status == Fw::SerializeStatus::FW_SERIALIZE_OK); - FwSizeType size = serializer.getBuffLength(); + FwSizeType size = serializer.getSize(); this->send_data(HubType::HUB_TYPE_EVENT, portNum, buffer, size); } @@ -170,7 +170,7 @@ void GenericHubComponentImpl ::TlmRecv_handler(const FwIndexType portNum, FW_ASSERT(status == Fw::SerializeStatus::FW_SERIALIZE_OK); status = serializer.serializeFrom(val); FW_ASSERT(status == Fw::SerializeStatus::FW_SERIALIZE_OK); - FwSizeType size = serializer.getBuffLength(); + FwSizeType size = serializer.getSize(); this->send_data(HubType::HUB_TYPE_CHANNEL, portNum, buffer, size); } @@ -181,7 +181,7 @@ void GenericHubComponentImpl ::TlmRecv_handler(const FwIndexType portNum, void GenericHubComponentImpl ::portIn_handler(FwIndexType portNum, /*!< The port number*/ Fw::SerializeBufferBase& Buffer /*!< The serialization buffer*/ ) { - send_data(HUB_TYPE_PORT, portNum, Buffer.getBuffAddr(), Buffer.getBuffLength()); + send_data(HUB_TYPE_PORT, portNum, Buffer.getBuffAddr(), Buffer.getSize()); } } // end namespace Svc diff --git a/Svc/GenericHub/test/ut/GenericHubTester.cpp b/Svc/GenericHub/test/ut/GenericHubTester.cpp index e6649f00fb..363082178b 100644 --- a/Svc/GenericHub/test/ut/GenericHubTester.cpp +++ b/Svc/GenericHub/test/ut/GenericHubTester.cpp @@ -199,8 +199,8 @@ void GenericHubTester ::from_portOut_handler(FwIndexType portNum, /*! m_comm_out++; // Assert the buffer came through exactly on the right port ASSERT_EQ(portNum, m_current_port); - ASSERT_EQ(Buffer.getBuffLength(), m_comm.getBuffLength()); - for (U32 i = 0; i < Buffer.getBuffLength(); i++) { + ASSERT_EQ(Buffer.getSize(), m_comm.getSize()); + for (U32 i = 0; i < Buffer.getSize(); i++) { ASSERT_EQ(Buffer.getBuffAddr()[i], m_comm.getBuffAddr()[i]); } ASSERT_from_buffersOut_SIZE(0); diff --git a/Svc/OsTime/test/RawTimeTester/RawTimeTester.hpp b/Svc/OsTime/test/RawTimeTester/RawTimeTester.hpp index da48960ff6..320b370442 100644 --- a/Svc/OsTime/test/RawTimeTester/RawTimeTester.hpp +++ b/Svc/OsTime/test/RawTimeTester/RawTimeTester.hpp @@ -48,12 +48,12 @@ class RawTimeTester : public Os::RawTimeInterface { return OP_OK; } - Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase& buffer, + Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override { return buffer.serializeFrom(m_handle.t, mode); } - Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase& buffer, + Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override { return buffer.deserializeTo(m_handle.t, mode); } diff --git a/Svc/PrmDb/PrmDbImpl.cpp b/Svc/PrmDb/PrmDbImpl.cpp index fb8b7c4d7b..d0a4e05c99 100644 --- a/Svc/PrmDb/PrmDbImpl.cpp +++ b/Svc/PrmDb/PrmDbImpl.cpp @@ -22,7 +22,7 @@ namespace Svc { namespace { class WorkingBuffer : public Fw::SerializeBufferBase { public: - FwSizeType getBuffCapacity() const { return sizeof(m_buff); } + FwSizeType getCapacity() const { return sizeof(m_buff); } U8* getBuffAddr() { return m_buff; } @@ -167,7 +167,7 @@ void PrmDbImpl::PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { return; } // serialize record size = id field + data - U32 recordSize = static_cast(sizeof(FwPrmIdType) + db[entry].val.getBuffLength()); + U32 recordSize = static_cast(sizeof(FwPrmIdType) + db[entry].val.getSize()); // reset buffer buff.resetSer(); @@ -176,7 +176,7 @@ void PrmDbImpl::PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { FW_ASSERT(Fw::FW_SERIALIZE_OK == serStat, static_cast(serStat)); // write record size - writeSize = static_cast(buff.getBuffLength()); + writeSize = static_cast(buff.getSize()); stat = paramFile.write(buff.getBuffAddr(), writeSize, Os::File::WaitType::WAIT); if (stat != Os::File::OP_OK) { this->unLock(); @@ -202,7 +202,7 @@ void PrmDbImpl::PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { FW_ASSERT(Fw::FW_SERIALIZE_OK == serStat, static_cast(serStat)); // write parameter ID - writeSize = static_cast(buff.getBuffLength()); + writeSize = static_cast(buff.getSize()); stat = paramFile.write(buff.getBuffAddr(), writeSize, Os::File::WaitType::WAIT); if (stat != Os::File::OP_OK) { this->unLock(); @@ -210,7 +210,7 @@ void PrmDbImpl::PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR); return; } - if (writeSize != static_cast(buff.getBuffLength())) { + if (writeSize != static_cast(buff.getSize())) { this->unLock(); this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::PARAMETER_ID_SIZE, static_cast(numRecords), static_cast(writeSize)); @@ -220,7 +220,7 @@ void PrmDbImpl::PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { // write serialized parameter value - writeSize = static_cast(db[entry].val.getBuffLength()); + writeSize = static_cast(db[entry].val.getSize()); stat = paramFile.write(db[entry].val.getBuffAddr(), writeSize, Os::File::WaitType::WAIT); if (stat != Os::File::OP_OK) { this->unLock(); @@ -229,7 +229,7 @@ void PrmDbImpl::PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR); return; } - if (writeSize != static_cast(db[entry].val.getBuffLength())) { + if (writeSize != static_cast(db[entry].val.getSize())) { this->unLock(); this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::PARAMETER_VALUE_SIZE, static_cast(numRecords), static_cast(writeSize)); diff --git a/Svc/PrmDb/PrmDbImpl.hpp b/Svc/PrmDb/PrmDbImpl.hpp index 1cedbf0c4e..6e9e1bfc29 100644 --- a/Svc/PrmDb/PrmDbImpl.hpp +++ b/Svc/PrmDb/PrmDbImpl.hpp @@ -96,10 +96,10 @@ class PrmDbImpl final : public PrmDbComponentBase { if (id != other.id) return false; // Compare lengths first - if (val.getBuffLength() != other.val.getBuffLength()) + if (val.getSize() != other.val.getSize()) return false; // Compare buffer contents - return std::memcmp(val.getBuffAddr(), other.val.getBuffAddr(), val.getBuffLength()) == 0; + return std::memcmp(val.getBuffAddr(), other.val.getBuffAddr(), val.getSize()) == 0; } }; diff --git a/Svc/PrmDb/test/ut/PrmDbTester.cpp b/Svc/PrmDb/test/ut/PrmDbTester.cpp index f2ca47ba82..11622b1c41 100644 --- a/Svc/PrmDb/test/ut/PrmDbTester.cpp +++ b/Svc/PrmDb/test/ut/PrmDbTester.cpp @@ -1352,7 +1352,7 @@ void PrmDbTester::printDb(PrmDb_PrmDbType dbType) { printf("%s Parameter DB @ %p \n", PrmDbImpl::getDbString(dbType).toChar(), static_cast(db)); for (FwSizeType entry = 0; entry < PRMDB_NUM_DB_ENTRIES; entry++) { U8* data = db[entry].val.getBuffAddr(); - FwSizeType len = db[entry].val.getBuffLength(); + FwSizeType len = db[entry].val.getSize(); if (db[entry].used) { std::cout << " " << std::setw(2) << entry << " :"; printf(" ID = %08X", db[entry].id); diff --git a/Svc/TlmChan/test/ut/TlmChanTester.cpp b/Svc/TlmChan/test/ut/TlmChanTester.cpp index cf17402707..b67f6c6831 100644 --- a/Svc/TlmChan/test/ut/TlmChanTester.cpp +++ b/Svc/TlmChan/test/ut/TlmChanTester.cpp @@ -129,7 +129,7 @@ void TlmChanTester::runOffNominal() { // Read back value Fw::TlmValid valid = this->invoke_to_TlmGet(0, 10, timeTag, buff); - ASSERT_EQ(0u, buff.getBuffLength()); + ASSERT_EQ(0u, buff.getSize()); ASSERT_EQ(valid, Fw::TlmValid::INVALID); } @@ -218,7 +218,7 @@ void TlmChanTester::checkBuff(FwChanIdType chanNum, FwChanIdType totalChan, FwCh } // packet should be empty - ASSERT_EQ(0, this->m_rcvdBuffer[packet].getBuffLeft()); + ASSERT_EQ(0, this->m_rcvdBuffer[packet].getDeserializeSizeLeft()); } } diff --git a/Svc/TlmPacketizer/TlmPacketizer.cpp b/Svc/TlmPacketizer/TlmPacketizer.cpp index 9b2a16066e..fcfba85eec 100644 --- a/Svc/TlmPacketizer/TlmPacketizer.cpp +++ b/Svc/TlmPacketizer/TlmPacketizer.cpp @@ -235,7 +235,7 @@ void TlmPacketizer ::TlmRecv_handler(const FwIndexType portNum, this->m_fillBuffers[pkt].updated = true; this->m_fillBuffers[pkt].latestTime = timeTag; U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entryToUse->packetOffset[pkt]]; - (void)memcpy(ptr, val.getBuffAddr(), static_cast(val.getBuffLength())); + (void)memcpy(ptr, val.getBuffAddr(), static_cast(val.getSize())); // record that this chan has a value. could do this outside of the loop only once // but then we'd need to grab the lock again. entryToUse->hasValue = true; @@ -294,8 +294,8 @@ Fw::TlmValid TlmPacketizer ::TlmGet_handler(FwIndexType portNum, //!< The port } // make sure we have enough space to store this entry in our buf - FW_ASSERT(entryToUse->channelSize <= val.getBuffCapacity(), static_cast(entryToUse->channelSize), - static_cast(val.getBuffCapacity())); + FW_ASSERT(entryToUse->channelSize <= val.getCapacity(), static_cast(entryToUse->channelSize), + static_cast(val.getCapacity())); // okay, we have the matching entry. // go over each packet and find the first one which stores this channel diff --git a/Svc/TlmPacketizer/test/ut/TlmPacketizerTester.cpp b/Svc/TlmPacketizer/test/ut/TlmPacketizerTester.cpp index 1abb84e18b..275b3a49ad 100644 --- a/Svc/TlmPacketizer/test/ut/TlmPacketizerTester.cpp +++ b/Svc/TlmPacketizer/test/ut/TlmPacketizerTester.cpp @@ -909,7 +909,7 @@ void TlmPacketizerTester ::getChannelValueTest() { Fw::TlmBuffer val; Fw::TlmValid valid = this->invoke_to_TlmGet(0, 10, time, val); // hasn't received a value yet - ASSERT_EQ(val.getBuffLength(), 0); + ASSERT_EQ(val.getSize(), 0); ASSERT_EQ(valid, Fw::TlmValid::INVALID); Fw::Time timeIn(123, 456); @@ -919,14 +919,14 @@ void TlmPacketizerTester ::getChannelValueTest() { valid = this->invoke_to_TlmGet(0, 10, time, val); // should have a value - ASSERT_EQ(val.getBuffLength(), 4); + ASSERT_EQ(val.getSize(), 4); ASSERT_EQ(time, timeIn); ASSERT_EQ(valid, Fw::TlmValid::VALID); // grab an ignored chan valid = this->invoke_to_TlmGet(0, 25, time, val); // should not have a value - ASSERT_EQ(val.getBuffLength(), 0); + ASSERT_EQ(val.getSize(), 0); ASSERT_EQ(valid, Fw::TlmValid::INVALID); // grab a nonexistent chan @@ -934,7 +934,7 @@ void TlmPacketizerTester ::getChannelValueTest() { val.setBuffLen(4); valid = this->invoke_to_TlmGet(0, 9123, time, val); // should not have a value - ASSERT_EQ(val.getBuffLength(), 0); + ASSERT_EQ(val.getSize(), 0); ASSERT_EQ(valid, Fw::TlmValid::INVALID); } diff --git a/Utils/Hash/HashBuffer.hpp b/Utils/Hash/HashBuffer.hpp index 28116ca017..433b34619a 100644 --- a/Utils/Hash/HashBuffer.hpp +++ b/Utils/Hash/HashBuffer.hpp @@ -57,7 +57,8 @@ class HashBuffer : public Fw::SerializeBufferBase { //! Get the total buffer length of a hash buffer //! - FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer + DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead"); + FwSizeType getCapacity() const; // !< returns capacity, not current size, of buffer //! Get a pointer to the buffer within the hash buffer //! diff --git a/Utils/Hash/HashBufferCommon.cpp b/Utils/Hash/HashBufferCommon.cpp index 12bd95c3de..5fbadc07c3 100644 --- a/Utils/Hash/HashBufferCommon.cpp +++ b/Utils/Hash/HashBufferCommon.cpp @@ -17,7 +17,7 @@ HashBuffer::HashBuffer(const U8* args, FwSizeType size) : Fw::SerializeBufferBas HashBuffer::~HashBuffer() {} HashBuffer::HashBuffer(const HashBuffer& other) : Fw::SerializeBufferBase() { - Fw::SerializeStatus stat = Fw::SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + Fw::SerializeStatus stat = Fw::SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast(stat)); } @@ -26,14 +26,14 @@ HashBuffer& HashBuffer::operator=(const HashBuffer& other) { return *this; } - Fw::SerializeStatus stat = Fw::SerializeBufferBase::setBuff(other.m_bufferData, other.getBuffLength()); + Fw::SerializeStatus stat = Fw::SerializeBufferBase::setBuff(other.m_bufferData, other.getSize()); FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast(stat)); return *this; } bool HashBuffer::operator==(const HashBuffer& other) const { - if ((this->getBuffLength() == other.getBuffLength()) && - (memcmp(this->getBuffAddr(), other.getBuffAddr(), static_cast(this->getBuffLength())) != 0)) { + if ((this->getSize() == other.getSize()) && + (memcmp(this->getBuffAddr(), other.getBuffAddr(), static_cast(this->getSize())) != 0)) { return false; } return true; @@ -51,10 +51,14 @@ U8* HashBuffer::getBuffAddr() { return this->m_bufferData; } -FwSizeType HashBuffer::getBuffCapacity() const { +FwSizeType HashBuffer::getCapacity() const { return sizeof(this->m_bufferData); } +FwSizeType HashBuffer::getBuffCapacity() const { + return this->getCapacity(); +} + U32 HashBuffer::asBigEndianU32() const { U32 result = 0; const FwSizeType bufferSize = sizeof this->m_bufferData; diff --git a/docs/how-to/custom-framing.md b/docs/how-to/custom-framing.md index 880e83439d..fcff17cf66 100644 --- a/docs/how-to/custom-framing.md +++ b/docs/how-to/custom-framing.md @@ -46,7 +46,7 @@ Before implementing, consider these best practices: 1. **Centralize Protocol Constants**: Define protocol constants (e.g., start word, header structure, field sizes) in a dedicated `.fpp` types file (e.g., `Types/Types.fpp`). This allows constants like start words, field types, or spacecraft IDs to be reused consistently across your framer, deframer, and frame detector. -2. **Endianness Convention**: F´ serializes all integer types in big-endian by default (network byte order), as defined in `Fw::Serializable`. If your protocol requires little-endian fields, you must specify so during serialization with the `Fw::Endianness::LITTLE` mode, or manually order bytes as needed. +2. **Endianness Convention**: F´ serializes all integer types in big-endian by default (network byte order), as defined in `Fw::Serializable`. If your protocol requires little-endian fields, you must specify so during serialization with the `Fw::Endianness::LITTLE` mode, or manually order bytes as needed. Payload serialization and deserialization target the `Fw::SerialBufferBase` interface, so user-defined serializable types can use `serializeTo`/`deserializeFrom` with a compatible buffer. 3. **Set the APID in the Deframer**: Your deframer **must** extract and set the APID (Application ID) in the `FrameContext` before emitting packets downstream via `dataOut`. Without this, the `Svc.FprimeRouter` will not know where to route packets to. This is a critical requirement, unless you are also implementing a custom router and define your own requirements (not recommended and outside the scope of this guide). diff --git a/docs/user-manual/framework/dynamic-memory.md b/docs/user-manual/framework/dynamic-memory.md index 3d3ef15713..b3275d9749 100644 --- a/docs/user-manual/framework/dynamic-memory.md +++ b/docs/user-manual/framework/dynamic-memory.md @@ -65,7 +65,9 @@ serialization representation of the buffer. To use this method, get either a serializer or deserializer using the `Fw::Buffer.getSerializer()` or `Fw::Buffer.getDeserializer()` methods. Both of these methods return a `Fw::ExternalSerializeBufferWithMemberCopy` -object which you can then call `.serializeFrom()` or `.deserializeTo()` on. +object which you can then call `.serializeFrom()` or `.deserializeTo()` on. This object implements the +`Fw::SerialBufferBase` interface, so it can also be passed directly to `Fw::Serializable::serializeTo` and +`Fw::Serializable::deserializeFrom` methods. **Example Using Serialization and Deserialization Methods** diff --git a/docs/user-manual/overview/05-enum-arr-ser.md b/docs/user-manual/overview/05-enum-arr-ser.md index b735fe51b6..0a1c75defd 100644 --- a/docs/user-manual/overview/05-enum-arr-ser.md +++ b/docs/user-manual/overview/05-enum-arr-ser.md @@ -119,6 +119,24 @@ arbitrary C++ `class`/`struct` types. If these types are to be passed through a should be defined as subclasses of the `Fw::Serializable` and define `serializeTo` and `deserializeFrom` methods to be called to perform the serialization. +Specifically, user-defined serializable classes must implement the following methods, which operate on the +`Fw::SerialBufferBase` interface and support selectable endianness (default: big-endian): + +```cpp +Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& buffer, + Fw::Endianness mode = Fw::Endianness::BIG) const; + +Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer, + Fw::Endianness mode = Fw::Endianness::BIG); +``` + +Notes: + +- `Fw::SerialBufferBase` is the abstract buffer interface accepted by `Fw::Serializable` APIs. Concrete buffers such as + `Fw::SerializeBufferBase` and helper wrappers like `Fw::ExternalSerializeBufferWithMemberCopy` implement this interface. +- Endianness defaults to `Fw::Endianness::BIG` (network byte order). Pass `Fw::Endianness::LITTLE` to serialize or + deserialize fields in little-endian. + ## Alias Types Alias types provide an alternate name for a type that is defined elsewhere. An alias type can refer to any type, including another alias type (excluding itself). diff --git a/requirements.txt b/requirements.txt index 5c8961f9af..818d1105ac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,7 @@ Flask-Compress==1.15 Flask-RESTful==0.3.10 fprime-fpl-layout==1.0.3 fprime-fpl-write-pic==1.0.3 -fprime-fpp==3.1.0a7 +fprime-fpp==3.1.0a8 fprime-gds==4.0.2a9 fprime-tools==4.0.2a1 fprime-visual==1.0.2