Created new SerialBufferBase as a parent of SerializeBufferBase (now renamed LinearBufferBase). (#4288)

* Created new SerialBufferBase as a parent of SerializeBufferBase. Renaming interface functions to be less confusing.

* Deprecating copyRawOffset. No direct use-cases in F' core.

* Make SerialBufferBase a true pure virtual interface.

* Changing Serializable to work with SerialBufferBase parent interface.

* Changing copyRaw and copyRawOffset to work with SerialBufferBase

* Updating documentation for SerialBufferBase usage

* Adding some documentation. Adding missing ASSERT in copyRaw. Fixing some bugs that new ASSERT uncovered.

* Renaming SerializeBufferBase to LinearBufferBase. Add a using declaration to maintain backwards compatability. Properly mark LinearBufferBase functions as override.

* Filling in the rest of the docstrings for the classes in Serializable

* Removing redundant virtual keyword on override function

* Applying clang formatting

* Incorporating PR comments

* Fix compile issues

* Bump version to alpha

* Format

* v

---------

Co-authored-by: M Starch <LeStarch@googlemail.com>
This commit is contained in:
Vince Woo 2025-11-06 16:23:20 -08:00 committed by GitHub
parent b254e981a1
commit 48e4720419
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
127 changed files with 2026 additions and 692 deletions

View File

@ -13,7 +13,7 @@ DataBuffer::DataBuffer() {}
DataBuffer::~DataBuffer() {} DataBuffer::~DataBuffer() {}
DataBuffer::DataBuffer(const DataBuffer& other) : Fw::SerializeBufferBase() { 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<FwAssertArgType>(stat)); FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
} }
@ -22,15 +22,19 @@ DataBuffer& DataBuffer::operator=(const DataBuffer& other) {
return *this; 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<FwAssertArgType>(stat)); FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
return *this; return *this;
} }
FwSizeType DataBuffer::getBuffCapacity() const { FwSizeType DataBuffer::getCapacity() const {
return sizeof(this->m_data); return sizeof(this->m_data);
} }
FwSizeType DataBuffer::getBuffCapacity() const {
return this->getCapacity();
}
const U8* DataBuffer::getBuffAddr() const { const U8* DataBuffer::getBuffAddr() const {
return this->m_data; return this->m_data;
} }

View File

@ -20,7 +20,9 @@ class DataBuffer : public Fw::SerializeBufferBase {
virtual ~DataBuffer(); virtual ~DataBuffer();
DataBuffer& operator=(const DataBuffer& other); 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(); U8* getBuffAddr();
const U8* getBuffAddr() const; const U8* getBuffAddr() const;

View File

@ -25,38 +25,38 @@ ActiveTest ::~ActiveTest() {}
// Handler implementations for user-defined serial input ports // Handler implementations for user-defined serial input ports
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
void ActiveTest ::serialAsync_handler(FwIndexType portNum, //!< The port number void ActiveTest ::serialAsync_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& Buffer //!< The serialization buffer Fw::LinearBufferBase& Buffer //!< The serialization buffer
) { ) {
this->serializeStatus = this->serialOut_out(portNum, Buffer); this->serializeStatus = this->serialOut_out(portNum, Buffer);
} }
void ActiveTest ::serialAsyncAssert_handler(FwIndexType portNum, //!< The port number void ActiveTest ::serialAsyncAssert_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& Buffer //!< The serialization buffer Fw::LinearBufferBase& Buffer //!< The serialization buffer
) { ) {
this->serializeStatus = this->serialOut_out(SerialPortIndex::ENUM, Buffer); this->serializeStatus = this->serialOut_out(SerialPortIndex::ENUM, Buffer);
} }
void ActiveTest ::serialAsyncBlockPriority_handler(FwIndexType portNum, //!< The port number void ActiveTest ::serialAsyncBlockPriority_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& Buffer //!< The serialization buffer Fw::LinearBufferBase& Buffer //!< The serialization buffer
) { ) {
this->serializeStatus = this->serialOut_out(SerialPortIndex::ARRAY, Buffer); this->serializeStatus = this->serialOut_out(SerialPortIndex::ARRAY, Buffer);
} }
void ActiveTest ::serialAsyncDropPriority_handler(FwIndexType portNum, //!< The port number void ActiveTest ::serialAsyncDropPriority_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& Buffer //!< The serialization buffer Fw::LinearBufferBase& Buffer //!< The serialization buffer
) { ) {
this->serializeStatus = this->serialOut_out(SerialPortIndex::STRUCT, Buffer); this->serializeStatus = this->serialOut_out(SerialPortIndex::STRUCT, Buffer);
} }
void ActiveTest ::serialGuarded_handler(FwIndexType portNum, //!< The port number void ActiveTest ::serialGuarded_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& Buffer //!< The serialization buffer Fw::LinearBufferBase& Buffer //!< The serialization buffer
) { ) {
this->serializeStatus = this->serialOut_out(portNum, Buffer); this->serializeStatus = this->serialOut_out(portNum, Buffer);
} }
void ActiveTest ::serialSync_handler(FwIndexType portNum, //!< The port number void ActiveTest ::serialSync_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& Buffer //!< The serialization buffer Fw::LinearBufferBase& Buffer //!< The serialization buffer
) { ) {
this->serializeStatus = this->serialOut_out(portNum, Buffer); this->serializeStatus = this->serialOut_out(portNum, Buffer);
} }

View File

@ -34,33 +34,33 @@ class ActiveTest : public ActiveTestComponentBase {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
//! Handler implementation for serialAsync //! Handler implementation for serialAsync
void serialAsync_handler(FwIndexType portNum, //!< The port number void serialAsync_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& buffer //!< The serialization buffer Fw::LinearBufferBase& buffer //!< The serialization buffer
) override; ) override;
//! Handler implementation for serialAsyncAssert //! Handler implementation for serialAsyncAssert
void serialAsyncAssert_handler(FwIndexType portNum, //!< The port number void serialAsyncAssert_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& buffer //!< The serialization buffer Fw::LinearBufferBase& buffer //!< The serialization buffer
) override; ) override;
//! Handler implementation for serialAsyncBlockPriority //! Handler implementation for serialAsyncBlockPriority
void serialAsyncBlockPriority_handler(FwIndexType portNum, //!< The port number void serialAsyncBlockPriority_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& buffer //!< The serialization buffer Fw::LinearBufferBase& buffer //!< The serialization buffer
) override; ) override;
//! Handler implementation for serialAsyncDropPriority //! Handler implementation for serialAsyncDropPriority
void serialAsyncDropPriority_handler(FwIndexType portNum, //!< The port number void serialAsyncDropPriority_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& buffer //!< The serialization buffer Fw::LinearBufferBase& buffer //!< The serialization buffer
) override; ) override;
//! Handler implementation for serialGuarded //! Handler implementation for serialGuarded
void serialGuarded_handler(FwIndexType portNum, //!< The port number void serialGuarded_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& buffer //!< The serialization buffer Fw::LinearBufferBase& buffer //!< The serialization buffer
) override; ) override;
//! Handler implementation for serialSync //! Handler implementation for serialSync
void serialSync_handler(FwIndexType portNum, //!< The port number void serialSync_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& buffer //!< The serialization buffer Fw::LinearBufferBase& buffer //!< The serialization buffer
) override; ) override;
private: private:

View File

@ -130,7 +130,7 @@ Fw::SerializeStatus ActiveTestTester::ActiveTestComponentBaseParamExternalDelega
const FwPrmIdType base_id, const FwPrmIdType base_id,
const FwPrmIdType local_id, const FwPrmIdType local_id,
const Fw::ParamValid prmStat, const Fw::ParamValid prmStat,
Fw::SerializeBufferBase& buff) { Fw::SerialBufferBase& buff) {
Fw::SerializeStatus stat; Fw::SerializeStatus stat;
(void)base_id; (void)base_id;
@ -171,7 +171,7 @@ Fw::SerializeStatus ActiveTestTester::ActiveTestComponentBaseParamExternalDelega
Fw::SerializeStatus ActiveTestTester::ActiveTestComponentBaseParamExternalDelegate ::serializeParam( Fw::SerializeStatus ActiveTestTester::ActiveTestComponentBaseParamExternalDelegate ::serializeParam(
const FwPrmIdType base_id, const FwPrmIdType base_id,
const FwPrmIdType local_id, const FwPrmIdType local_id,
Fw::SerializeBufferBase& buff) const { Fw::SerialBufferBase& buff) const {
Fw::SerializeStatus stat; Fw::SerializeStatus stat;
(void)base_id; (void)base_id;

View File

@ -226,14 +226,13 @@ class ActiveTestTester : public ActiveTestGTestBase {
const FwPrmIdType base_id, //!< The component base parameter ID to deserialize const FwPrmIdType base_id, //!< The component base parameter ID to deserialize
const FwPrmIdType local_id, //!< The parameter local ID to deserialize const FwPrmIdType local_id, //!< The parameter local ID to deserialize
const Fw::ParamValid prmStat, //!< The parameter validity status 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; ) override;
//! Parameter serialization function for external parameter unit testing //! Parameter serialization function for external parameter unit testing
Fw::SerializeStatus serializeParam( Fw::SerializeStatus serializeParam(const FwPrmIdType base_id, //!< The component base parameter ID to serialize
const FwPrmIdType base_id, //!< The component base parameter ID to serialize const FwPrmIdType local_id, //!< The parameter local ID to serialize
const FwPrmIdType local_id, //!< The parameter local ID to serialize Fw::SerialBufferBase& buff //!< The buffer to serialize the parameter into
Fw::SerializeBufferBase& buff //!< The buffer to serialize the parameter into
) const override; ) const override;
}; };

View File

@ -129,7 +129,7 @@ Fw::SerializeStatus PassiveTestTester::PassiveTestComponentBaseParamExternalDele
const FwPrmIdType base_id, const FwPrmIdType base_id,
const FwPrmIdType local_id, const FwPrmIdType local_id,
const Fw::ParamValid prmStat, const Fw::ParamValid prmStat,
Fw::SerializeBufferBase& buff) { Fw::SerialBufferBase& buff) {
Fw::SerializeStatus stat; Fw::SerializeStatus stat;
(void)base_id; (void)base_id;
@ -170,7 +170,7 @@ Fw::SerializeStatus PassiveTestTester::PassiveTestComponentBaseParamExternalDele
Fw::SerializeStatus PassiveTestTester::PassiveTestComponentBaseParamExternalDelegate ::serializeParam( Fw::SerializeStatus PassiveTestTester::PassiveTestComponentBaseParamExternalDelegate ::serializeParam(
const FwPrmIdType base_id, const FwPrmIdType base_id,
const FwPrmIdType local_id, const FwPrmIdType local_id,
Fw::SerializeBufferBase& buff) const { Fw::SerialBufferBase& buff) const {
Fw::SerializeStatus stat; Fw::SerializeStatus stat;
(void)base_id; (void)base_id;

View File

@ -210,14 +210,13 @@ class PassiveTestTester : public PassiveTestGTestBase {
const FwPrmIdType base_id, //!< The component base parameter ID to deserialize const FwPrmIdType base_id, //!< The component base parameter ID to deserialize
const FwPrmIdType local_id, //!< The parameter local ID to deserialize const FwPrmIdType local_id, //!< The parameter local ID to deserialize
const Fw::ParamValid prmStat, //!< The parameter validity status 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; ) override;
//! Parameter serialization function for external parameter unit testing //! Parameter serialization function for external parameter unit testing
Fw::SerializeStatus serializeParam( Fw::SerializeStatus serializeParam(const FwPrmIdType base_id, //!< The component base parameter ID to serialize
const FwPrmIdType base_id, //!< The component base parameter ID to serialize const FwPrmIdType local_id, //!< The parameter local ID to serialize
const FwPrmIdType local_id, //!< The parameter local ID to serialize Fw::SerialBufferBase& buff //!< The buffer to serialize the parameter into
Fw::SerializeBufferBase& buff //!< The buffer to serialize the parameter into
) const override; ) const override;
}; };

View File

@ -130,7 +130,7 @@ Fw::SerializeStatus QueuedTestTester::QueuedTestComponentBaseParamExternalDelega
const FwPrmIdType base_id, const FwPrmIdType base_id,
const FwPrmIdType local_id, const FwPrmIdType local_id,
const Fw::ParamValid prmStat, const Fw::ParamValid prmStat,
Fw::SerializeBufferBase& buff) { Fw::SerialBufferBase& buff) {
Fw::SerializeStatus stat; Fw::SerializeStatus stat;
(void)base_id; (void)base_id;
@ -171,7 +171,7 @@ Fw::SerializeStatus QueuedTestTester::QueuedTestComponentBaseParamExternalDelega
Fw::SerializeStatus QueuedTestTester::QueuedTestComponentBaseParamExternalDelegate ::serializeParam( Fw::SerializeStatus QueuedTestTester::QueuedTestComponentBaseParamExternalDelegate ::serializeParam(
const FwPrmIdType base_id, const FwPrmIdType base_id,
const FwPrmIdType local_id, const FwPrmIdType local_id,
Fw::SerializeBufferBase& buff) const { Fw::SerialBufferBase& buff) const {
Fw::SerializeStatus stat; Fw::SerializeStatus stat;
(void)base_id; (void)base_id;

View File

@ -82,8 +82,8 @@ class QueuedTestTester : public QueuedTestGTestBase {
//! Handler for from_serialOut //! Handler for from_serialOut
//! //!
void from_serialOut_handler(FwIndexType portNum, //!< The port number void from_serialOut_handler(FwIndexType portNum, //!< The port number
Fw::SerializeBufferBase& Buffer //!< The serialization buffer Fw::LinearBufferBase& Buffer //!< The serialization buffer
); );
public: public:
@ -227,14 +227,13 @@ class QueuedTestTester : public QueuedTestGTestBase {
const FwPrmIdType base_id, //!< The component base parameter ID to deserialize const FwPrmIdType base_id, //!< The component base parameter ID to deserialize
const FwPrmIdType local_id, //!< The parameter local ID to deserialize const FwPrmIdType local_id, //!< The parameter local ID to deserialize
const Fw::ParamValid prmStat, //!< The parameter validity status 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; ) override;
//! Parameter serialization function for external parameter unit testing //! Parameter serialization function for external parameter unit testing
Fw::SerializeStatus serializeParam( Fw::SerializeStatus serializeParam(const FwPrmIdType base_id, //!< The component base parameter ID to serialize
const FwPrmIdType base_id, //!< The component base parameter ID to serialize const FwPrmIdType local_id, //!< The parameter local ID to serialize
const FwPrmIdType local_id, //!< The parameter local ID to serialize Fw::SerialBufferBase& buff //!< The buffer to serialize the parameter into
Fw::SerializeBufferBase& buff //!< The buffer to serialize the parameter into
) const override; ) const override;
}; };

View File

@ -139,23 +139,23 @@ void Tester ::from_serialOut_handler(FwIndexType portNum, //!< The p
break; break;
case SerialPortIndex::PRIMITIVE: case SerialPortIndex::PRIMITIVE:
status = Buffer.copyRaw(this->primitiveBuf, Buffer.getBuffCapacity()); status = Buffer.copyRaw(this->primitiveBuf, Buffer.getDeserializeSizeLeft());
break; break;
case SerialPortIndex::STRING: case SerialPortIndex::STRING:
status = Buffer.copyRaw(this->stringBuf, Buffer.getBuffCapacity()); status = Buffer.copyRaw(this->stringBuf, Buffer.getDeserializeSizeLeft());
break; break;
case SerialPortIndex::ENUM: case SerialPortIndex::ENUM:
status = Buffer.copyRaw(this->enumBuf, Buffer.getBuffCapacity()); status = Buffer.copyRaw(this->enumBuf, Buffer.getDeserializeSizeLeft());
break; break;
case SerialPortIndex::ARRAY: case SerialPortIndex::ARRAY:
status = Buffer.copyRaw(this->arrayBuf, Buffer.getBuffCapacity()); status = Buffer.copyRaw(this->arrayBuf, Buffer.getDeserializeSizeLeft());
break; break;
case SerialPortIndex::STRUCT: case SerialPortIndex::STRUCT:
status = Buffer.copyRaw(this->structBuf, Buffer.getBuffCapacity()); status = Buffer.copyRaw(this->structBuf, Buffer.getDeserializeSizeLeft());
break; break;
} }

View File

@ -48,14 +48,14 @@ struct TestAbsType final : public Fw::Serializable {
//! Serialize function //! Serialize function
//! \return Status //! \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 { Fw::Endianness mode = Fw::Endianness::BIG) const final {
return sbb.serializeFrom(this->m_data, mode); return sbb.serializeFrom(this->m_data, mode);
} }
//! Deserialize method //! Deserialize method
//! \return status //! \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 { Fw::Endianness mode = Fw::Endianness::BIG) final {
return sbb.deserializeTo(this->m_data, mode); return sbb.deserializeTo(this->m_data, mode);
} }

