improvements for creator API
This commit is contained in:
parent
85dbef20b0
commit
5bb7023ff3
@ -90,10 +90,6 @@ PusTcParams &PusTcCreator::getPusParams() { return pusParams; }
|
|||||||
|
|
||||||
SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); }
|
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) {
|
ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) {
|
||||||
// TODO: Check length field?
|
// TODO: Check length field?
|
||||||
pusParams.dataWrapper.setRawData({data, len});
|
pusParams.dataWrapper.setRawData({data, len});
|
||||||
@ -107,3 +103,11 @@ ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF &serializable) {
|
|||||||
updateSpLengthField();
|
updateSpLengthField();
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
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();
|
PusTcParams &getPusParams();
|
||||||
SpacePacketParams &getSpParams();
|
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;
|
[[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 getPacketIdRaw() const override;
|
||||||
[[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override;
|
[[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override;
|
||||||
[[nodiscard]] uint16_t getPacketDataLen() const override;
|
[[nodiscard]] uint16_t getPacketDataLen() const override;
|
||||||
@ -52,6 +52,9 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF
|
|||||||
private:
|
private:
|
||||||
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||||
Endianness streamEndianness) const override;
|
Endianness streamEndianness) const override;
|
||||||
|
// Forbidden to use
|
||||||
|
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||||
|
Endianness streamEndianness) override;
|
||||||
SpacePacketCreator spCreator;
|
SpacePacketCreator spCreator;
|
||||||
PusTcParams pusParams;
|
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,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||||
Endianness streamEndianness) const override;
|
Endianness streamEndianness) const override;
|
||||||
[[nodiscard]] size_t getSerializedSize() 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;
|
[[nodiscard]] TimeStamperIF* getTimestamper() const;
|
||||||
ReturnValue_t setRawUserData(const uint8_t* data, size_t len) override;
|
ReturnValue_t setRawUserData(const uint8_t* data, size_t len) override;
|
||||||
ReturnValue_t setSerializableUserData(SerializeIF& serializable) override;
|
ReturnValue_t setSerializableUserData(SerializeIF& serializable) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Forbidden to use
|
||||||
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
|
Endianness streamEndianness) override;
|
||||||
void setup();
|
void setup();
|
||||||
PusTmParams pusParams{};
|
PusTmParams pusParams{};
|
||||||
bool calculateCrcOnSerialization = true;
|
bool calculateCrcOnSerialization = true;
|
||||||
|
@ -95,9 +95,10 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Deserialization Fails") {
|
SECTION("Deserialization Fails") {
|
||||||
|
SerializeIF& deser = creator;
|
||||||
size_t deserLen = buf.size();
|
size_t deserLen = buf.size();
|
||||||
const uint8_t* roPtr = buf.data();
|
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);
|
HasReturnvaluesIF::RETURN_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +97,9 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Deserialization fails") {
|
SECTION("Deserialization fails") {
|
||||||
|
SerializeIF& deser = creator;
|
||||||
const uint8_t* roDataPtr = nullptr;
|
const uint8_t* roDataPtr = nullptr;
|
||||||
REQUIRE(creator.deSerialize(&roDataPtr, &serLen, SerializeIF::Endianness::NETWORK) ==
|
REQUIRE(deser.deSerialize(&roDataPtr, &serLen, SerializeIF::Endianness::NETWORK) ==
|
||||||
HasReturnvaluesIF::RETURN_FAILED);
|
HasReturnvaluesIF::RETURN_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user