Refactor TMTC Stack, improve test framework #655
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user