View File

@ -77,7 +77,7 @@ void ChoiceToChoiceTester ::smChoiceChoiceToChoice_stateMachineOverflowHook(SmId
this->m_hookCalled = true; this->m_hookCalled = true;
ASSERT_EQ(smId, SmId::smChoiceChoiceToChoice); ASSERT_EQ(smId, SmId::smChoiceChoiceToChoice);
ASSERT_EQ(static_cast<SmChoice_ChoiceToChoice::Signal>(signal), SmChoice_ChoiceToChoice::Signal::s); ASSERT_EQ(static_cast<SmChoice_ChoiceToChoice::Signal>(signal), SmChoice_ChoiceToChoice::Signal::s);
ASSERT_EQ(buffer.getBuffLeft(), 0); ASSERT_EQ(buffer.getDeserializeSizeLeft(), 0);
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------

View File

@ -43,7 +43,7 @@ void NestedTester::FppTest_SmInstanceInitial_Nested_Nested_action_a(
void NestedTester ::smInitialNested_stateMachineOverflowHook(SmId smId, void NestedTester ::smInitialNested_stateMachineOverflowHook(SmId smId,
FwEnumStoreType signal, FwEnumStoreType signal,
Fw::SerializeBufferBase& buffer) { Fw::SerialBufferBase& buffer) {
// Nothing to do // Nothing to do
} }

View File

@ -78,9 +78,9 @@ class NestedTester : public NestedComponentBase {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
//! Overflow hook implementation for smInitialNested //! Overflow hook implementation for smInitialNested
void smInitialNested_stateMachineOverflowHook(SmId smId, //!< The state machine ID void smInitialNested_stateMachineOverflowHook(SmId smId, //!< The state machine ID
FwEnumStoreType signal, //!< The signal FwEnumStoreType signal, //!< The signal
Fw::SerializeBufferBase& buffer //!< The message buffer Fw::SerialBufferBase& buffer //!< The message buffer
) override; ) override;
public: public:

View File

@ -53,17 +53,16 @@ bool BasicGuardTestAbsTypeTester::FppTest_SmState_BasicGuardTestAbsType_guard_g(
// Overflow hook implementations for internal state machines // Overflow hook implementations for internal state machines
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
void BasicGuardTestAbsTypeTester::smStateBasicGuardTestAbsType_stateMachineOverflowHook( void BasicGuardTestAbsTypeTester::smStateBasicGuardTestAbsType_stateMachineOverflowHook(SmId smId,
SmId smId, FwEnumStoreType signal,
FwEnumStoreType signal, Fw::SerialBufferBase& buffer) {
Fw::SerializeBufferBase& buffer) {
this->m_hookCalled = true; this->m_hookCalled = true;
ASSERT_EQ(smId, SmId::smStateBasicGuardTestAbsType); ASSERT_EQ(smId, SmId::smStateBasicGuardTestAbsType);
ASSERT_EQ(static_cast<SmState_BasicGuardTestAbsType::Signal>(signal), SmState_BasicGuardTestAbsType::Signal::s); ASSERT_EQ(static_cast<SmState_BasicGuardTestAbsType::Signal>(signal), SmState_BasicGuardTestAbsType::Signal::s);
SmHarness::TestAbsType value; SmHarness::TestAbsType value;
const auto status = buffer.deserializeTo(value); const auto status = buffer.deserializeTo(value);
ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK);
ASSERT_EQ(buffer.getBuffLeft(), 0); ASSERT_EQ(buffer.getDeserializeSizeLeft(), 0);
ASSERT_EQ(value, this->m_value); ASSERT_EQ(value, this->m_value);
} }

View File

@ -83,9 +83,9 @@ class BasicGuardTestAbsTypeTester : public BasicGuardTestAbsTypeComponentBase {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
//! Overflow hook implementation for smStateBasicGuardTestAbsType //! Overflow hook implementation for smStateBasicGuardTestAbsType
void smStateBasicGuardTestAbsType_stateMachineOverflowHook(SmId smId, //!< The state machine ID void smStateBasicGuardTestAbsType_stateMachineOverflowHook(SmId smId, //!< The state machine ID
FwEnumStoreType signal, //!< The signal FwEnumStoreType signal, //!< The signal
Fw::SerializeBufferBase& buffer //!< The message buffer Fw::SerialBufferBase& buffer //!< The message buffer
) override; ) override;
public: public:

View File

@ -259,7 +259,7 @@ TEST_F(NonPrimitiveStructTest, Serialization) {
status = buf.serializeFrom(s); status = buf.serializeFrom(s);
ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK);
ASSERT_EQ(buf.getBuffLength(), serializedSize); ASSERT_EQ(buf.getSize(), serializedSize);
// Deserialize // Deserialize
status = buf.deserializeTo(sCopy); status = buf.deserializeTo(sCopy);

View File

@ -171,7 +171,7 @@ TEST_F(PrimitiveStructTest, Serialization) {
status = buf.serializeFrom(s); status = buf.serializeFrom(s);
ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK);
ASSERT_EQ(buf.getBuffLength(), Primitive::SERIALIZED_SIZE); ASSERT_EQ(buf.getSize(), Primitive::SERIALIZED_SIZE);
// Deserialize // Deserialize
status = buf.deserializeTo(sCopy); status = buf.deserializeTo(sCopy);

View File

@ -182,7 +182,7 @@ TYPED_TEST_P(ArrayTest, Serialization) {
status = buf.serializeFrom(a); status = buf.serializeFrom(a);
ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK);
ASSERT_EQ(buf.getBuffLength(), serializedSize); ASSERT_EQ(buf.getSize(), serializedSize);
// Deserialize // Deserialize
status = buf.deserializeTo(aCopy); status = buf.deserializeTo(aCopy);
@ -199,7 +199,7 @@ TYPED_TEST_P(ArrayTest, Serialization) {
status = buf2.serializeFrom(a); status = buf2.serializeFrom(a);
ASSERT_NE(status, Fw::FW_SERIALIZE_OK); ASSERT_NE(status, Fw::FW_SERIALIZE_OK);
ASSERT_NE(buf2.getBuffLength(), serializedSize); ASSERT_NE(buf2.getSize(), serializedSize);
// Deserialize // Deserialize
status = buf2.deserializeTo(aCopy2); status = buf2.deserializeTo(aCopy2);

View File

@ -168,12 +168,12 @@ TYPED_TEST_P(EnumTest, Serialization) {
status = buf.serializeFrom(validEnum); status = buf.serializeFrom(validEnum);
ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); 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); status = buf.serializeFrom(invalidEnum);
ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); 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 // Deserialize the enums
status = buf.deserializeTo(validEnumCopy); status = buf.deserializeTo(validEnumCopy);

View File

@ -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; Fw::SerializeStatus stat;
#if FW_SERIALIZATION_TYPE_ID #if FW_SERIALIZATION_TYPE_ID
stat = buffer.serializeFrom(static_cast<U32>(Buffer::TYPE_ID)); stat = buffer.serializeFrom(static_cast<U32>(Buffer::TYPE_ID));
@ -136,7 +136,7 @@ Fw::SerializeStatus Buffer::serializeTo(Fw::SerializeBufferBase& buffer, Fw::End
return stat; 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; Fw::SerializeStatus stat;
#if FW_SERIALIZATION_TYPE_ID #if FW_SERIALIZATION_TYPE_ID

View File

@ -134,7 +134,7 @@ class Buffer : public Fw::Serializable {
//! or the serialize buffer base representation and serialize from that. //! or the serialize buffer base representation and serialize from that.
//! \param serialBuffer: serialize buffer to write data into //! \param serialBuffer: serialize buffer to write data into
//! \return: status of serialization //! \return: status of serialization
Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase& serialBuffer, Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& serialBuffer,
Fw::Endianness mode = Fw::Endianness::BIG) const; Fw::Endianness mode = Fw::Endianness::BIG) const;
//! Deserializes this buffer from a SerializeBufferBase //! 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. //! or the serialize buffer base representation and deserialize from that.
//! \param buffer: serialize buffer to read data into //! \param buffer: serialize buffer to read data into
//! \return: status of serialization //! \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 // Accessor functions

View File

@ -93,3 +93,7 @@ sb.deserializeTo(my_byte);
sb.deserializeTo(my_data, Fw::Endianness::LITTLE); sb.deserializeTo(my_data, Fw::Endianness::LITTLE);
sb.deserializeTo(my_byte, 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.

View File

@ -13,7 +13,7 @@ CmdArgBuffer::CmdArgBuffer() {}
CmdArgBuffer::~CmdArgBuffer() {} CmdArgBuffer::~CmdArgBuffer() {}
CmdArgBuffer::CmdArgBuffer(const CmdArgBuffer& other) : Fw::SerializeBufferBase() { 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
} }
@ -22,15 +22,19 @@ CmdArgBuffer& CmdArgBuffer::operator=(const CmdArgBuffer& other) {
return *this; 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
return *this; return *this;
} }
FwSizeType CmdArgBuffer::getBuffCapacity() const { FwSizeType CmdArgBuffer::getCapacity() const {
return sizeof(this->m_bufferData); return sizeof(this->m_bufferData);
} }
FwSizeType CmdArgBuffer::getBuffCapacity() const {
return this->getCapacity();
}
const U8* CmdArgBuffer::getBuffAddr() const { const U8* CmdArgBuffer::getBuffAddr() const {
return this->m_bufferData; return this->m_bufferData;
} }

View File

