improvements for creator API

This commit is contained in:
Robin Müller 2022-07-27 21:11:12 +02:00
parent 85dbef20b0
commit 5bb7023ff3
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
5 changed files with 21 additions and 11 deletions

View File

@ -90,10 +90,6 @@ PusTcParams &PusTcCreator::getPusParams() { return pusParams; }
SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); }
ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize) {
return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK);
}
ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) {
// TODO: Check length field?
pusParams.dataWrapper.setRawData({data, len});
@ -107,3 +103,11 @@ ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF &serializable) {
updateSpLengthField();
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize) const {
return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK);
}
ReturnValue_t PusTcCreator::serialize(uint8_t *buffer, size_t maxSize) const {
return SerializeIF::serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK);
}

View File

@ -34,10 +34,10 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF
PusTcParams &getPusParams();
SpacePacketParams &getSpParams();
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize);
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const override;
ReturnValue_t serialize(uint8_t *buffer, size_t maxSize) const override;
[[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) override;
[[nodiscard]] uint16_t getPacketIdRaw() const override;
[[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override;
[[nodiscard]] uint16_t getPacketDataLen() const override;
@ -52,6 +52,9 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF
private:
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const override;
// Forbidden to use
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) override;
SpacePacketCreator spCreator;
PusTcParams pusParams;
};

View File

@ -78,13 +78,14 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
[[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
[[nodiscard]] TimeStamperIF* getTimestamper() const;
ReturnValue_t setRawUserData(const uint8_t* data, size_t len) override;
ReturnValue_t setSerializableUserData(SerializeIF& serializable) override;
private:
// Forbidden to use
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
void setup();
PusTmParams pusParams{};
bool calculateCrcOnSerialization = true;

View File

@ -95,9 +95,10 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") {
}
SECTION("Deserialization Fails") {
SerializeIF& deser = creator;
size_t deserLen = buf.size();
const uint8_t* roPtr = buf.data();
REQUIRE(creator.deSerialize(&roPtr, &deserLen, SerializeIF::Endianness::NETWORK) ==
REQUIRE(deser.deSerialize(&roPtr, &deserLen, SerializeIF::Endianness::NETWORK) ==
HasReturnvaluesIF::RETURN_FAILED);
}

View File

@ -97,8 +97,9 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") {
}
SECTION("Deserialization fails") {
SerializeIF& deser = creator;
const uint8_t* roDataPtr = nullptr;
REQUIRE(creator.deSerialize(&roDataPtr, &serLen, SerializeIF::Endianness::NETWORK) ==
REQUIRE(deser.deSerialize(&roDataPtr, &serLen, SerializeIF::Endianness::NETWORK) ==
HasReturnvaluesIF::RETURN_FAILED);
}