diff --git a/src/fsfw/datapool/PoolDataSetBase.cpp b/src/fsfw/datapool/PoolDataSetBase.cpp index 0462d761..9e941c5c 100644 --- a/src/fsfw/datapool/PoolDataSetBase.cpp +++ b/src/fsfw/datapool/PoolDataSetBase.cpp @@ -9,9 +9,9 @@ PoolDataSetBase::PoolDataSetBase(PoolVariableIF** registeredVariablesArray, const size_t maxFillCount, bool serializeWithValidityBlob) - : registeredVariables(registeredVariablesArray), - maxFillCount(maxFillCount), - serializeWithValidityBlob(serializeWithValidityBlob) {} + : serializeWithValidityBlob(serializeWithValidityBlob), + registeredVariables(registeredVariablesArray), + maxFillCount(maxFillCount) {} PoolDataSetBase::~PoolDataSetBase() = default; diff --git a/src/fsfw/datapool/PoolDataSetBase.h b/src/fsfw/datapool/PoolDataSetBase.h index 85e66ec3..dba3c98b 100644 --- a/src/fsfw/datapool/PoolDataSetBase.h +++ b/src/fsfw/datapool/PoolDataSetBase.h @@ -139,6 +139,8 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF { */ void setChildrenValidity(bool valid); + bool serializeWithValidityBlob = false; + protected: /** * @brief The fill_count attribute ensures that the variables @@ -166,7 +168,6 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF { */ PoolVariableIF** registeredVariables = nullptr; const size_t maxFillCount = 0; - bool serializeWithValidityBlob = false; void setContainer(PoolVariableIF** variablesContainer); PoolVariableIF** getContainer() const; diff --git a/src/fsfw/datapool/SharedSet.cpp b/src/fsfw/datapool/SharedSet.cpp index 6c661be2..96d10d4c 100644 --- a/src/fsfw/datapool/SharedSet.cpp +++ b/src/fsfw/datapool/SharedSet.cpp @@ -3,7 +3,7 @@ using namespace dp; SharedSet::SharedSet(dp::SharedPool& sharedPool, uint32_t setId, const size_t maxNumberOfVariables, - bool serializeWithValídityBlob) + bool serializeWithValidityBlob) : SharedSetBase(sharedPool, setId, nullptr, maxNumberOfVariables, serializeWithValidityBlob), poolVarList(maxNumberOfVariables) { this->setContainer(poolVarList.data()); diff --git a/src/fsfw/datapool/SharedSetBase.cpp b/src/fsfw/datapool/SharedSetBase.cpp index 5900861c..a7a158ba 100644 --- a/src/fsfw/datapool/SharedSetBase.cpp +++ b/src/fsfw/datapool/SharedSetBase.cpp @@ -105,9 +105,6 @@ ReturnValue_t SharedSetBase::deSerialize(const uint8_t **buffer, size_t *size, ReturnValue_t SharedSetBase::serialize(uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { - if (serializeWithValidityBlob) { - return base.doSerializeWithValidityBlob(buffer, size, maxSize, streamEndianness); - } return base.serialize(buffer, size, maxSize, streamEndianness); } @@ -165,3 +162,8 @@ void SharedSetBase::setContainer(PoolVariableIF **variablesContainer) { return base.setContainer(variablesContainer); } PoolVariableIF **SharedSetBase::getContainer() const { return base.getContainer(); } + +void SharedSetBase::updateValidityBlobSerialization(bool enable) { + base.serializeWithValidityBlob = enable; +} +bool SharedSetBase::getValidityBlobSerialization() const { return base.serializeWithValidityBlob; } diff --git a/src/fsfw/datapool/SharedSetBase.h b/src/fsfw/datapool/SharedSetBase.h index 34dc3dd6..4eb87b11 100644 --- a/src/fsfw/datapool/SharedSetBase.h +++ b/src/fsfw/datapool/SharedSetBase.h @@ -159,11 +159,8 @@ class SharedSetBase : public SerializeIF, public PoolDataSetIF { */ void setChildrenValidity(bool valid); - /** - * If the valid state of a dataset is always relevant to the whole - * data set we can use this flag. - */ - bool serializeWithValidityBlob = false; + void updateValidityBlobSerialization(bool enable); + bool getValidityBlobSerialization() const; protected: PoolDataSetBase base; diff --git a/unittests/datapool/testDataset.cpp b/unittests/datapool/testDataset.cpp index 67af121b..0d2c048c 100644 --- a/unittests/datapool/testDataset.cpp +++ b/unittests/datapool/testDataset.cpp @@ -62,6 +62,7 @@ TEST_CASE("Pool Dataset Test", "[datapool]") { size_t serLen = 0; uint8_t* dataPtr = buf; dataset.serializeWithValidityBlob = true; + CHECK(dataset.getSerializedSize() == 6); CHECK(dataset.serialize(&dataPtr, &serLen, sizeof(buf), SerializeIF::Endianness::NETWORK) == returnvalue::OK); CHECK(buf[5] == 0b11000000); @@ -70,7 +71,7 @@ TEST_CASE("Pool Dataset Test", "[datapool]") { SECTION("Larger Pool Dataset Serialization With Validity") { uint8_t buf[64]{}; TestDatasetLarger datasetLarge; - datasetLarge.setAllChildrenValidity(true); + datasetLarge.setChildrenValidity(true); size_t serLen = 0; uint8_t* dataPtr = buf; datasetLarge.serializeWithValidityBlob = true; diff --git a/unittests/datapool/testSharedSet.cpp b/unittests/datapool/testSharedSet.cpp index 2a3cee5b..68b972b2 100644 --- a/unittests/datapool/testSharedSet.cpp +++ b/unittests/datapool/testSharedSet.cpp @@ -23,6 +23,7 @@ TEST_CASE("DataSetTest", "[datapool]") { SECTION("BasicTest") { /* Test some basic functions */ CHECK(localSet.getReportingEnabled() == false); + CHECK(localSet.getSerializedSize() == 11); CHECK(localSet.getLocalPoolIdsSerializedSize() == 3 * sizeof(dp::id_t)); CHECK(localSet.getStructureId() == lpool::testSid1); CHECK(localSet.getCreatorObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE); @@ -156,7 +157,7 @@ TEST_CASE("DataSetTest", "[datapool]") { } SECTION("Serialize with Validity Blob") { - localSet.serializeWithValidityBlob = true; + localSet.updateValidityBlobSerialization(true); CHECK(!localSet.localPoolVarUint8.isValid()); CHECK(!localSet.localPoolUint16Vec.isValid()); CHECK(!localSet.localPoolVarFloat.isValid()); @@ -168,6 +169,7 @@ TEST_CASE("DataSetTest", "[datapool]") { // Already reserve additional space for validity buffer, will be needed later uint8_t buffer[128]{}; uint8_t* buffPtr = buffer; + CHECK(localSet.getSerializedSize() == 12); CHECK(localSet.serialize(&buffPtr, &serSize, sizeof(buffer), SerializeIF::Endianness::MACHINE) == returnvalue::OK); CHECK(serSize == 12);