@ -31,9 +31,11 @@ class CmdArgBuffer final : public SerializeBufferBase {
virtual ~CmdArgBuffer(); //!< destructor virtual ~CmdArgBuffer(); //!< destructor
CmdArgBuffer& operator=(const CmdArgBuffer& other); //!< Equal operator CmdArgBuffer& operator=(const CmdArgBuffer& other); //!< Equal operator
FwSizeType getBuffCapacity() const; //!< return capacity of buffer (how much it can hold) DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead");
U8* getBuffAddr(); //!< return address of buffer (non const version) FwSizeType getCapacity() const; //!< return capacity of buffer (how much it can hold)
const U8* getBuffAddr() const; //!< return address of buffer (const version)
U8* getBuffAddr(); //!< return address of buffer (non const version)
const U8* getBuffAddr() const; //!< return address of buffer (const version)
private: private:
U8 m_bufferData[FW_CMD_ARG_BUFFER_MAX_SIZE]; //!< command argument buffer U8 m_bufferData[FW_CMD_ARG_BUFFER_MAX_SIZE]; //!< command argument buffer

View File

@ -18,13 +18,13 @@ CmdPacket::CmdPacket() : m_opcode(0) {
CmdPacket::~CmdPacket() {} CmdPacket::~CmdPacket() {}
// New serialization interface methods // 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) // Shouldn't be called, no use case for serializing CmdPackets in FSW (currently)
FW_ASSERT(0); FW_ASSERT(0);
return FW_SERIALIZE_OK; // for compiler 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); SerializeStatus stat = ComPacket::deserializeBase(buffer);
if (stat != FW_SERIALIZE_OK) { if (stat != FW_SERIALIZE_OK) {
return stat; return stat;
@ -41,9 +41,9 @@ SerializeStatus CmdPacket::deserializeFrom(SerializeBufferBase& buffer, Fw::Endi
} }
// if non-empty, copy data // if non-empty, copy data
if (buffer.getBuffLeft()) { if (buffer.getDeserializeSizeLeft()) {
// copy the serialized arguments to the buffer // 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; return stat;

View File

@ -19,8 +19,8 @@ class CmdPacket : public ComPacket {
virtual ~CmdPacket(); virtual ~CmdPacket();
// New serialization interface methods // New serialization interface methods
SerializeStatus serializeTo(SerializeBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const; SerializeStatus serializeTo(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) const override;
SerializeStatus deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG); SerializeStatus deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG) override;
FwOpcodeType getOpCode() const; FwOpcodeType getOpCode() const;
CmdArgBuffer& getArgBuffer(); CmdArgBuffer& getArgBuffer();

View File

@ -13,7 +13,7 @@ ComBuffer::ComBuffer() {}
ComBuffer::~ComBuffer() {} ComBuffer::~ComBuffer() {}
ComBuffer::ComBuffer(const ComBuffer& other) : Fw::SerializeBufferBase() { 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
} }
@ -22,15 +22,19 @@ ComBuffer& ComBuffer::operator=(const ComBuffer& other) {
return *this; 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
return *this; return *this;
} }
FwSizeType ComBuffer::getBuffCapacity() const { FwSizeType ComBuffer::getCapacity() const {
return sizeof(this->m_bufferData); return sizeof(this->m_bufferData);
} }
FwSizeType ComBuffer::getBuffCapacity() const {
return this->getCapacity();
}
const U8* ComBuffer::getBuffAddr() const { const U8* ComBuffer::getBuffAddr() const {
return this->m_bufferData; return this->m_bufferData;
} }

View File

@ -30,7 +30,9 @@ class ComBuffer final : public SerializeBufferBase {
virtual ~ComBuffer(); virtual ~ComBuffer();
ComBuffer& operator=(const ComBuffer& other); 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(); U8* getBuffAddr();
const U8* getBuffAddr() const; const U8* getBuffAddr() const;

View File

@ -13,11 +13,11 @@ ComPacket::ComPacket() : m_type(ComPacketType::FW_PACKET_UNKNOWN) {}
ComPacket::~ComPacket() {} ComPacket::~ComPacket() {}
SerializeStatus ComPacket::serializeBase(SerializeBufferBase& buffer) const { SerializeStatus ComPacket::serializeBase(SerialBufferBase& buffer) const {
return buffer.serializeFrom(static_cast<FwPacketDescriptorType>(this->m_type)); return buffer.serializeFrom(static_cast<FwPacketDescriptorType>(this->m_type));
} }
SerializeStatus ComPacket::deserializeBase(SerializeBufferBase& buffer) { SerializeStatus ComPacket::deserializeBase(SerialBufferBase& buffer) {
FwPacketDescriptorType serVal; FwPacketDescriptorType serVal;
SerializeStatus stat = buffer.deserializeTo(serVal); SerializeStatus stat = buffer.deserializeTo(serVal);
if (FW_SERIALIZE_OK == stat) { if (FW_SERIALIZE_OK == stat) {

View File

@ -27,9 +27,9 @@ class ComPacket : public Serializable {
protected: protected:
ComPacketType m_type; ComPacketType m_type;
SerializeStatus serializeBase( 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( SerializeStatus deserializeBase(
SerializeBufferBase& buffer); // called by derived classes to deserialize common fields SerialBufferBase& buffer); // called by derived classes to deserialize common fields
}; };
} /* namespace Fw */ } /* namespace Fw */

View File

@ -7,7 +7,8 @@ namespace Fw {
class ActiveComponentExitSerializableBuffer : public Fw::SerializeBufferBase { class ActiveComponentExitSerializableBuffer : public Fw::SerializeBufferBase {
public: 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; } U8* getBuffAddr() { return m_buff; }

View File

@ -212,7 +212,7 @@ void DpContainer::setDataHash(Utils::HashBuffer hash) {
static_cast<FwAssertArgType>(dataHashOffset + HASH_DIGEST_LENGTH), static_cast<FwAssertArgType>(dataHashOffset + HASH_DIGEST_LENGTH),
static_cast<FwAssertArgType>(bufferSize)); static_cast<FwAssertArgType>(bufferSize));
ExternalSerializeBuffer serialBuffer(dataHashAddr, HASH_DIGEST_LENGTH); ExternalSerializeBuffer serialBuffer(dataHashAddr, HASH_DIGEST_LENGTH);
hash.resetSer(); hash.resetDeser();
const Fw::SerializeStatus status = hash.copyRaw(serialBuffer, HASH_DIGEST_LENGTH); const Fw::SerializeStatus status = hash.copyRaw(serialBuffer, HASH_DIGEST_LENGTH);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status)); FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
} }

View File

@ -27,13 +27,13 @@ class DpContainerTester {
} }
static bool verifyDataBufferCapacity(const Fw::DpContainer& container, FwSizeType expectedCapacity) { 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) { static bool isDataBufferEmpty(const Fw::DpContainer& container) {
const Fw::SerializeBufferBase& buffer = container.m_dataBuffer; const Fw::SerializeBufferBase& buffer = container.m_dataBuffer;
const FwSizeType buffLength = buffer.getBuffLength(); const FwSizeType buffLength = buffer.getSize();
const FwSizeType buffLeft = buffer.getBuffLeft(); const FwSizeType buffLeft = buffer.getDeserializeSizeLeft();
return buffLength == 0 && buffLeft == 0; return buffLength == 0 && buffLeft == 0;
} }

View File

@ -31,7 +31,7 @@ SerializeStatus FilePacket::CancelPacket ::toBuffer(Buffer& buffer) const {
SerializeStatus FilePacket::CancelPacket ::fromSerialBuffer(SerialBuffer& serialBuffer) { SerializeStatus FilePacket::CancelPacket ::fromSerialBuffer(SerialBuffer& serialBuffer) {
FW_ASSERT(this->m_header.m_type == T_CANCEL); FW_ASSERT(this->m_header.m_type == T_CANCEL);
if (serialBuffer.getBuffLeft() != 0) { if (serialBuffer.getDeserializeSizeLeft() != 0) {
return FW_DESERIALIZE_SIZE_MISMATCH; return FW_DESERIALIZE_SIZE_MISMATCH;
} }

View File

@ -48,7 +48,7 @@ SerializeStatus FilePacket::DataPacket ::fromSerialBuffer(SerialBuffer& serialBu
return status; return status;
} }
if (serialBuffer.getBuffLeft() != this->m_dataSize) { if (serialBuffer.getDeserializeSizeLeft() != this->m_dataSize) {
return FW_DESERIALIZE_SIZE_MISMATCH; return FW_DESERIALIZE_SIZE_MISMATCH;
} }

View File

@ -14,7 +14,7 @@ StatementArgBuffer::StatementArgBuffer() {}
StatementArgBuffer::~StatementArgBuffer() {} StatementArgBuffer::~StatementArgBuffer() {}
StatementArgBuffer::StatementArgBuffer(const StatementArgBuffer& other) : Fw::SerializeBufferBase() { 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
} }
@ -23,15 +23,19 @@ StatementArgBuffer& StatementArgBuffer::operator=(const StatementArgBuffer& othe
return *this; 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
return *this; return *this;
} }
Serializable::SizeType StatementArgBuffer::getBuffCapacity() const { Serializable::SizeType StatementArgBuffer::getCapacity() const {
return sizeof(this->m_bufferData); return sizeof(this->m_bufferData);
} }
Serializable::SizeType StatementArgBuffer::getBuffCapacity() const {
return this->getCapacity();
}
const U8* StatementArgBuffer::getBuffAddr() const { const U8* StatementArgBuffer::getBuffAddr() const {
return this->m_bufferData; return this->m_bufferData;
} }
@ -41,7 +45,7 @@ U8* StatementArgBuffer::getBuffAddr() {
} }
bool StatementArgBuffer::operator==(const StatementArgBuffer& other) const { bool StatementArgBuffer::operator==(const StatementArgBuffer& other) const {
if (this->getBuffLength() != other.getBuffLength()) { if (this->getSize() != other.getSize()) {
return false; return false;
} }
@ -51,7 +55,7 @@ bool StatementArgBuffer::operator==(const StatementArgBuffer& other) const {
FW_ASSERT(us); FW_ASSERT(us);
FW_ASSERT(them); 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]) { if (us[byte] != them[byte]) {
return false; return false;
} }
@ -63,7 +67,7 @@ bool StatementArgBuffer::operator==(const StatementArgBuffer& other) const {
#if FW_SERIALIZABLE_TO_STRING #if FW_SERIALIZABLE_TO_STRING
void StatementArgBuffer::toString(Fw::StringBase& text) const { void StatementArgBuffer::toString(Fw::StringBase& text) const {
static const char* formatString = "(data = %p, size = %" PRI_FwSizeType ")"; 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 #endif
} // namespace Fw } // namespace Fw

View File

@ -20,7 +20,9 @@ class StatementArgBuffer : public SerializeBufferBase {
virtual ~StatementArgBuffer(); virtual ~StatementArgBuffer();
StatementArgBuffer& operator=(const StatementArgBuffer& other); 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(); U8* getBuffAddr();
const U8* getBuffAddr() const; const U8* getBuffAddr() const;
bool operator==(const StatementArgBuffer& other) const; bool operator==(const StatementArgBuffer& other) const;

View File

@ -16,7 +16,7 @@ AmpcsEvrLogPacket::AmpcsEvrLogPacket() : m_eventID(0), m_overSeqNum(0), m_catSeq
} }
AmpcsEvrLogPacket::~AmpcsEvrLogPacket() {} AmpcsEvrLogPacket::~AmpcsEvrLogPacket() {}
SerializeStatus AmpcsEvrLogPacket::serializeTo(SerializeBufferBase& buffer) const { SerializeStatus AmpcsEvrLogPacket::serializeTo(SerialBufferBase& buffer) const {
SerializeStatus stat; SerializeStatus stat;
stat = buffer.serializeFrom(this->m_taskName, AMPCS_EVR_TASK_NAME_LEN, Fw::Serialization::OMIT_LENGTH); 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 stat;
} }
return buffer.serializeFrom(this->m_logBuffer.getBuffAddr(), m_logBuffer.getBuffLength(), return buffer.serializeFrom(this->m_logBuffer.getBuffAddr(), m_logBuffer.getSize(), Fw::Serialization::OMIT_LENGTH);
Fw::Serialization::OMIT_LENGTH);
} }
SerializeStatus AmpcsEvrLogPacket::deserializeFrom(SerializeBufferBase& buffer) { SerializeStatus AmpcsEvrLogPacket::deserializeFrom(SerialBufferBase& buffer) {
FwSizeType len; FwSizeType len;
SerializeStatus stat;
SerializeStatus stat; SerializeStatus stat;
len = AMPCS_EVR_TASK_NAME_LEN; len = AMPCS_EVR_TASK_NAME_LEN;
@ -70,7 +68,7 @@ SerializeStatus AmpcsEvrLogPacket::deserializeFrom(SerializeBufferBase& buffer)
return stat; return stat;
} }
FwSizeType size = buffer.getBuffLeft(); FwSizeType size = buffer.getDeserializeSizeLeft();
stat = buffer.deserializeTo(this->m_logBuffer.getBuffAddr(), size, true); stat = buffer.deserializeTo(this->m_logBuffer.getBuffAddr(), size, true);
if (stat == FW_SERIALIZE_OK) { if (stat == FW_SERIALIZE_OK) {
// Shouldn't fail // Shouldn't fail

View File

@ -23,8 +23,8 @@ class AmpcsEvrLogPacket : public ComPacket {
AmpcsEvrLogPacket(); AmpcsEvrLogPacket();
virtual ~AmpcsEvrLogPacket(); virtual ~AmpcsEvrLogPacket();
SerializeStatus serializeTo(SerializeBufferBase& buffer, SerializeStatus serializeTo(SerialBufferBase& buffer,
Fw::Endianness mode = Fw::Endianness::BIG) const; //!< serialize contents Fw::Endianness mode = Fw::Endianness::BIG) const override; //!< serialize contents
SerializeStatus deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG); SerializeStatus deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode = Fw::Endianness::BIG);
void setTaskName(U8* taskName, U8 len); void setTaskName(U8* taskName, U8 len);

View File

@ -13,7 +13,7 @@ LogBuffer::LogBuffer() {}
LogBuffer::~LogBuffer() {} LogBuffer::~LogBuffer() {}
LogBuffer::LogBuffer(const LogBuffer& other) : Fw::SerializeBufferBase() { 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
} }
@ -22,15 +22,19 @@ LogBuffer& LogBuffer::operator=(const LogBuffer& other) {
return *this; 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
return *this; return *this;
} }
FwSizeType LogBuffer::getBuffCapacity() const { FwSizeType LogBuffer::getCapacity() const {
return sizeof(this->m_bufferData); return sizeof(this->m_bufferData);
} }
FwSizeType LogBuffer::getBuffCapacity() const {
return this->getCapacity();
}
const U8* LogBuffer::getBuffAddr() const { const U8* LogBuffer::getBuffAddr() const {
return this->m_bufferData; return this->m_bufferData;
} }

View File

@ -28,7 +28,9 @@ class LogBuffer final : public SerializeBufferBase {
virtual ~LogBuffer(); virtual ~LogBuffer();
LogBuffer& operator=(const LogBuffer& other); 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(); U8* getBuffAddr();
const U8* getBuffAddr() const; const U8* getBuffAddr() const;

View File

@ -16,7 +16,7 @@ LogPacket::LogPacket() : m_id(0) {
LogPacket::~LogPacket() {} 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); SerializeStatus stat = ComPacket::serializeBase(buffer);
if (stat != FW_SERIALIZE_OK) { if (stat != FW_SERIALIZE_OK) {
return stat; 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 // We want to add data but not size for the ground software
return buffer.serializeFrom(this->m_logBuffer.getBuffAddr(), m_logBuffer.getBuffLength(), return buffer.serializeFrom(this->m_logBuffer.getBuffAddr(), m_logBuffer.getSize(), Fw::Serialization::OMIT_LENGTH);
Fw::Serialization::OMIT_LENGTH);
} }
SerializeStatus LogPacket::deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode) { SerializeStatus LogPacket::deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode) {
SerializeStatus stat = deserializeBase(buffer); SerializeStatus stat = deserializeBase(buffer);
if (stat != FW_SERIALIZE_OK) { if (stat != FW_SERIALIZE_OK) {
return stat; return stat;
@ -54,7 +53,7 @@ SerializeStatus LogPacket::deserializeFrom(SerializeBufferBase& buffer, Fw::Endi
} }
// remainder of buffer must be telemetry value // 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); stat = buffer.deserializeTo(this->m_logBuffer.getBuffAddr(), size, Fw::Serialization::OMIT_LENGTH);
if (stat == FW_SERIALIZE_OK) { if (stat == FW_SERIALIZE_OK) {
// Shouldn't fail // Shouldn't fail

View File

@ -19,9 +19,9 @@ class LogPacket : public ComPacket {
LogPacket(); LogPacket();
virtual ~LogPacket(); virtual ~LogPacket();
SerializeStatus serializeTo(SerializeBufferBase& buffer, SerializeStatus serializeTo(SerialBufferBase& buffer,
Fw::Endianness mode = Fw::Endianness::BIG) const override; //!< serialize contents 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 setId(FwEventIdType id);
void setLogBuffer(const LogBuffer& buffer); void setLogBuffer(const LogBuffer& buffer);

View File

@ -15,7 +15,7 @@ class InputPortBase : public PortBase {
#if FW_PORT_SERIALIZATION #if FW_PORT_SERIALIZATION
virtual SerializeStatus invokeSerial( 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 #endif
protected: protected:

View File

@ -14,7 +14,7 @@ void InputSerializePort::init() {
InputPortBase::init(); InputPortBase::init();
} }
SerializeStatus InputSerializePort::invokeSerial(SerializeBufferBase& buffer) { SerializeStatus InputSerializePort::invokeSerial(LinearBufferBase& buffer) {
FW_ASSERT(this->m_comp); FW_ASSERT(this->m_comp);
FW_ASSERT(this->m_func); FW_ASSERT(this->m_func);

View File

@ -17,11 +17,11 @@ class InputSerializePort final : public InputPortBase {
void init() override; void init() override;
SerializeStatus invokeSerial( 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, typedef void (*CompFuncPtr)(Fw::PassiveComponentBase* callComp,
FwIndexType portNum, FwIndexType portNum,
SerializeBufferBase& arg); //!< port callback definition LinearBufferBase& arg); //!< port callback definition
void addCallComp(Fw::PassiveComponentBase* callComp, CompFuncPtr funcPtr); //!< call to register a component void addCallComp(Fw::PassiveComponentBase* callComp, CompFuncPtr funcPtr); //!< call to register a component
protected: protected:

View File

@ -13,7 +13,7 @@ ParamBuffer::ParamBuffer() {}
ParamBuffer::~ParamBuffer() {} ParamBuffer::~ParamBuffer() {}
ParamBuffer::ParamBuffer(const ParamBuffer& other) : Fw::SerializeBufferBase() { 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
} }
@ -22,15 +22,19 @@ ParamBuffer& ParamBuffer::operator=(const ParamBuffer& other) {
return *this; 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
return *this; return *this;
} }
FwSizeType ParamBuffer::getBuffCapacity() const { FwSizeType ParamBuffer::getCapacity() const {
return sizeof(this->m_bufferData); return sizeof(this->m_bufferData);
} }
FwSizeType ParamBuffer::getBuffCapacity() const {
return this->getCapacity();
}
const U8* ParamBuffer::getBuffAddr() const { const U8* ParamBuffer::getBuffAddr() const {
return this->m_bufferData; return this->m_bufferData;
} }

View File

@ -36,7 +36,9 @@ class ParamBuffer final : public SerializeBufferBase {
virtual ~ParamBuffer(); virtual ~ParamBuffer();
ParamBuffer& operator=(const ParamBuffer& other); 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(); U8* getBuffAddr();
const U8* getBuffAddr() const; const U8* getBuffAddr() const;

View File

@ -31,7 +31,7 @@ class ParamExternalDelegate {
virtual SerializeStatus deserializeParam(const FwPrmIdType base_id, virtual SerializeStatus deserializeParam(const FwPrmIdType base_id,
const FwPrmIdType local_id, const FwPrmIdType local_id,
const ParamValid prmStat, const ParamValid prmStat,
SerializeBufferBase& buff) = 0; SerialBufferBase& buff) = 0;
//! Serialize a parameter into a parameter buffer //! Serialize a parameter into a parameter buffer
//! //!
@ -42,7 +42,7 @@ class ParamExternalDelegate {
//! \return: The status of the serialize operation //! \return: The status of the serialize operation
virtual SerializeStatus serializeParam(const FwPrmIdType base_id, virtual SerializeStatus serializeParam(const FwPrmIdType base_id,
const FwPrmIdType local_id, const FwPrmIdType local_id,
SerializeBufferBase& buff) const = 0; SerialBufferBase& buff) const = 0;
}; };
} // namespace Fw } // namespace Fw

View File

@ -39,7 +39,7 @@ SerializableFile::Status SerializableFile::load(const char* fileName, Serializab
return FILE_OPEN_ERROR; 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); status = file.read(this->m_buffer.getBuffAddr(), length, Os::File::WaitType::NO_WAIT);
if (Os::File::OP_OK != status) { if (Os::File::OP_OK != status) {
file.close(); file.close();
@ -71,9 +71,9 @@ SerializableFile::Status SerializableFile::save(const char* fileName, Serializab
return FILE_OPEN_ERROR; return FILE_OPEN_ERROR;
} }
FwSizeType length = this->m_buffer.getBuffLength(); FwSizeType length = this->m_buffer.getSize();
status = file.write(this->m_buffer.getBuffAddr(), length); 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(); file.close();
return FILE_WRITE_ERROR; return FILE_WRITE_ERROR;
} }

View File

@ -16,9 +16,9 @@ SmSignalBuffer::~SmSignalBuffer() {}
SmSignalBuffer::SmSignalBuffer(const SmSignalBuffer& other) : Fw::SerializeBufferBase(), m_bufferData{} { SmSignalBuffer::SmSignalBuffer(const SmSignalBuffer& other) : Fw::SerializeBufferBase(), m_bufferData{} {
FW_ASSERT(other.getBuffAddr() != nullptr); 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
} }
@ -28,17 +28,21 @@ SmSignalBuffer& SmSignalBuffer::operator=(const SmSignalBuffer& other) {
} }
FW_ASSERT(other.getBuffAddr() != nullptr); 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
return *this; return *this;
} }
Serializable::SizeType SmSignalBuffer::getBuffCapacity() const { Serializable::SizeType SmSignalBuffer::getCapacity() const {
return sizeof(this->m_bufferData); return sizeof(this->m_bufferData);
} }
Serializable::SizeType SmSignalBuffer::getBuffCapacity() const {
return this->getCapacity();
}
const U8* SmSignalBuffer::getBuffAddr() const { const U8* SmSignalBuffer::getBuffAddr() const {
return this->m_bufferData; return this->m_bufferData;
} }

View File

@ -28,7 +28,9 @@ class SmSignalBuffer final : public SerializeBufferBase {
virtual ~SmSignalBuffer(); virtual ~SmSignalBuffer();
SmSignalBuffer& operator=(const SmSignalBuffer& other); 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(); U8* getBuffAddr();
const U8* getBuffAddr() const; const U8* getBuffAddr() const;

View File

@ -77,11 +77,11 @@ bool Time::operator<=(const Time& other) const {
return ((LT == c) or (EQ == c)); 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); 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); return this->m_val.deserializeFrom(buffer, mode);
} }

View File

@ -36,9 +36,9 @@ class Time : public Serializable {
TimeBase getTimeBase() TimeBase getTimeBase()
const; // !< Time base of time. This is project specific and is meant for indicating different sources of time 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 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 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 Fw::Endianness mode = Fw::Endianness::BIG) override; // !< Deserialize method
bool operator==(const Time& other) const; bool operator==(const Time& other) const;
bool operator!=(const Time& other) const; bool operator!=(const Time& other) const;

View File

@ -53,12 +53,12 @@ bool TimeInterval::operator<=(const TimeInterval& other) const {
return ((LT == c) or (EQ == c)); 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 // Use TimeIntervalValue's built-in serialization
return this->m_val.serializeTo(buffer, mode); 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 // Use TimeIntervalValue's built-in deserialization
return this->m_val.deserializeFrom(buffer, mode); return this->m_val.deserializeFrom(buffer, mode);
} }

View File

@ -30,9 +30,9 @@ class TimeInterval : public Serializable {
U32 getSeconds() const; // !< Gets seconds part of time U32 getSeconds() const; // !< Gets seconds part of time
U32 getUSeconds() const; // !< Gets microseconds 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 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 Fw::Endianness mode = Fw::Endianness::BIG) override; // !< Deserialize method
void add(U32 seconds, U32 mseconds); // !< Add seconds and microseconds to existing time interval void add(U32 seconds, U32 mseconds); // !< Add seconds and microseconds to existing time interval
bool operator==(const TimeInterval& other) const; bool operator==(const TimeInterval& other) const;

View File

@ -13,7 +13,7 @@ TlmBuffer::TlmBuffer() {}
TlmBuffer::~TlmBuffer() {} TlmBuffer::~TlmBuffer() {}
TlmBuffer::TlmBuffer(const TlmBuffer& other) : Fw::SerializeBufferBase() { 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
} }
@ -22,15 +22,19 @@ TlmBuffer& TlmBuffer::operator=(const TlmBuffer& other) {
return *this; 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<FwAssertArgType>(stat)); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
return *this; return *this;
} }
FwSizeType TlmBuffer::getBuffCapacity() const { FwSizeType TlmBuffer::getCapacity() const {
return sizeof(this->m_bufferData); return sizeof(this->m_bufferData);
} }
FwSizeType TlmBuffer::getBuffCapacity() const {
return this->getCapacity();
}
const U8* TlmBuffer::getBuffAddr() const { const U8* TlmBuffer::getBuffAddr() const {
return this->m_bufferData; return this->m_bufferData;
} }

View File

@ -27,7 +27,9 @@ class TlmBuffer final : public SerializeBufferBase {
virtual ~TlmBuffer(); virtual ~TlmBuffer();
TlmBuffer& operator=(const TlmBuffer& other); 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(); U8* getBuffAddr();
const U8* getBuffAddr() const; const U8* getBuffAddr() const;

View File

@ -62,8 +62,8 @@ void TlmPacket::setBuffer(Fw::ComBuffer& buffer) {
SerializeStatus TlmPacket::addValue(FwChanIdType id, Time& timeTag, TlmBuffer& buffer) { SerializeStatus TlmPacket::addValue(FwChanIdType id, Time& timeTag, TlmBuffer& buffer) {
// check to make sure there is room for all the fields // check to make sure there is room for all the fields
FwSizeType left = this->m_tlmBuffer.getBuffCapacity() - this->m_tlmBuffer.getBuffLength(); FwSizeType left = this->m_tlmBuffer.getCapacity() - this->m_tlmBuffer.getSize();
if ((sizeof(FwChanIdType) + Time::SERIALIZED_SIZE + buffer.getBuffLength()) > left) { if ((sizeof(FwChanIdType) + Time::SERIALIZED_SIZE + buffer.getSize()) > left) {
return Fw::FW_SERIALIZE_NO_ROOM_LEFT; return Fw::FW_SERIALIZE_NO_ROOM_LEFT;
} }
@ -82,8 +82,7 @@ SerializeStatus TlmPacket::addValue(FwChanIdType id, Time& timeTag, TlmBuffer& b
} }
// telemetry buffer // telemetry buffer
stat = stat = this->m_tlmBuffer.serializeFrom(buffer.getBuffAddr(), buffer.getSize(), Fw::Serialization::OMIT_LENGTH);
this->m_tlmBuffer.serializeFrom(buffer.getBuffAddr(), buffer.getBuffLength(), Fw::Serialization::OMIT_LENGTH);
if (stat != Fw::FW_SERIALIZE_OK) { if (stat != Fw::FW_SERIALIZE_OK) {
return stat; return stat;
} }
@ -125,25 +124,24 @@ SerializeStatus TlmPacket::extractValue(FwChanIdType& id, Time& timeTag, TlmBuff
return Fw::FW_SERIALIZE_OK; 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 // serialize the number of packets
SerializeStatus stat = buffer.serializeFrom(this->m_numEntries, mode); SerializeStatus stat = buffer.serializeFrom(this->m_numEntries, mode);
if (stat != Fw::FW_SERIALIZE_OK) { if (stat != Fw::FW_SERIALIZE_OK) {
return stat; return stat;
} }
// Serialize the ComBuffer // Serialize the ComBuffer
return buffer.serializeFrom(this->m_tlmBuffer.getBuffAddr(), m_tlmBuffer.getBuffLength(), return buffer.serializeFrom(this->m_tlmBuffer.getBuffAddr(), m_tlmBuffer.getSize(), Fw::Serialization::OMIT_LENGTH);
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 // deserialize the number of packets
SerializeStatus stat = buffer.deserializeTo(this->m_numEntries, mode); SerializeStatus stat = buffer.deserializeTo(this->m_numEntries, mode);
if (stat != Fw::FW_SERIALIZE_OK) { if (stat != Fw::FW_SERIALIZE_OK) {
return stat; return stat;
} }
// deserialize the channel value entry buffers // 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); stat = buffer.deserializeTo(this->m_tlmBuffer.getBuffAddr(), size, Fw::Serialization::OMIT_LENGTH);
if (stat == FW_SERIALIZE_OK) { if (stat == FW_SERIALIZE_OK) {
// Shouldn't fail // Shouldn't fail

View File

@ -22,9 +22,9 @@ class TlmPacket : public ComPacket {
//! Destructor //! Destructor
virtual ~TlmPacket(); virtual ~TlmPacket();
SerializeStatus serializeTo(SerializeBufferBase& buffer, SerializeStatus serializeTo(SerialBufferBase& buffer,
Fw::Endianness mode = Fw::Endianness::BIG) const override; //!< serialize contents 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. //! Add telemetry value to buffer.
SerializeStatus addValue(FwChanIdType id, Time& timeTag, TlmBuffer& buffer); SerializeStatus addValue(FwChanIdType id, Time& timeTag, TlmBuffer& buffer);
//! extract telemetry value - since there are potentially multiple channel values in the packet, //! extract telemetry value - since there are potentially multiple channel values in the packet,

View File

@ -480,7 +480,7 @@ bool PolyType::operator<=(const PolyType& other) const {
return (this->operator<(other)) || (this->operator==(other)); 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 // store type
SerializeStatus stat = buffer.serializeFrom(static_cast<FwEnumStoreType>(this->m_dataType), mode); SerializeStatus stat = buffer.serializeFrom(static_cast<FwEnumStoreType>(this->m_dataType), mode);
if (stat != FW_SERIALIZE_OK) { if (stat != FW_SERIALIZE_OK) {
@ -539,7 +539,7 @@ SerializeStatus PolyType::serializeTo(SerializeBufferBase& buffer, Fw::Endiannes
return stat; return stat;
} }
SerializeStatus PolyType::deserializeFrom(SerializeBufferBase& buffer, Fw::Endianness mode) { SerializeStatus PolyType::deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode) {
// get type // get type
FwEnumStoreType des; FwEnumStoreType des;
SerializeStatus stat = buffer.deserializeTo(des, mode); SerializeStatus stat = buffer.deserializeTo(des, mode);

View File

@ -103,9 +103,9 @@ class PolyType : public Serializable {
bool operator==(const PolyType& other) const; //!< PolyType operator== bool operator==(const PolyType& other) const; //!< PolyType operator==
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 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 Fw::Endianness mode = Fw::Endianness::BIG) override; //!< Deserialize function
private: private:

View File

@ -17,10 +17,14 @@ namespace Fw {
SerialBuffer ::SerialBuffer(U8* const data, const FwSizeType capacity) : m_data(data), m_capacity(capacity) {} 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; return m_capacity;
} }
FwSizeType SerialBuffer ::getBuffCapacity() const {
return this->getCapacity();
}
U8* SerialBuffer ::getBuffAddr() { U8* SerialBuffer ::getBuffAddr() {
return m_data; return m_data;
} }

View File

@ -38,7 +38,8 @@ class SerialBuffer final : public SerializeBufferBase {
// Pure virtual methods from SerializeBufferBase // Pure virtual methods from SerializeBufferBase
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
FwSizeType getBuffCapacity() const; DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead");
FwSizeType getCapacity() const;
U8* getBuffAddr(); U8* getBuffAddr();

View File

@ -37,32 +37,34 @@ std::ostream& operator<<(std::ostream& os, const Serializable& val) {
} }
#endif #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_serLoc = src.m_serLoc;
this->m_deserLoc = src.m_deserLoc; this->m_deserLoc = src.m_deserLoc;
FW_ASSERT(src.getBuffAddr()); FW_ASSERT(src.getBuffAddr());
FW_ASSERT(this->getBuffAddr()); FW_ASSERT(this->getBuffAddr());
// destination has to be same or bigger // destination has to be same or bigger
FW_ASSERT(src.getBuffLength() <= this->getBuffCapacity(), static_cast<FwAssertArgType>(src.getBuffLength()), FW_ASSERT(src.getSize() <= this->getCapacity(), static_cast<FwAssertArgType>(src.getSize()),
static_cast<FwAssertArgType>(this->getBuffLength())); static_cast<FwAssertArgType>(this->getSize()));
(void)memcpy(this->getBuffAddr(), src.getBuffAddr(), static_cast<size_t>(this->m_serLoc)); (void)memcpy(this->getBuffAddr(), src.getBuffAddr(), static_cast<size_t>(this->m_serLoc));
} }
// Copy constructor doesn't make sense in this virtual class as there is nothing to copy. Derived classes should // 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 // 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); this->copyFrom(src);
return *this; return *this;
} }
// serialization routines // serialization routines
SerializeStatus SerializeBufferBase::serializeFrom(U8 val, Endianness mode) { SerializeStatus LinearBufferBase::serializeFrom(U8 val, Endianness mode) {
if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->getBuffCapacity()) { if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->getCapacity()) {
return FW_SERIALIZE_NO_ROOM_LEFT; return FW_SERIALIZE_NO_ROOM_LEFT;
} }
FW_ASSERT(this->getBuffAddr()); FW_ASSERT(this->getBuffAddr());
@ -73,13 +75,13 @@ SerializeStatus SerializeBufferBase::serializeFrom(U8 val, Endianness mode) {
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::serializeFrom(I8 val, Endianness mode) { SerializeStatus LinearBufferBase::serializeFrom(I8 val, Endianness mode) {
return serializeFrom(static_cast<U8>(val), mode); return serializeFrom(static_cast<U8>(val), mode);
} }
#if FW_HAS_16_BIT == 1 #if FW_HAS_16_BIT == 1
SerializeStatus SerializeBufferBase::serializeFrom(U16 val, Endianness mode) { SerializeStatus LinearBufferBase::serializeFrom(U16 val, Endianness mode) {
if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->getBuffCapacity()) { if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->getCapacity()) {
return FW_SERIALIZE_NO_ROOM_LEFT; return FW_SERIALIZE_NO_ROOM_LEFT;
} }
FW_ASSERT(this->getBuffAddr()); FW_ASSERT(this->getBuffAddr());
@ -103,13 +105,13 @@ SerializeStatus SerializeBufferBase::serializeFrom(U16 val, Endianness mode) {
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::serializeFrom(I16 val, Endianness mode) { SerializeStatus LinearBufferBase::serializeFrom(I16 val, Endianness mode) {
return serializeFrom(static_cast<U16>(val), mode); return serializeFrom(static_cast<U16>(val), mode);
} }
#endif #endif
#if FW_HAS_32_BIT == 1 #if FW_HAS_32_BIT == 1
SerializeStatus SerializeBufferBase::serializeFrom(U32 val, Endianness mode) { SerializeStatus LinearBufferBase::serializeFrom(U32 val, Endianness mode) {
if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->getBuffCapacity()) { if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->getCapacity()) {
return FW_SERIALIZE_NO_ROOM_LEFT; return FW_SERIALIZE_NO_ROOM_LEFT;
} }
FW_ASSERT(this->getBuffAddr()); FW_ASSERT(this->getBuffAddr());
@ -137,14 +139,14 @@ SerializeStatus SerializeBufferBase::serializeFrom(U32 val, Endianness mode) {
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::serializeFrom(I32 val, Endianness mode) { SerializeStatus LinearBufferBase::serializeFrom(I32 val, Endianness mode) {
return serializeFrom(static_cast<U32>(val), mode); return serializeFrom(static_cast<U32>(val), mode);
} }
#endif #endif
#if FW_HAS_64_BIT == 1 #if FW_HAS_64_BIT == 1
SerializeStatus SerializeBufferBase::serializeFrom(U64 val, Endianness mode) { SerializeStatus LinearBufferBase::serializeFrom(U64 val, Endianness mode) {
if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->getBuffCapacity()) { if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->getCapacity()) {
return FW_SERIALIZE_NO_ROOM_LEFT; return FW_SERIALIZE_NO_ROOM_LEFT;
} }
FW_ASSERT(this->getBuffAddr()); FW_ASSERT(this->getBuffAddr());
@ -180,27 +182,27 @@ SerializeStatus SerializeBufferBase::serializeFrom(U64 val, Endianness mode) {
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::serializeFrom(I64 val, Endianness mode) { SerializeStatus LinearBufferBase::serializeFrom(I64 val, Endianness mode) {
return serializeFrom(static_cast<U64>(val), mode); return serializeFrom(static_cast<U64>(val), mode);
} }
#endif #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 // floating point values need to be byte-swapped as well, so copy to U64 and use that routine
U64 u64Val; U64 u64Val;
(void)memcpy(&u64Val, &val, sizeof(val)); (void)memcpy(&u64Val, &val, sizeof(val));
return this->serializeFrom(u64Val, mode); 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 // floating point values need to be byte-swapped as well, so copy to U32 and use that routine
U32 u32Val; U32 u32Val;
(void)memcpy(&u32Val, &val, sizeof(val)); (void)memcpy(&u32Val, &val, sizeof(val));
return this->serializeFrom(u32Val, mode); return this->serializeFrom(u32Val, mode);
} }
SerializeStatus SerializeBufferBase::serializeFrom(bool val, Endianness mode) { SerializeStatus LinearBufferBase::serializeFrom(bool val, Endianness mode) {
if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(U8)) - 1 >= this->getBuffCapacity()) { if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(U8)) - 1 >= this->getCapacity()) {
return FW_SERIALIZE_NO_ROOM_LEFT; return FW_SERIALIZE_NO_ROOM_LEFT;
} }
@ -216,24 +218,22 @@ SerializeStatus SerializeBufferBase::serializeFrom(bool val, Endianness mode) {
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::serializeFrom(const void* val, Endianness mode) { SerializeStatus LinearBufferBase::serializeFrom(const void* val, Endianness mode) {
if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(void*)) - 1 >= this->getBuffCapacity()) { if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(void*)) - 1 >= this->getCapacity()) {
return FW_SERIALIZE_NO_ROOM_LEFT; return FW_SERIALIZE_NO_ROOM_LEFT;
} }
return this->serializeFrom(reinterpret_cast<PlatformPointerCastType>(val), mode); return this->serializeFrom(reinterpret_cast<PlatformPointerCastType>(val), mode);
} }
SerializeStatus SerializeBufferBase::serializeFrom(const U8* buff, SerializeStatus LinearBufferBase::serializeFrom(const U8* buff, Serializable::SizeType length, Endianness endianMode) {
Serializable::SizeType length,
Endianness endianMode) {
return this->serializeFrom(buff, static_cast<FwSizeType>(length), Serialization::INCLUDE_LENGTH, endianMode); return this->serializeFrom(buff, static_cast<FwSizeType>(length), Serialization::INCLUDE_LENGTH, endianMode);
} }
SerializeStatus SerializeBufferBase::serializeFrom(const U8* buff, SerializeStatus LinearBufferBase::serializeFrom(const U8* buff,
FwSizeType length, FwSizeType length,
Serialization::t lengthMode, Serialization::t lengthMode,
Endianness endianMode) { // First serialize length Endianness endianMode) { // First serialize length
SerializeStatus stat; SerializeStatus stat;
if (lengthMode == Serialization::INCLUDE_LENGTH) { if (lengthMode == Serialization::INCLUDE_LENGTH) {
stat = this->serializeFrom(static_cast<FwSizeStoreType>(length), endianMode); stat = this->serializeFrom(static_cast<FwSizeStoreType>(length), endianMode);
@ -243,7 +243,7 @@ SerializeStatus SerializeBufferBase::serializeFrom(const U8* buff,
} }
// make sure we have enough space // 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; return FW_SERIALIZE_NO_ROOM_LEFT;
} }
@ -255,14 +255,13 @@ SerializeStatus SerializeBufferBase::serializeFrom(const U8* buff,
return FW_SERIALIZE_OK; 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); return val.serializeTo(*this, mode);
} }
SerializeStatus SerializeBufferBase::serializeFrom(const SerializeBufferBase& val, Endianness mode) { SerializeStatus LinearBufferBase::serializeFrom(const LinearBufferBase& val, Endianness mode) {
Serializable::SizeType size = val.getBuffLength(); Serializable::SizeType size = val.getSize();
if (this->m_serLoc + size + static_cast<Serializable::SizeType>(sizeof(FwSizeStoreType)) > if (this->m_serLoc + size + static_cast<Serializable::SizeType>(sizeof(FwSizeStoreType)) > this->getCapacity()) {
this->getBuffCapacity()) {
return FW_SERIALIZE_NO_ROOM_LEFT; return FW_SERIALIZE_NO_ROOM_LEFT;
} }
@ -282,7 +281,7 @@ SerializeStatus SerializeBufferBase::serializeFrom(const SerializeBufferBase& va
return FW_SERIALIZE_OK; 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; SerializeStatus status = FW_SERIALIZE_OK;
if ((size < std::numeric_limits<FwSizeStoreType>::min()) || (size > std::numeric_limits<FwSizeStoreType>::max())) { if ((size < std::numeric_limits<FwSizeStoreType>::min()) || (size > std::numeric_limits<FwSizeStoreType>::max())) {
status = FW_SERIALIZE_FORMAT_ERROR; status = FW_SERIALIZE_FORMAT_ERROR;
@ -295,11 +294,11 @@ SerializeStatus SerializeBufferBase::serializeSize(const FwSizeType size, Endian
// deserialization routines // deserialization routines
SerializeStatus SerializeBufferBase::deserializeTo(U8& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(U8& val, Endianness mode) {
// check for room // check for room
if (this->getBuffLength() == this->m_deserLoc) { if (this->getSize() == this->m_deserLoc) {
return FW_DESERIALIZE_BUFFER_EMPTY; return FW_DESERIALIZE_BUFFER_EMPTY;
} else if (this->getBuffLength() - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) { } else if (this->getSize() - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) {
return FW_DESERIALIZE_SIZE_MISMATCH; return FW_DESERIALIZE_SIZE_MISMATCH;
} }
// read from current location // read from current location
@ -309,11 +308,11 @@ SerializeStatus SerializeBufferBase::deserializeTo(U8& val, Endianness mode) {
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::deserializeTo(I8& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(I8& val, Endianness mode) {
// check for room // check for room
if (this->getBuffLength() == this->m_deserLoc) { if (this->getSize() == this->m_deserLoc) {
return FW_DESERIALIZE_BUFFER_EMPTY; return FW_DESERIALIZE_BUFFER_EMPTY;
} else if (this->getBuffLength() - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) { } else if (this->getSize() - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) {
return FW_DESERIALIZE_SIZE_MISMATCH; return FW_DESERIALIZE_SIZE_MISMATCH;
} }
// read from current location // read from current location
@ -324,11 +323,11 @@ SerializeStatus SerializeBufferBase::deserializeTo(I8& val, Endianness mode) {
} }
#if FW_HAS_16_BIT == 1 #if FW_HAS_16_BIT == 1
SerializeStatus SerializeBufferBase::deserializeTo(U16& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(U16& val, Endianness mode) {
// check for room // check for room
if (this->getBuffLength() == this->m_deserLoc) { if (this->getSize() == this->m_deserLoc) {
return FW_DESERIALIZE_BUFFER_EMPTY; return FW_DESERIALIZE_BUFFER_EMPTY;
} else if (this->getBuffLength() - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) { } else if (this->getSize() - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) {
return FW_DESERIALIZE_SIZE_MISMATCH; return FW_DESERIALIZE_SIZE_MISMATCH;
} }
// read from current location // read from current location
@ -352,7 +351,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(U16& val, Endianness mode) {
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::deserializeTo(I16& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(I16& val, Endianness mode) {
U16 unsignVal; U16 unsignVal;
SerializeStatus res = deserializeTo(unsignVal, mode); SerializeStatus res = deserializeTo(unsignVal, mode);
if (res == SerializeStatus::FW_SERIALIZE_OK) { if (res == SerializeStatus::FW_SERIALIZE_OK) {
@ -362,11 +361,11 @@ SerializeStatus SerializeBufferBase::deserializeTo(I16& val, Endianness mode) {
} }
#endif #endif
#if FW_HAS_32_BIT == 1 #if FW_HAS_32_BIT == 1
SerializeStatus SerializeBufferBase::deserializeTo(U32& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(U32& val, Endianness mode) {
// check for room // check for room
if (this->getBuffLength() == this->m_deserLoc) { if (this->getSize() == this->m_deserLoc) {
return FW_DESERIALIZE_BUFFER_EMPTY; return FW_DESERIALIZE_BUFFER_EMPTY;
} else if (this->getBuffLength() - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) { } else if (this->getSize() - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) {
return FW_DESERIALIZE_SIZE_MISMATCH; return FW_DESERIALIZE_SIZE_MISMATCH;
} }
// read from current location // read from current location
@ -394,7 +393,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(U32& val, Endianness mode) {
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::deserializeTo(I32& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(I32& val, Endianness mode) {
U32 unsignVal; U32 unsignVal;
SerializeStatus res = deserializeTo(unsignVal, mode); SerializeStatus res = deserializeTo(unsignVal, mode);
if (res == SerializeStatus::FW_SERIALIZE_OK) { if (res == SerializeStatus::FW_SERIALIZE_OK) {
@ -406,11 +405,11 @@ SerializeStatus SerializeBufferBase::deserializeTo(I32& val, Endianness mode) {
#if FW_HAS_64_BIT == 1 #if FW_HAS_64_BIT == 1
SerializeStatus SerializeBufferBase::deserializeTo(U64& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(U64& val, Endianness mode) {
// check for room // check for room
if (this->getBuffLength() == this->m_deserLoc) { if (this->getSize() == this->m_deserLoc) {
return FW_DESERIALIZE_BUFFER_EMPTY; return FW_DESERIALIZE_BUFFER_EMPTY;
} else if (this->getBuffLength() - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) { } else if (this->getSize() - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) {
return FW_DESERIALIZE_SIZE_MISMATCH; return FW_DESERIALIZE_SIZE_MISMATCH;
} }
// read from current location // read from current location
@ -446,7 +445,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(U64& val, Endianness mode) {
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::deserializeTo(I64& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(I64& val, Endianness mode) {
U64 unsignVal; U64 unsignVal;
SerializeStatus res = deserializeTo(unsignVal, mode); SerializeStatus res = deserializeTo(unsignVal, mode);
if (res == SerializeStatus::FW_SERIALIZE_OK) { if (res == SerializeStatus::FW_SERIALIZE_OK) {
@ -456,7 +455,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(I64& val, Endianness mode) {
} }
#endif #endif
SerializeStatus SerializeBufferBase::deserializeTo(F64& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(F64& val, Endianness mode) {
// deserialize as 64-bit int to handle endianness // deserialize as 64-bit int to handle endianness
U64 tempVal; U64 tempVal;
SerializeStatus stat = this->deserializeTo(tempVal, mode); SerializeStatus stat = this->deserializeTo(tempVal, mode);
@ -469,11 +468,11 @@ SerializeStatus SerializeBufferBase::deserializeTo(F64& val, Endianness mode) {
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::deserializeTo(bool& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(bool& val, Endianness mode) {
// check for room // check for room
if (this->getBuffLength() == this->m_deserLoc) { if (this->getSize() == this->m_deserLoc) {
return FW_DESERIALIZE_BUFFER_EMPTY; return FW_DESERIALIZE_BUFFER_EMPTY;
} else if (this->getBuffLength() - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(U8))) { } else if (this->getSize() - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(U8))) {
return FW_DESERIALIZE_SIZE_MISMATCH; return FW_DESERIALIZE_SIZE_MISMATCH;
} }
// read from current location // read from current location
@ -490,7 +489,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(bool& val, Endianness mode) {
return FW_SERIALIZE_OK; 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* // Deserialize as pointer cast, then convert to void*
PlatformPointerCastType pointerCastVal = 0; PlatformPointerCastType pointerCastVal = 0;
const SerializeStatus stat = this->deserializeTo(pointerCastVal, mode); const SerializeStatus stat = this->deserializeTo(pointerCastVal, mode);
@ -500,7 +499,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(void*& val, Endianness mode)
return stat; return stat;
} }
SerializeStatus SerializeBufferBase::deserializeTo(F32& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(F32& val, Endianness mode) {
// deserialize as 64-bit int to handle endianness // deserialize as 64-bit int to handle endianness
U32 tempVal; U32 tempVal;
SerializeStatus stat = this->deserializeTo(tempVal, mode); SerializeStatus stat = this->deserializeTo(tempVal, mode);
@ -512,17 +511,17 @@ SerializeStatus SerializeBufferBase::deserializeTo(F32& val, Endianness mode) {
return FW_SERIALIZE_OK; 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<FwSizeType>(length); FwSizeType length_in_out = static_cast<FwSizeType>(length);
SerializeStatus status = this->deserializeTo(buff, length_in_out, Serialization::INCLUDE_LENGTH, endianMode); SerializeStatus status = this->deserializeTo(buff, length_in_out, Serialization::INCLUDE_LENGTH, endianMode);
length = static_cast<Serializable::SizeType>(length_in_out); length = static_cast<Serializable::SizeType>(length_in_out);
return status; return status;
} }
SerializeStatus SerializeBufferBase::deserializeTo(U8* buff, SerializeStatus LinearBufferBase::deserializeTo(U8* buff,
Serializable::SizeType& length, Serializable::SizeType& length,
Serialization::t lengthMode, Serialization::t lengthMode,
Endianness endianMode) { Endianness endianMode) {
FW_ASSERT(this->getBuffAddr()); FW_ASSERT(this->getBuffAddr());
if (lengthMode == Serialization::INCLUDE_LENGTH) { if (lengthMode == Serialization::INCLUDE_LENGTH) {
@ -535,7 +534,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(U8* buff,
} }
// make sure it fits // make sure it fits
if ((storedLength > this->getBuffLeft()) or (storedLength > length)) { if ((storedLength > this->getDeserializeSizeLeft()) or (storedLength > length)) {
return FW_DESERIALIZE_SIZE_MISMATCH; return FW_DESERIALIZE_SIZE_MISMATCH;
} }
@ -545,7 +544,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(U8* buff,
} else { } else {
// make sure enough is left // make sure enough is left
if (length > this->getBuffLeft()) { if (length > this->getDeserializeSizeLeft()) {
return FW_DESERIALIZE_SIZE_MISMATCH; return FW_DESERIALIZE_SIZE_MISMATCH;
} }
@ -556,11 +555,11 @@ SerializeStatus SerializeBufferBase::deserializeTo(U8* buff,
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::deserializeTo(Serializable& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(Serializable& val, Endianness mode) {
return val.deserializeFrom(*this, mode); return val.deserializeFrom(*this, mode);
} }
SerializeStatus SerializeBufferBase::deserializeTo(SerializeBufferBase& val, Endianness mode) { SerializeStatus LinearBufferBase::deserializeTo(LinearBufferBase& val, Endianness mode) {
FW_ASSERT(val.getBuffAddr()); FW_ASSERT(val.getBuffAddr());
SerializeStatus stat = FW_SERIALIZE_OK; SerializeStatus stat = FW_SERIALIZE_OK;
@ -574,7 +573,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(SerializeBufferBase& val, End
// make sure destination has enough room // 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; return FW_DESERIALIZE_SIZE_MISMATCH;
} }
@ -592,7 +591,7 @@ SerializeStatus SerializeBufferBase::deserializeTo(SerializeBufferBase& val, End
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::deserializeSize(FwSizeType& size, Endianness mode) { SerializeStatus LinearBufferBase::deserializeSize(FwSizeType& size, Endianness mode) {
FwSizeStoreType storedSize = 0; FwSizeStoreType storedSize = 0;
Fw::SerializeStatus status = this->deserializeTo(storedSize, mode); Fw::SerializeStatus status = this->deserializeTo(storedSize, mode);
if (status == FW_SERIALIZE_OK) { if (status == FW_SERIALIZE_OK) {
@ -601,21 +600,21 @@ SerializeStatus SerializeBufferBase::deserializeSize(FwSizeType& size, Endiannes
return status; return status;
} }
void SerializeBufferBase::resetSer() { void LinearBufferBase::resetSer() {
this->m_deserLoc = 0; this->m_deserLoc = 0;
this->m_serLoc = 0; this->m_serLoc = 0;
} }
void SerializeBufferBase::resetDeser() { void LinearBufferBase::resetDeser() {
this->m_deserLoc = 0; this->m_deserLoc = 0;
} }
SerializeStatus SerializeBufferBase::serializeSkip(FwSizeType numBytesToSkip) { SerializeStatus LinearBufferBase::serializeSkip(FwSizeType numBytesToSkip) {
Fw::SerializeStatus status = FW_SERIALIZE_OK; Fw::SerializeStatus status = FW_SERIALIZE_OK;
// compute new deser loc // compute new deser loc
const FwSizeType newSerLoc = this->m_serLoc + numBytesToSkip; const FwSizeType newSerLoc = this->m_serLoc + numBytesToSkip;
// check for room // check for room
if (newSerLoc <= this->getBuffCapacity()) { if (newSerLoc <= this->getCapacity()) {
// update deser loc // update deser loc
this->m_serLoc = static_cast<Serializable::SizeType>(newSerLoc); this->m_serLoc = static_cast<Serializable::SizeType>(newSerLoc);
} else { } else {
@ -624,11 +623,11 @@ SerializeStatus SerializeBufferBase::serializeSkip(FwSizeType numBytesToSkip) {
return status; return status;
} }
SerializeStatus SerializeBufferBase::deserializeSkip(FwSizeType numBytesToSkip) { SerializeStatus LinearBufferBase::deserializeSkip(FwSizeType numBytesToSkip) {
// check for room // check for room
if (this->getBuffLength() == this->m_deserLoc) { if (this->getSize() == this->m_deserLoc) {
return FW_DESERIALIZE_BUFFER_EMPTY; 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; return FW_DESERIALIZE_SIZE_MISMATCH;
} }
// update location in buffer to skip the value // update location in buffer to skip the value
@ -636,25 +635,25 @@ SerializeStatus SerializeBufferBase::deserializeSkip(FwSizeType numBytesToSkip)
return FW_SERIALIZE_OK; return FW_SERIALIZE_OK;
} }
SerializeStatus SerializeBufferBase::moveSerToOffset(FwSizeType offset) { SerializeStatus LinearBufferBase::moveSerToOffset(FwSizeType offset) {
// Reset serialization // Reset serialization
this->resetSer(); this->resetSer();
// Advance to offset // Advance to offset
return this->serializeSkip(offset); return this->serializeSkip(offset);
} }
SerializeStatus SerializeBufferBase::moveDeserToOffset(FwSizeType offset) { SerializeStatus LinearBufferBase::moveDeserToOffset(FwSizeType offset) {
// Reset deserialization // Reset deserialization
this->resetDeser(); this->resetDeser();
// Advance to offset // Advance to offset
return this->deserializeSkip(offset); return this->deserializeSkip(offset);
} }
Serializable::SizeType SerializeBufferBase::getBuffLength() const { Serializable::SizeType LinearBufferBase::getSize() const {
return this->m_serLoc; return this->m_serLoc;
} }
SerializeStatus SerializeBufferBase::setBuff(const U8* src, Serializable::SizeType length) { SerializeStatus LinearBufferBase::setBuff(const U8* src, Serializable::SizeType length) {
if (this->getBuffCapacity() < length) { if (this->getCapacity() < length) {
return FW_SERIALIZE_NO_ROOM_LEFT; return FW_SERIALIZE_NO_ROOM_LEFT;
} else { } else {
FW_ASSERT(src); FW_ASSERT(src);
@ -666,8 +665,8 @@ SerializeStatus SerializeBufferBase::setBuff(const U8* src, Serializable::SizeTy
} }
} }
SerializeStatus SerializeBufferBase::setBuffLen(Serializable::SizeType length) { SerializeStatus LinearBufferBase::setBuffLen(Serializable::SizeType length) {
if (this->getBuffCapacity() < length) { if (this->getCapacity() < length) {
return FW_SERIALIZE_NO_ROOM_LEFT; return FW_SERIALIZE_NO_ROOM_LEFT;
} else { } else {
this->m_serLoc = length; 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<FwAssertArgType>(this->m_serLoc), FW_ASSERT(this->m_serLoc >= this->m_deserLoc, static_cast<FwAssertArgType>(this->m_serLoc),
static_cast<FwAssertArgType>(this->m_deserLoc)); static_cast<FwAssertArgType>(this->m_deserLoc));
return this->m_serLoc - 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<FwAssertArgType>(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 // make sure there is sufficient size in destination
if (dest.getBuffCapacity() < size) { if (dest.getCapacity() < size) {
return FW_SERIALIZE_NO_ROOM_LEFT; 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 // otherwise, set destination buffer to data from deserialization pointer plus size
SerializeStatus stat = dest.setBuff(&this->getBuffAddr()[this->m_deserLoc], size); SerializeStatus stat = dest.setBuff(&this->getBuffAddr()[this->m_deserLoc], size);
if (stat == FW_SERIALIZE_OK) { if (stat == FW_SERIALIZE_OK) {
@ -695,13 +704,13 @@ SerializeStatus SerializeBufferBase::copyRaw(SerializeBufferBase& dest, Serializ
return stat; 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 // 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; return FW_SERIALIZE_NO_ROOM_LEFT;
} }
// make sure there is sufficient buffer in source // make sure there is sufficient buffer in source
if (this->getBuffLeft() < size) { if (this->getDeserializeSizeLeft() < size) {
return FW_DESERIALIZE_SIZE_MISMATCH; 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 // return address of buffer not yet deserialized. This is used
// to copy the remainder of a buffer. // to copy the remainder of a buffer.
const U8* SerializeBufferBase::getBuffAddrLeft() const { const U8* LinearBufferBase::getBuffAddrLeft() const {
return &this->getBuffAddr()[this->m_deserLoc]; return &this->getBuffAddr()[this->m_deserLoc];
} }
//!< gets address of end of serialization. Used to manually place data at the end //!< 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]; return &this->getBuffAddr()[this->m_serLoc];
} }
#ifdef BUILD_UT #ifdef BUILD_UT
bool SerializeBufferBase::operator==(const SerializeBufferBase& other) const { bool LinearBufferBase::operator==(const SerializeBufferBase& other) const {
if (this->getBuffLength() != other.getBuffLength()) { if (this->getSize() != other.getSize()) {
return false; return false;
} }
@ -736,7 +745,7 @@ bool SerializeBufferBase::operator==(const SerializeBufferBase& other) const {
FW_ASSERT(us); FW_ASSERT(us);
FW_ASSERT(them); 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]) { if (us[byte] != them[byte]) {
return false; return false;
} }
@ -745,12 +754,12 @@ bool SerializeBufferBase::operator==(const SerializeBufferBase& other) const {
return true; 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(); const U8* us = buff.getBuffAddr();
FW_ASSERT(us); 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; os << "[" << std::setw(2) << std::hex << std::setfill('0') << us[byte] << "]" << std::dec;
} }
@ -780,7 +789,7 @@ void ExternalSerializeBuffer::clear() {
this->m_buffSize = 0; this->m_buffSize = 0;
} }
Serializable::SizeType ExternalSerializeBuffer::getBuffCapacity() const { Serializable::SizeType ExternalSerializeBuffer::getCapacity() const {
return this->m_buffSize; return this->m_buffSize;
} }
@ -796,130 +805,142 @@ const U8* ExternalSerializeBuffer::getBuffAddr() const {
// Deprecated method implementations for backward compatibility // 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); return this->serializeFrom(val);
} }
SerializeStatus SerializeBufferBase::serialize(I8 val) { SerializeStatus LinearBufferBase::serialize(I8 val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
#if FW_HAS_16_BIT == 1 #if FW_HAS_16_BIT == 1
SerializeStatus SerializeBufferBase::serialize(U16 val) { SerializeStatus LinearBufferBase::serialize(U16 val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
SerializeStatus SerializeBufferBase::serialize(I16 val) { SerializeStatus LinearBufferBase::serialize(I16 val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
#endif #endif
#if FW_HAS_32_BIT == 1 #if FW_HAS_32_BIT == 1
SerializeStatus SerializeBufferBase::serialize(U32 val) { SerializeStatus LinearBufferBase::serialize(U32 val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
SerializeStatus SerializeBufferBase::serialize(I32 val) { SerializeStatus LinearBufferBase::serialize(I32 val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
#endif #endif
#if FW_HAS_64_BIT == 1 #if FW_HAS_64_BIT == 1
SerializeStatus SerializeBufferBase::serialize(U64 val) { SerializeStatus LinearBufferBase::serialize(U64 val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
SerializeStatus SerializeBufferBase::serialize(I64 val) { SerializeStatus LinearBufferBase::serialize(I64 val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
#endif #endif
SerializeStatus SerializeBufferBase::serialize(F32 val) { SerializeStatus LinearBufferBase::serialize(F32 val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
SerializeStatus SerializeBufferBase::serialize(F64 val) { SerializeStatus LinearBufferBase::serialize(F64 val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
SerializeStatus SerializeBufferBase::serialize(bool val) { SerializeStatus LinearBufferBase::serialize(bool val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
SerializeStatus SerializeBufferBase::serialize(const void* val) { SerializeStatus LinearBufferBase::serialize(const void* val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
// Deprecated method for backward compatibility // 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; const Serialization::t mode = noLength ? Serialization::OMIT_LENGTH : Serialization::INCLUDE_LENGTH;
return this->serializeFrom(buff, length, mode); 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); 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); return this->serializeFrom(buff, length, mode);
} }
SerializeStatus SerializeBufferBase::serialize(const Serializable& val) { SerializeStatus LinearBufferBase::serialize(const Serializable& val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
SerializeStatus SerializeBufferBase::serialize(const SerializeBufferBase& val) { SerializeStatus LinearBufferBase::serialize(const LinearBufferBase& val) {
return this->serializeFrom(val); return this->serializeFrom(val);
} }
SerializeStatus SerializeBufferBase::deserialize(U8& val) { SerializeStatus LinearBufferBase::deserialize(U8& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
SerializeStatus SerializeBufferBase::deserialize(I8& val) { SerializeStatus LinearBufferBase::deserialize(I8& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
#if FW_HAS_16_BIT == 1 #if FW_HAS_16_BIT == 1
SerializeStatus SerializeBufferBase::deserialize(U16& val) { SerializeStatus LinearBufferBase::deserialize(U16& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
SerializeStatus SerializeBufferBase::deserialize(I16& val) { SerializeStatus LinearBufferBase::deserialize(I16& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
#endif #endif
#if FW_HAS_32_BIT == 1 #if FW_HAS_32_BIT == 1
SerializeStatus SerializeBufferBase::deserialize(U32& val) { SerializeStatus LinearBufferBase::deserialize(U32& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
SerializeStatus SerializeBufferBase::deserialize(I32& val) { SerializeStatus LinearBufferBase::deserialize(I32& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
#endif #endif
#if FW_HAS_64_BIT == 1 #if FW_HAS_64_BIT == 1
SerializeStatus SerializeBufferBase::deserialize(U64& val) { SerializeStatus LinearBufferBase::deserialize(U64& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
SerializeStatus SerializeBufferBase::deserialize(I64& val) { SerializeStatus LinearBufferBase::deserialize(I64& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
#endif #endif
SerializeStatus SerializeBufferBase::deserialize(F32& val) { SerializeStatus LinearBufferBase::deserialize(F32& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
SerializeStatus SerializeBufferBase::deserialize(F64& val) { SerializeStatus LinearBufferBase::deserialize(F64& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
SerializeStatus SerializeBufferBase::deserialize(bool& val) { SerializeStatus LinearBufferBase::deserialize(bool& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
SerializeStatus SerializeBufferBase::deserialize(void*& val) { SerializeStatus LinearBufferBase::deserialize(void*& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
// Deprecated method for backward compatibility // 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; const Serialization::t mode = noLength ? Serialization::OMIT_LENGTH : Serialization::INCLUDE_LENGTH;
return this->deserializeTo(buff, length, mode); 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); 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); return this->deserializeTo(buff, length, mode);
} }
SerializeStatus SerializeBufferBase::deserialize(Serializable& val) { SerializeStatus LinearBufferBase::deserialize(Serializable& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
SerializeStatus SerializeBufferBase::deserialize(SerializeBufferBase& val) { SerializeStatus LinearBufferBase::deserialize(LinearBufferBase& val) {
return this->deserializeTo(val); return this->deserializeTo(val);
} }
Serializable::SizeType ExternalSerializeBuffer::getBuffCapacity() const {
return this->getCapacity();
}
} // namespace Fw } // namespace Fw

File diff suppressed because it is too large Load Diff

View File

@ -139,17 +139,17 @@ StringBase::SizeType StringBase::serializedTruncatedSize(FwSizeType maxLength) c
return static_cast<SizeType>(sizeof(FwSizeStoreType)) + static_cast<SizeType>(FW_MIN(this->length(), maxLength)); return static_cast<SizeType>(sizeof(FwSizeStoreType)) + static_cast<SizeType>(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<const U8*>(this->toChar()), this->length()); return buffer.serializeFrom(reinterpret_cast<const U8*>(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()); const FwSizeType len = FW_MIN(maxLength, this->length());
// Serialize length and then bytes // Serialize length and then bytes
return buffer.serializeFrom(reinterpret_cast<const U8*>(this->toChar()), len, Serialization::INCLUDE_LENGTH); return buffer.serializeFrom(reinterpret_cast<const U8*>(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 // Get the max size of the deserialized string
const SizeType maxSize = this->maxLength(); const SizeType maxSize = this->maxLength();
// Initial estimate of actual size is max size // Initial estimate of actual size is max size

View File

@ -66,18 +66,18 @@ class StringBase : public Serializable {
FormatStatus format(const CHAR* formatString, ...); //!< write formatted string to buffer 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 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; SerializeStatus serializeTo(SerialBufferBase& buffer, Endianness mode = Endianness::BIG) const override;
virtual SerializeStatus serializeTo(SerializeBufferBase& buffer, virtual SerializeStatus serializeTo(SerialBufferBase& buffer,
SizeType maxLen, SizeType maxLen,
Endianness mode = Endianness::BIG) const; 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") { "Use serializeTo(SerializeBufferBase& buffer) instead") {
return this->serializeTo(buffer); 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") { "Use serializeTo(SerializeBufferBase& buffer, SizeType maxLen) instead") {
return this->serializeTo(buffer, maxLen); return this->serializeTo(buffer, maxLen);
} }

View File

@ -12,37 +12,37 @@ constexpr SizeType BUFFER_SIZE = 10;
U8 buffer[BUFFER_SIZE]; U8 buffer[BUFFER_SIZE];
void serializeOK(Fw::ExternalSerializeBuffer& esb) { void serializeOK(Fw::ExternalSerializeBuffer& esb) {
const SizeType buffCapacity = esb.getBuffCapacity(); const SizeType buffCapacity = esb.getCapacity();
ASSERT_EQ(esb.getBuffLength(), 0); ASSERT_EQ(esb.getSize(), 0);
for (SizeType i = 0; i < buffCapacity; i++) { for (SizeType i = 0; i < buffCapacity; i++) {
const U8 value = static_cast<U8>(i); const U8 value = static_cast<U8>(i);
const Fw::SerializeStatus status = esb.serializeFrom(value); const Fw::SerializeStatus status = esb.serializeFrom(value);
ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK);
} }
ASSERT_EQ(esb.getBuffLength(), buffCapacity); ASSERT_EQ(esb.getSize(), buffCapacity);
} }
void serializeFail(Fw::ExternalSerializeBuffer& esb) { 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<U8>(0)); const Fw::SerializeStatus status = esb.serializeFrom(static_cast<U8>(0));
ASSERT_EQ(status, Fw::FW_SERIALIZE_NO_ROOM_LEFT); ASSERT_EQ(status, Fw::FW_SERIALIZE_NO_ROOM_LEFT);
} }
void deserializeOK(Fw::ExternalSerializeBuffer& esb) { void deserializeOK(Fw::ExternalSerializeBuffer& esb) {
const SizeType buffCapacity = esb.getBuffCapacity(); const SizeType buffCapacity = esb.getCapacity();
ASSERT_EQ(esb.getBuffLeft(), buffCapacity); ASSERT_EQ(esb.getDeserializeSizeLeft(), buffCapacity);
for (SizeType i = 0; i < buffCapacity; i++) { for (SizeType i = 0; i < buffCapacity; i++) {
U8 value = 0; U8 value = 0;
const Fw::SerializeStatus status = esb.deserializeTo(value); const Fw::SerializeStatus status = esb.deserializeTo(value);
ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); ASSERT_EQ(status, Fw::FW_SERIALIZE_OK);
ASSERT_EQ(value, static_cast<U8>(i)); ASSERT_EQ(value, static_cast<U8>(i));
} }
ASSERT_EQ(esb.getBuffLeft(), 0); ASSERT_EQ(esb.getDeserializeSizeLeft(), 0);
} }
void deserializeFail(Fw::ExternalSerializeBuffer& esb) { void deserializeFail(Fw::ExternalSerializeBuffer& esb) {
U8 value = 0; U8 value = 0;
ASSERT_EQ(esb.getBuffLeft(), 0); ASSERT_EQ(esb.getDeserializeSizeLeft(), 0);
const Fw::SerializeStatus status = esb.deserializeTo(value); const Fw::SerializeStatus status = esb.deserializeTo(value);
ASSERT_EQ(status, Fw::FW_DESERIALIZE_BUFFER_EMPTY); ASSERT_EQ(status, Fw::FW_DESERIALIZE_BUFFER_EMPTY);
} }

View File

@ -30,7 +30,7 @@
class SerializeTestBuffer : public Fw::SerializeBufferBase { class SerializeTestBuffer : public Fw::SerializeBufferBase {
public: 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); return sizeof(m_testBuff);
} }
@ -887,7 +887,7 @@ struct TestStruct {
class MySerializable : public Fw::Serializable { class MySerializable : public Fw::Serializable {
public: public:
Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase& buffer, Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& buffer,
Fw::Endianness mode = Fw::Endianness::BIG) const override { Fw::Endianness mode = Fw::Endianness::BIG) const override {
buffer.serializeFrom(m_testStruct.m_u32, mode); buffer.serializeFrom(m_testStruct.m_u32, mode);
buffer.serializeFrom(m_testStruct.m_u16, mode); buffer.serializeFrom(m_testStruct.m_u16, mode);
@ -897,7 +897,7 @@ class MySerializable : public Fw::Serializable {
return Fw::FW_SERIALIZE_OK; return Fw::FW_SERIALIZE_OK;
} }
Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase& buffer, Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer,
Fw::Endianness mode = Fw::Endianness::BIG) override { Fw::Endianness mode = Fw::Endianness::BIG) override {
buffer.serializeFrom(m_testStruct.m_buff, sizeof(m_testStruct.m_buff)); buffer.serializeFrom(m_testStruct.m_buff, sizeof(m_testStruct.m_buff));
buffer.serializeFrom(m_testStruct.m_f32, mode); buffer.serializeFrom(m_testStruct.m_f32, mode);

View File

@ -44,7 +44,7 @@ PosixRawTime::Status PosixRawTime::getTimeInterval(const Os::RawTime& other, Fw:
return Status::OP_OK; 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), static_assert(PosixRawTime::SERIALIZED_SIZE >= 2 * sizeof(U32),
"PosixRawTime implementation requires at least 2*sizeof(U32) serialization size"); "PosixRawTime implementation requires at least 2*sizeof(U32) serialization size");
Fw::SerializeStatus status = buffer.serializeFrom(static_cast<U32>(this->m_handle.m_timespec.tv_sec), mode); Fw::SerializeStatus status = buffer.serializeFrom(static_cast<U32>(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<U32>(this->m_handle.m_timespec.tv_nsec), mode); return buffer.serializeFrom(static_cast<U32>(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), static_assert(PosixRawTime::SERIALIZED_SIZE >= 2 * sizeof(U32),
"PosixRawTime implementation requires at least 2*sizeof(U32) serialization size"); "PosixRawTime implementation requires at least 2*sizeof(U32) serialization size");
U32 sec = 0; U32 sec = 0;

View File

@ -65,7 +65,7 @@ class PosixRawTime : public RawTimeInterface {
//! //!
//! \param buffer The buffer to serialize the contents into. //! \param buffer The buffer to serialize the contents into.
//! \return Fw::SerializeStatus indicating the result of the serialization. //! \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; Fw::Endianness mode = Fw::Endianness::BIG) const override;
//! \brief Deserialize the contents of the RawTimeInterface object from a buffer. //! \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. //! \param buffer The buffer to deserialize the contents from.
//! \return Fw::SerializeStatus indicating the result of the deserialization. //! \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; Fw::Endianness mode = Fw::Endianness::BIG) override;
private: private:

View File

@ -93,19 +93,19 @@ QueueHandle* Queue::getHandle() {
return this->m_delegate.getHandle(); return this->m_delegate.getHandle();
} }
QueueInterface::Status Queue::send(const Fw::SerializeBufferBase& message, QueueInterface::Status Queue::send(const Fw::LinearBufferBase& message,
FwQueuePriorityType priority, FwQueuePriorityType priority,
QueueInterface::BlockingType blockType) { 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, QueueInterface::BlockingType blockType,
FwQueuePriorityType& priority) { FwQueuePriorityType& priority) {
FwSizeType actualSize = 0; FwSizeType actualSize = 0;
destination.resetSer(); // Reset the buffer destination.resetSer(); // Reset the buffer
QueueInterface::Status status = 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) { if (status == QueueInterface::Status::OP_OK) {
Fw::SerializeStatus serializeStatus = Fw::SerializeStatus serializeStatus =
destination.setBuffLen(static_cast<Fw::Serializable::SizeType>(actualSize)); destination.setBuffLen(static_cast<Fw::Serializable::SizeType>(actualSize));

View File

@ -248,7 +248,7 @@ class Queue final : public QueueInterface {
//! \param priority: priority of the message //! \param priority: priority of the message
//! \param blockType: BLOCKING to block for space or NONBLOCKING to return error when queue is full //! \param blockType: BLOCKING to block for space or NONBLOCKING to return error when queue is full
//! \return status of the send //! \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 //! \brief receive a message from a queue
//! //!
@ -261,7 +261,7 @@ class Queue final : public QueueInterface {
//! \param priority: (output) priority of the message //! \param priority: (output) priority of the message
//! \param blockType: BLOCKING to block for space or NONBLOCKING to return error when queue is full //! \param blockType: BLOCKING to block for space or NONBLOCKING to return error when queue is full
//! \return status of the send //! \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 //! \brief get the queue's depth in messages
FwSizeType getDepth() const; FwSizeType getDepth() const;

View File

@ -43,12 +43,12 @@ RawTime::Status RawTime::getTimeInterval(const Os::RawTime& other, Fw::TimeInter
return this->m_delegate.getTimeInterval(other, result); 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<const RawTimeInterface*>(&this->m_handle_storage[0])); FW_ASSERT(&this->m_delegate == reinterpret_cast<const RawTimeInterface*>(&this->m_handle_storage[0]));
return this->m_delegate.serializeTo(buffer, mode); 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<const RawTimeInterface*>(&this->m_handle_storage[0])); FW_ASSERT(&this->m_delegate == reinterpret_cast<const RawTimeInterface*>(&this->m_handle_storage[0]));
return this->m_delegate.deserializeFrom(buffer, mode); return this->m_delegate.deserializeFrom(buffer, mode);
} }

View File

@ -77,7 +77,7 @@ class RawTimeInterface : public Fw::Serializable {
//! //!
//! \param buffer The buffer to serialize the contents into. //! \param buffer The buffer to serialize the contents into.
//! \return Fw::SerializeStatus indicating the result of the serialization. //! \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; Fw::Endianness mode = Fw::Endianness::BIG) const = 0;
//! \brief Deserialize the contents of the RawTimeInterface object from a buffer. //! \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. //! \param buffer The buffer to deserialize the contents from.
//! \return Fw::SerializeStatus indicating the result of the deserialization. //! \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; 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. //! \param buffer The buffer to serialize the contents into.
//! \return Fw::SerializeStatus indicating the result of the serialization. //! \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; Fw::Endianness mode = Fw::Endianness::BIG) const override;
//! \brief Deserialize the contents of the RawTimeInterface object from a buffer. //! \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. //! \param buffer The buffer to deserialize the contents from.
//! \return Fw::SerializeStatus indicating the result of the deserialization. //! \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; Fw::Endianness mode = Fw::Endianness::BIG) override;
// ------------------------------------------------------------ // ------------------------------------------------------------

View File

@ -21,11 +21,11 @@ StubRawTime::Status StubRawTime::getTimeInterval(const Os::RawTime& other, Fw::T
return Status::OP_OK; 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; 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; return Fw::FW_SERIALIZE_OK;
} }

View File

@ -64,7 +64,7 @@ class StubRawTime : public RawTimeInterface {
//! //!
//! \param buffer The buffer to serialize the contents into. //! \param buffer The buffer to serialize the contents into.
//! \return Fw::SerializeStatus indicating the result of the serialization. //! \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; Fw::Endianness mode = Fw::Endianness::BIG) const override;
//! \brief Deserialize the contents of the RawTimeInterface object from a buffer. //! \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. //! \param buffer The buffer to deserialize the contents from.
//! \return Fw::SerializeStatus indicating the result of the deserialization. //! \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; Fw::Endianness mode = Fw::Endianness::BIG) override;
private: private:

View File

@ -38,12 +38,12 @@ TestRawTime::Status TestRawTime::getTimeInterval(const Os::RawTime& other, Fw::T
return Status::OP_OK; 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; StaticData::data.lastCalled = StaticData::LastFn::SERIALIZE_FN;
return Fw::FW_SERIALIZE_OK; 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; StaticData::data.lastCalled = StaticData::LastFn::DESERIALIZE_FN;
return Fw::FW_SERIALIZE_OK; return Fw::FW_SERIALIZE_OK;
} }

View File

@ -67,9 +67,9 @@ class TestRawTime : public RawTimeInterface {
// ------------------------------------------------------------ // ------------------------------------------------------------
Status now() override; Status now() override;
Status getTimeInterval(const Os::RawTime& other, Fw::TimeInterval& interval) const 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::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; Fw::Endianness mode = Fw::Endianness::BIG) override;
private: private:

View File

@ -71,12 +71,12 @@ File::Status readHash(const char* hashFileName, Utils::HashBuffer& hashBuffer) {
// Read hash from checksum file: // Read hash from checksum file:
unsigned char savedHash[HASH_DIGEST_LENGTH]; unsigned char savedHash[HASH_DIGEST_LENGTH];
FwSizeType size = static_cast<FwSizeType>(hashBuffer.getBuffCapacity()); FwSizeType size = static_cast<FwSizeType>(hashBuffer.getCapacity());
status = hashFile.read(savedHash, size); status = hashFile.read(savedHash, size);
if (File::OP_OK != status) { if (File::OP_OK != status) {
return status; return status;
} }
if (static_cast<FwSizeType>(size) != hashBuffer.getBuffCapacity()) { if (static_cast<FwSizeType>(size) != hashBuffer.getCapacity()) {
return File::BAD_SIZE; return File::BAD_SIZE;
} }
hashFile.close(); hashFile.close();
@ -98,12 +98,12 @@ File::Status writeHash(const char* hashFileName, Utils::HashBuffer hashBuffer) {
} }
// Write out the hash // Write out the hash
FwSizeType size = static_cast<FwSizeType>(hashBuffer.getBuffLength()); FwSizeType size = static_cast<FwSizeType>(hashBuffer.getSize());
status = hashFile.write(hashBuffer.getBuffAddr(), size, Os::File::WaitType::NO_WAIT); status = hashFile.write(hashBuffer.getBuffAddr(), size, Os::File::WaitType::NO_WAIT);
if (File::OP_OK != status) { if (File::OP_OK != status) {
return status; return status;
} }
if (static_cast<FwSizeType>(size) != hashBuffer.getBuffLength()) { if (static_cast<FwSizeType>(size) != hashBuffer.getSize()) {
return File::BAD_SIZE; return File::BAD_SIZE;
} }
hashFile.close(); hashFile.close();

View File

@ -59,7 +59,7 @@ void testValidateFile(const char* fileName) {
return; return;
} }
Utils::HashBuffer buf; Utils::HashBuffer buf;
EXPECT_TRUE(static_cast<FwSizeType>(fileSize) == buf.getBuffCapacity()); EXPECT_TRUE(static_cast<FwSizeType>(fileSize) == buf.getCapacity());
// Validate file: // Validate file:
printf("Validating file %s against hash file %s\n", fileName, hashFileName); printf("Validating file %s against hash file %s\n", fileName, hashFileName);

View File

@ -50,7 +50,7 @@ void BufferLogger ::bufferSendIn_handler(const FwIndexType portNum, Fw::Buffer&
void BufferLogger ::comIn_handler(FwIndexType portNum, Fw::ComBuffer& data, U32 context) { void BufferLogger ::comIn_handler(FwIndexType portNum, Fw::ComBuffer& data, U32 context) {
if (m_state == LogState::LOGGING_ON) { if (m_state == LogState::LOGGING_ON) {
const U8* const addr = data.getBuffAddr(); const U8* const addr = data.getBuffAddr();
const FwSizeType size = data.getBuffLength(); const FwSizeType size = data.getSize();
m_file.logBuffer(addr, size); m_file.logBuffer(addr, size);
} }
} }

View File

@ -108,7 +108,7 @@ void TmFramer ::dataReturnIn_handler(FwIndexType portNum,
void TmFramer ::fill_with_idle_packet(Fw::SerializeBufferBase& serializer) { void TmFramer ::fill_with_idle_packet(Fw::SerializeBufferBase& serializer) {
constexpr U16 endIndex = ComCfg::TmFrameFixedSize - TMTrailer::SERIALIZED_SIZE; constexpr U16 endIndex = ComCfg::TmFrameFixedSize - TMTrailer::SERIALIZED_SIZE;
constexpr U16 idleApid = static_cast<U16>(ComCfg::Apid::SPP_IDLE_PACKET); constexpr U16 idleApid = static_cast<U16>(ComCfg::Apid::SPP_IDLE_PACKET);
const U16 startIndex = static_cast<U16>(serializer.getBuffLength()); const U16 startIndex = static_cast<U16>(serializer.getSize());
const U16 idlePacketSize = static_cast<U16>(endIndex - startIndex); const U16 idlePacketSize = static_cast<U16>(endIndex - startIndex);
// Length token is defined as the number of bytes of payload data minus 1 // Length token is defined as the number of bytes of payload data minus 1
const U16 lengthToken = static_cast<U16>(idlePacketSize - SpacePacketHeader::SERIALIZED_SIZE - 1); const U16 lengthToken = static_cast<U16>(idlePacketSize - SpacePacketHeader::SERIALIZED_SIZE - 1);

View File

@ -58,7 +58,7 @@ bool CmdSequencerComponentImpl::FPrimeSequence ::loadFile(const Fw::StringBase&
} }
bool CmdSequencerComponentImpl::FPrimeSequence ::hasMoreRecords() const { bool CmdSequencerComponentImpl::FPrimeSequence ::hasMoreRecords() const {
return this->m_buffer.getBuffLeft() > 0; return this->m_buffer.getDeserializeSizeLeft() > 0;
} }
void CmdSequencerComponentImpl::FPrimeSequence ::nextRecord(Record& record) { void CmdSequencerComponentImpl::FPrimeSequence ::nextRecord(Record& record) {
@ -102,7 +102,7 @@ bool CmdSequencerComponentImpl::FPrimeSequence ::readOpenFile() {
status = this->deserializeHeader() and this->readRecordsAndCRC() and this->extractCRC(); status = this->deserializeHeader() and this->readRecordsAndCRC() and this->extractCRC();
} }
if (status) { 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.update(buffAddr, buffLen);
this->m_crc.finalize(); this->m_crc.finalize();
} }
@ -116,7 +116,7 @@ bool CmdSequencerComponentImpl::FPrimeSequence ::readHeader() {
FwSizeType readLen = Sequence::Header::SERIALIZED_SIZE; FwSizeType readLen = Sequence::Header::SERIALIZED_SIZE;
const FwSizeType capacity = buffer.getBuffCapacity(); const FwSizeType capacity = buffer.getCapacity();
FW_ASSERT(capacity >= readLen, static_cast<FwAssertArgType>(capacity), static_cast<FwAssertArgType>(readLen)); FW_ASSERT(capacity >= readLen, static_cast<FwAssertArgType>(capacity), static_cast<FwAssertArgType>(readLen));
Os::File::Status fileStatus = file.read(buffer.getBuffAddr(), 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); this->m_events.fileInvalid(CmdSequencer_FileReadStage::DESER_SIZE, serializeStatus);
return false; return false;
} }
if (header.m_fileSize > buffer.getBuffCapacity()) { if (header.m_fileSize > buffer.getCapacity()) {
this->m_events.fileSizeError(header.m_fileSize); this->m_events.fileSizeError(header.m_fileSize);
return false; return false;
} }
@ -203,7 +203,7 @@ bool CmdSequencerComponentImpl::FPrimeSequence ::extractCRC() {
U32& crc = this->m_crc.m_stored; U32& crc = this->m_crc.m_stored;
// Compute the data size // Compute the data size
const FwSizeType buffSize = buffer.getBuffLength(); const FwSizeType buffSize = buffer.getSize();
const FwSizeType crcSize = sizeof(crc); const FwSizeType crcSize = sizeof(crc);
U8* const buffAddr = buffer.getBuffAddr(); U8* const buffAddr = buffer.getBuffAddr();
if (buffSize < crcSize) { if (buffSize < crcSize) {
@ -280,7 +280,7 @@ Fw::SerializeStatus CmdSequencerComponentImpl::FPrimeSequence ::deserializeTimeT
Fw::SerializeStatus CmdSequencerComponentImpl::FPrimeSequence ::deserializeRecordSize(U32& recordSize) { Fw::SerializeStatus CmdSequencerComponentImpl::FPrimeSequence ::deserializeRecordSize(U32& recordSize) {
Fw::SerializeBufferBase& buffer = this->m_buffer; Fw::SerializeBufferBase& buffer = this->m_buffer;
Fw::SerializeStatus status = buffer.deserializeTo(recordSize); 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 // Not enough data left
status = Fw::FW_DESERIALIZE_SIZE_MISMATCH; status = Fw::FW_DESERIALIZE_SIZE_MISMATCH;
} }
@ -322,7 +322,7 @@ bool CmdSequencerComponentImpl::FPrimeSequence ::validateRecords() {
} }
} }
// Check there is no data left // Check there is no data left
const FwSizeType buffLeftSize = buffer.getBuffLeft(); const FwSizeType buffLeftSize = buffer.getDeserializeSizeLeft();
if (buffLeftSize > 0) { if (buffLeftSize > 0) {
this->m_events.recordMismatch(numRecords, static_cast<U32>(buffLeftSize)); this->m_events.recordMismatch(numRecords, static_cast<U32>(buffLeftSize));
return false; return false;

View File

@ -108,7 +108,7 @@ bool AMPCSSequence ::validateRecords() {
Sequence::Record record; Sequence::Record record;
// Deserialize all records and count the records // Deserialize all records and count the records
const U32 loopBound = static_cast<U32>(buffer.getBuffLeft()); const U32 loopBound = static_cast<U32>(buffer.getDeserializeSizeLeft());
U32 numRecords = 0; U32 numRecords = 0;
for (; numRecords < loopBound; ++numRecords) { for (; numRecords < loopBound; ++numRecords) {
if (not this->hasMoreRecords()) { if (not this->hasMoreRecords()) {
@ -129,7 +129,7 @@ bool AMPCSSequence ::validateRecords() {
} }
bool AMPCSSequence ::hasMoreRecords() const { bool AMPCSSequence ::hasMoreRecords() const {
return this->m_buffer.getBuffLeft() > 0; return this->m_buffer.getDeserializeSizeLeft() > 0;
} }
void AMPCSSequence ::nextRecord(Sequence::Record& record) { void AMPCSSequence ::nextRecord(Sequence::Record& record) {
@ -186,7 +186,7 @@ bool AMPCSSequence ::readOpenSequenceFile() {
} }
if (status) { if (status) {
U8* const buffAddr = this->m_buffer.getBuffAddr(); 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<FwAssertArgType>(buffLen), FW_ASSERT(buffLen == this->m_header.m_fileSize, static_cast<FwAssertArgType>(buffLen),
static_cast<FwAssertArgType>(this->m_header.m_fileSize)); static_cast<FwAssertArgType>(this->m_header.m_fileSize));
this->m_crc.update(buffAddr, buffLen); this->m_crc.update(buffAddr, buffLen);
@ -223,7 +223,7 @@ bool AMPCSSequence ::readRecords() {
U8* const addr = buffer.getBuffAddr(); U8* const addr = buffer.getBuffAddr();
// Check file size // Check file size
if (size > this->m_buffer.getBuffCapacity()) { if (size > this->m_buffer.getCapacity()) {
this->m_events.fileSizeError(static_cast<U32>(size)); this->m_events.fileSizeError(static_cast<U32>(size));
return false; return false;
} }
@ -298,7 +298,7 @@ Fw::SerializeStatus AMPCSSequence ::deserializeTime(Fw::Time& timeTag) {
Fw::SerializeStatus AMPCSSequence ::deserializeCmdLength(Record::CmdLength::t& cmdLength) { Fw::SerializeStatus AMPCSSequence ::deserializeCmdLength(Record::CmdLength::t& cmdLength) {
Fw::SerializeBufferBase& buffer = this->m_buffer; Fw::SerializeBufferBase& buffer = this->m_buffer;
Fw::SerializeStatus status = buffer.deserializeTo(cmdLength); 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 // Not enough data left
status = Fw::FW_DESERIALIZE_SIZE_MISMATCH; status = Fw::FW_DESERIALIZE_SIZE_MISMATCH;
} }
@ -328,7 +328,7 @@ Fw::SerializeStatus AMPCSSequence ::translateCommand(Fw::ComBuffer& comBuffer, c
sizeOfZeros += static_cast<U32>(sizeof(zeros)); sizeOfZeros += static_cast<U32>(sizeof(zeros));
} }
// Set the buffer length // Set the buffer length
const U32 fixedBuffLen = static_cast<U32>(comBuffer.getBuffLength()); const U32 fixedBuffLen = static_cast<U32>(comBuffer.getSize());
FW_ASSERT(fixedBuffLen == sizeof(cmdDescriptor) + sizeOfZeros, static_cast<FwAssertArgType>(fixedBuffLen)); FW_ASSERT(fixedBuffLen == sizeof(cmdDescriptor) + sizeOfZeros, static_cast<FwAssertArgType>(fixedBuffLen));
const U32 totalBuffLen = fixedBuffLen + cmdLength; const U32 totalBuffLen = fixedBuffLen + cmdLength;
status = comBuffer.setBuffLen(totalBuffLen); status = comBuffer.setBuffLen(totalBuffLen);

View File

@ -61,7 +61,7 @@ void createFile(Fw::SerializeBufferBase& buffer, const char* const fileName) {
void computeCRC(Fw::SerializeBufferBase& buffer, CRC& crc) { void computeCRC(Fw::SerializeBufferBase& buffer, CRC& crc) {
crc.init(); crc.init();
const U8* const addr = buffer.getBuffAddr(); const U8* const addr = buffer.getBuffAddr();
const U32 size = buffer.getBuffLength(); const U32 size = buffer.getSize();
crc.update(addr, size); crc.update(addr, size);
crc.finalize(); crc.finalize();
} }

View File

@ -24,7 +24,7 @@ void serialize(const AMPCSSequence::Record::TimeFlag::t timeFlag,
const Fw::SerializeBufferBase& cmdField, const Fw::SerializeBufferBase& cmdField,
Fw::SerializeBufferBase& dest) { Fw::SerializeBufferBase& dest) {
const AMPCSSequence::Record::TimeFlag::Serial::t serialTimeFlag = timeFlag; 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(); const U8* const addr = cmdField.getBuffAddr();
ASSERT_EQ(Fw::FW_SERIALIZE_OK, dest.serializeFrom(serialTimeFlag)); ASSERT_EQ(Fw::FW_SERIALIZE_OK, dest.serializeFrom(serialTimeFlag));
ASSERT_EQ(Fw::FW_SERIALIZE_OK, dest.serializeFrom(time)); ASSERT_EQ(Fw::FW_SERIALIZE_OK, dest.serializeFrom(time));

View File

@ -33,7 +33,7 @@ void BadCRCFile ::serializeFPrime(Fw::SerializeBufferBase& buffer) {
ASSERT_EQ(Fw::FW_SERIALIZE_OK, buffer.serializeFrom(recordData)); ASSERT_EQ(Fw::FW_SERIALIZE_OK, buffer.serializeFrom(recordData));
// CRC // CRC
const U8* const addr = buffer.getBuffAddr(); const U8* const addr = buffer.getBuffAddr();
const U32 size = buffer.getBuffLength(); const U32 size = buffer.getSize();
this->crc.init(); this->crc.init();
this->crc.update(addr, size); this->crc.update(addr, size);
this->crc.finalize(); this->crc.finalize();

View File

@ -19,10 +19,14 @@ namespace SequenceFiles {
namespace Buffers { namespace Buffers {
FwSizeType FileBuffer ::getBuffCapacity() const { FwSizeType FileBuffer ::getCapacity() const {
return sizeof(m_buff); return sizeof(m_buff);
} }
FwSizeType FileBuffer ::getBuffCapacity() const {
return this->getCapacity();
}
U8* FileBuffer ::getBuffAddr() { U8* FileBuffer ::getBuffAddr() {
return m_buff; return m_buff;
} }
@ -34,7 +38,7 @@ const U8* FileBuffer ::getBuffAddr() const {
void write(const Fw::SerializeBufferBase& buffer, const char* fileName) { void write(const Fw::SerializeBufferBase& buffer, const char* fileName) {
Os::File file; Os::File file;
ASSERT_EQ(file.open(fileName, Os::File::OPEN_WRITE), Os::File::OP_OK); 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 U32 expectedSize = size;
const U8* const buffAddr = buffer.getBuffAddr(); const U8* const buffAddr = buffer.getBuffAddr();
ASSERT_EQ(file.write(buffAddr, size, Os::File::WaitType::WAIT), Os::File::OP_OK); ASSERT_EQ(file.write(buffAddr, size, Os::File::WaitType::WAIT), Os::File::OP_OK);

View File

@ -26,7 +26,8 @@ class FileBuffer : public Fw::SerializeBufferBase {
enum Constants { CAPACITY = 4096 }; enum Constants { CAPACITY = 4096 };
public: public:
FwSizeType getBuffCapacity() const; DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead");
FwSizeType getCapacity() const;
U8* getBuffAddr(); U8* getBuffAddr();

View File

@ -22,7 +22,7 @@ namespace CRCs {
void serialize(Fw::SerializeBufferBase& destBuffer) { void serialize(Fw::SerializeBufferBase& destBuffer) {
CmdSequencerComponentImpl::FPrimeSequence::CRC crc; CmdSequencerComponentImpl::FPrimeSequence::CRC crc;
crc.init(); crc.init();
crc.update(destBuffer.getBuffAddr(), destBuffer.getBuffLength()); crc.update(destBuffer.getBuffAddr(), destBuffer.getSize());
crc.finalize(); crc.finalize();
ASSERT_EQ(destBuffer.serializeFrom(crc.m_computed), Fw::FW_SERIALIZE_OK); ASSERT_EQ(destBuffer.serializeFrom(crc.m_computed), Fw::FW_SERIALIZE_OK);
} }

View File

@ -27,7 +27,7 @@ void serialize(Records::Descriptor desc,
ASSERT_EQ(Fw::FW_SERIALIZE_OK, destBuffer.serializeFrom(descU8)); ASSERT_EQ(Fw::FW_SERIALIZE_OK, destBuffer.serializeFrom(descU8));
if (desc != CmdSequencerComponentImpl::Sequence::Record::END_OF_SEQUENCE) { if (desc != CmdSequencerComponentImpl::Sequence::Record::END_OF_SEQUENCE) {
const U8* const buffAddr = opcodeAndArgument.getBuffAddr(); const U8* const buffAddr = opcodeAndArgument.getBuffAddr();
const U32 size = opcodeAndArgument.getBuffLength(); const U32 size = opcodeAndArgument.getSize();
const U32 recSize = sizeof(FwPacketDescriptorType) + size; const U32 recSize = sizeof(FwPacketDescriptorType) + size;
const FwPacketDescriptorType cmdDescriptor = Fw::ComPacketType::FW_PACKET_COMMAND; const FwPacketDescriptorType cmdDescriptor = Fw::ComPacketType::FW_PACKET_COMMAND;
const U32 seconds = time.getSeconds(); const U32 seconds = time.getSeconds();

View File

@ -45,7 +45,7 @@ void TooLargeFile ::serializeAMPCS(Fw::SerializeBufferBase& buffer) {
Fw::SerialBuffer cmdField(cmdFieldBuffer, sizeof(cmdFieldBuffer)); Fw::SerialBuffer cmdField(cmdFieldBuffer, sizeof(cmdFieldBuffer));
cmdField.setBuffLen(cmdFieldSize); cmdField.setBuffLen(cmdFieldSize);
AMPCS::Records::serialize(timeFlag, time, cmdField, buffer); 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 // CRC
AMPCS::CRCs::createFile(buffer, this->getName().toChar()); AMPCS::CRCs::createFile(buffer, this->getName().toChar());
} }

View File

@ -36,7 +36,7 @@ Fw::ComBuffer CmdSplitterTester ::build_command_around_opcode(FwOpcodeType opcod
Fw::CmdArgBuffer args; Fw::CmdArgBuffer args;
U32 random_size = STest::Pick::lowerUpper(0, static_cast<U32>(args.getBuffCapacity())); U32 random_size = STest::Pick::lowerUpper(0, static_cast<U32>(args.getCapacity()));
args.resetSer(); args.resetSer();
for (FwSizeType i = 0; i < random_size; i++) { for (FwSizeType i = 0; i < random_size; i++) {
args.serializeFrom(static_cast<U8>(STest::Pick::any())); args.serializeFrom(static_cast<U8>(STest::Pick::any()));

View File

@ -76,9 +76,9 @@ void ComAggregator ::Svc_AggregationMachine_action_doFill(SmId smId,
void ComAggregator ::Svc_AggregationMachine_action_doSend(SmId smId, Svc_AggregationMachine::Signal signal) { void ComAggregator ::Svc_AggregationMachine_action_doSend(SmId smId, Svc_AggregationMachine::Signal signal) {
// Send only when the buffer will be valid // 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_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); 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, Svc_AggregationMachine::Signal signal,
const Svc::ComDataContextPair& value) const { const Svc::ComDataContextPair& value) const {
FW_ASSERT(value.get_data().getSize() <= ComCfg::AggregationSize); 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()); return (remaining <= value.get_data().getSize());
} }
bool ComAggregator ::Svc_AggregationMachine_guard_isNotEmpty(SmId smId, Svc_AggregationMachine::Signal signal) const { 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, bool ComAggregator ::Svc_AggregationMachine_guard_isGood(SmId smId,

View File

@ -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) { 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++) { for (FwSizeType i = 0; i < buffer.getSize(); i++) {
ASSERT_EQ(buffer.getData()[i], this->component.m_frameBuffer.getData()[start + 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() { void ComAggregatorTester ::test_initial() {
// Initial state should have empty buffer // 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); ASSERT_EQ(this->component.m_bufferState, Fw::Buffer::OwnershipState::OWNED);
this->component.preamble(); this->component.preamble();
ASSERT_from_comStatusOut(0, Fw::Success::SUCCESS); ASSERT_from_comStatusOut(0, Fw::Success::SUCCESS);
@ -77,7 +77,7 @@ void ComAggregatorTester ::test_initial() {
//! Tests fill operation //! Tests fill operation
Fw::Buffer ComAggregatorTester ::test_fill(bool expect_hold) { Fw::Buffer ComAggregatorTester ::test_fill(bool expect_hold) {
// Precondition: initial has run // 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) { if (ORIGINAL_LENGTH == ComCfg::AggregationSize) {
// Nothing to fill // Nothing to fill
return Fw::Buffer(); return Fw::Buffer();
@ -90,9 +90,9 @@ Fw::Buffer ComAggregatorTester ::test_fill(bool expect_hold) {
EXPECT_EQ(this->dispatchOne(this->component), EXPECT_EQ(this->dispatchOne(this->component),
Svc::ComAggregatorComponentBase::MsgDispatchStatus::MSG_DISPATCH_OK); // Dispatch the state machine Svc::ComAggregatorComponentBase::MsgDispatchStatus::MSG_DISPATCH_OK); // Dispatch the state machine
if (expect_hold) { if (expect_hold) {
EXPECT_EQ(ORIGINAL_LENGTH, this->component.m_frameSerializer.getBuffLength()); EXPECT_EQ(ORIGINAL_LENGTH, this->component.m_frameSerializer.getSize());
} else { } 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->validate_buffer_aggregated(buffer, context);
} }
this->clearHistory(); this->clearHistory();
@ -110,7 +110,7 @@ void ComAggregatorTester ::test_fill_multi() {
void ComAggregatorTester ::test_full() { void ComAggregatorTester ::test_full() {
// Precondition: fill has run // Precondition: fill has run
// Chose a buffer that will be too large to fit but still will fit after being aggregated // 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<U32>(ComCfg::AggregationSize - ORIGINAL_LENGTH + 1), const U32 BUFFER_LENGTH = STest::Pick::lowerUpper(static_cast<U32>(ComCfg::AggregationSize - ORIGINAL_LENGTH + 1),
static_cast<U32>(ComCfg::AggregationSize)); static_cast<U32>(ComCfg::AggregationSize));
Fw::Buffer buffer = fill_buffer(BUFFER_LENGTH); Fw::Buffer buffer = fill_buffer(BUFFER_LENGTH);

View File

@ -87,7 +87,7 @@ void ComLogger ::comIn_handler(FwIndexType portNum, Fw::ComBuffer& data, U32 con
FW_ASSERT(portNum == 0); FW_ASSERT(portNum == 0);
// Get length of buffer: // Get length of buffer:
FwSizeType sizeNative = data.getBuffLength(); FwSizeType sizeNative = data.getSize();
// ComLogger only writes 16-bit sizes to save space // ComLogger only writes 16-bit sizes to save space
// on disk: // on disk:
FW_ASSERT(sizeNative < 65536, static_cast<FwAssertArgType>(sizeNative)); FW_ASSERT(sizeNative < 65536, static_cast<FwAssertArgType>(sizeNative));
@ -182,8 +182,8 @@ void ComLogger ::writeComBufferToFile(Fw::ComBuffer& data, U16 size) {
U8 buffer[sizeof(size)]; U8 buffer[sizeof(size)];
Fw::SerialBuffer serialLength(&buffer[0], sizeof(size)); Fw::SerialBuffer serialLength(&buffer[0], sizeof(size));
serialLength.serializeFrom(size); serialLength.serializeFrom(size);
if (this->writeToFile(serialLength.getBuffAddr(), static_cast<U16>(serialLength.getBuffLength()))) { if (this->writeToFile(serialLength.getBuffAddr(), static_cast<U16>(serialLength.getSize()))) {
this->m_byteCount += static_cast<U32>(serialLength.getBuffLength()); this->m_byteCount += static_cast<U32>(serialLength.getSize());
} else { } else {
return; return;
} }

Some files were not shown because too many files have changed in this diff Show More