diff --git a/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt b/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt index 161c308b..ad413c02 100644 --- a/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt @@ -1,4 +1,4 @@ target_sources( ${LIB_FSFW_NAME} PRIVATE TcPacketPusBase.cpp TcPacketPus.cpp TcPacketStoredBase.cpp - TcPacketStoredPus.cpp TcPacketPusIntoBuf.cpp) + TcPacketStoredPus.cpp TcPacketSerializer.cpp) diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusIntoBuf.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.cpp similarity index 65% rename from src/fsfw/tmtcpacket/pus/tc/TcPacketPusIntoBuf.cpp rename to src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.cpp index 6ef46f48..28e8271f 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusIntoBuf.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.cpp @@ -1,11 +1,11 @@ -#include "TcPacketPusIntoBuf.h" +#include "TcPacketSerializer.h" #include -TcPacketPusIntoBuf::TcPacketPusIntoBuf(uint8_t* store, size_t maxSize, PusConfig& cfg) +TcPacketSerializer::TcPacketSerializer(uint8_t* store, size_t maxSize, PusConfig& cfg) : TcPacketPus(nullptr), store(store), maxSize(maxSize), cfg(cfg) {} -ReturnValue_t TcPacketPusIntoBuf::serialize(uint8_t** buffer, size_t* size, size_t maxSize, +ReturnValue_t TcPacketSerializer::serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { if (*size + getSerializedSize() > maxSize) { return BUFFER_TOO_SHORT; @@ -16,9 +16,9 @@ ReturnValue_t TcPacketPusIntoBuf::serialize(uint8_t** buffer, size_t* size, size return RETURN_OK; } -size_t TcPacketPusIntoBuf::getSerializedSize() const { return TC_PACKET_MIN_SIZE + cfg.appDataLen; } +size_t TcPacketSerializer::getSerializedSize() const { return TC_PACKET_MIN_SIZE + cfg.appDataLen; } -ReturnValue_t TcPacketPusIntoBuf::initialize() { +ReturnValue_t TcPacketSerializer::initialize() { if (getSerializedSize() > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } @@ -26,13 +26,8 @@ ReturnValue_t TcPacketPusIntoBuf::initialize() { if (result != RETURN_OK) { return result; } -#if FSFW_USE_PUS_C_TELECOMMANDS == 1 - pus::PusVersion pusVersion = pus::PusVersion::PUS_C_VERSION; -#else - pus::PusVersion pusVersion = pus::PusVersion::PUS_A_VERSION; -#endif - initializeTcPacket(cfg.apid, cfg.sequenceCount, cfg.ack, cfg.service, cfg.subservice, pusVersion, - cfg.sourceId); + initializeTcPacket(cfg.apid, cfg.sequenceCount, cfg.ack, cfg.service, cfg.subservice, + cfg.pusVersion, cfg.sourceId); if (cfg.appData != nullptr and cfg.appDataLen > 0) { std::memcpy(&tcData->appData, cfg.appData, cfg.appDataLen); } @@ -41,7 +36,7 @@ ReturnValue_t TcPacketPusIntoBuf::initialize() { return RETURN_OK; } -ReturnValue_t TcPacketPusIntoBuf::deSerialize(const uint8_t** buffer, size_t* size, +ReturnValue_t TcPacketSerializer::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { return RETURN_FAILED; } diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusIntoBuf.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.h similarity index 83% rename from src/fsfw/tmtcpacket/pus/tc/TcPacketPusIntoBuf.h rename to src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.h index 92b98d12..dcc5ef1f 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusIntoBuf.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.h @@ -14,12 +14,13 @@ struct PusConfig { uint16_t sourceId = 0; uint8_t* appData = nullptr; size_t appDataLen = 0; + pus::PusVersion pusVersion = pus::PusVersion::PUS_C_VERSION; uint8_t ack = TcPacketPus::ACK_ALL; }; -class TcPacketPusIntoBuf : public TcPacketPus, public SerializeIF, public HasReturnvaluesIF { +class TcPacketSerializer : public TcPacketPus, public SerializeIF, public HasReturnvaluesIF { public: - TcPacketPusIntoBuf(uint8_t* data, size_t size, PusConfig& cfg); + TcPacketSerializer(uint8_t* data, size_t size, PusConfig& cfg); ReturnValue_t initialize();