renamed new class, small tweak

This commit is contained in:
Robin Müller 2022-06-13 16:20:37 +02:00
parent d74bcbb1f8
commit 15d69e64f3
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 12 additions and 16 deletions

View File

@ -1,4 +1,4 @@
target_sources(
${LIB_FSFW_NAME}
PRIVATE TcPacketPusBase.cpp TcPacketPus.cpp TcPacketStoredBase.cpp
TcPacketStoredPus.cpp TcPacketPusIntoBuf.cpp)
TcPacketStoredPus.cpp TcPacketSerializer.cpp)

View File

@ -1,11 +1,11 @@
#include "TcPacketPusIntoBuf.h"
#include "TcPacketSerializer.h"
#include <cstring>
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;
}

View File

@ -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();