better names

This commit is contained in:
Robin Müller 2022-08-03 16:00:48 +02:00
parent 7fb9e14555
commit acf5c2a56d
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
47 changed files with 178 additions and 185 deletions

View File

@ -1,14 +1,14 @@
#include "AckPduDeserializer.h" #include "AckPduDeserializer.h"
AckPduDeserializer::AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, AckInfo& info) AckPduDeserializer::AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, AckInfo& info)
: FileDirectiveDeserializer(pduBuf, maxSize), info(info) {} : FileDirectiveReader(pduBuf, maxSize), info(info) {}
ReturnValue_t AckPduDeserializer::parseData() { ReturnValue_t AckPduDeserializer::parseData() {
ReturnValue_t result = FileDirectiveDeserializer::parseData(); ReturnValue_t result = FileDirectiveReader::parseData();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); size_t currentIdx = FileDirectiveReader::getHeaderSize();
if (currentIdx + 2 > this->maxSize) { if (currentIdx + 2 > this->maxSize) {
return SerializeIF::BUFFER_TOO_SHORT; return SerializeIF::BUFFER_TOO_SHORT;
} }

View File

@ -2,9 +2,9 @@
#define FSFW_SRC_FSFW_CFDP_PDU_ACKPDUDESERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_ACKPDUDESERIALIZER_H_
#include "AckInfo.h" #include "AckInfo.h"
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h"
class AckPduDeserializer : public FileDirectiveDeserializer { class AckPduDeserializer : public FileDirectiveReader {
public: public:
AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, AckInfo& info); AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, AckInfo& info);

View File

@ -1,16 +1,15 @@
#include "AckPduSerializer.h" #include "AckPduSerializer.h"
AckPduSerializer::AckPduSerializer(AckInfo &ackInfo, PduConfig &pduConf) AckPduSerializer::AckPduSerializer(AckInfo &ackInfo, PduConfig &pduConf)
: FileDirectiveSerializer(pduConf, cfdp::FileDirectives::ACK, 2), ackInfo(ackInfo) {} : FileDirectiveCreator(pduConf, cfdp::FileDirectives::ACK, 2), ackInfo(ackInfo) {}
size_t AckPduSerializer::getSerializedSize() const { size_t AckPduSerializer::getSerializedSize() const {
return FileDirectiveSerializer::getWholePduSize(); return FileDirectiveCreator::getWholePduSize();
} }
ReturnValue_t AckPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t AckPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
ReturnValue_t result = ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }

View File

@ -2,10 +2,10 @@
#define FSFW_SRC_FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_
#include "AckInfo.h" #include "AckInfo.h"
#include "FileDirectiveDeserializer.h" #include "FileDirectiveCreator.h"
#include "FileDirectiveSerializer.h" #include "FileDirectiveReader.h"
class AckPduSerializer : public FileDirectiveSerializer { class AckPduSerializer : public FileDirectiveCreator {
public: public:
/** /**
* @brief Serializer to pack ACK PDUs * @brief Serializer to pack ACK PDUs

View File

@ -4,8 +4,8 @@ target_sources(
VarLenField.cpp VarLenField.cpp
HeaderCreator.cpp HeaderCreator.cpp
HeaderReader.cpp HeaderReader.cpp
FileDirectiveDeserializer.cpp FileDirectiveReader.cpp
FileDirectiveSerializer.cpp FileDirectiveCreator.cpp
AckInfo.cpp AckInfo.cpp
AckPduSerializer.cpp AckPduSerializer.cpp
AckPduDeserializer.cpp AckPduDeserializer.cpp
@ -25,6 +25,6 @@ target_sources(
KeepAlivePduDeserializer.cpp KeepAlivePduDeserializer.cpp
PromptPduSerializer.cpp PromptPduSerializer.cpp
PromptPduDeserializer.cpp PromptPduDeserializer.cpp
FileDataSerializer.cpp FileDataCreator.cpp
FileDataDeserializer.cpp FileDataReader.cpp
FileDataInfo.cpp) FileDataInfo.cpp)

View File

@ -4,10 +4,10 @@
#include "fsfw/serviceinterface.h" #include "fsfw/serviceinterface.h"
EofPduDeserializer::EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo) EofPduDeserializer::EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo)
: FileDirectiveDeserializer(pduBuf, maxSize), info(eofInfo) {} : FileDirectiveReader(pduBuf, maxSize), info(eofInfo) {}
ReturnValue_t EofPduDeserializer::parseData() { ReturnValue_t EofPduDeserializer::parseData() {
ReturnValue_t result = FileDirectiveDeserializer::parseData(); ReturnValue_t result = FileDirectiveReader::parseData();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
@ -17,7 +17,7 @@ ReturnValue_t EofPduDeserializer::parseData() {
if (this->getLargeFileFlag()) { if (this->getLargeFileFlag()) {
expectedFileFieldLen = 8; expectedFileFieldLen = 8;
} }
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); size_t currentIdx = FileDirectiveReader::getHeaderSize();
size_t deserLen = maxSize; size_t deserLen = maxSize;
if (maxSize < currentIdx + 5 + expectedFileFieldLen) { if (maxSize < currentIdx + 5 + expectedFileFieldLen) {
return SerializeIF::STREAM_TOO_SHORT; return SerializeIF::STREAM_TOO_SHORT;

View File

@ -2,9 +2,9 @@
#define FSFW_SRC_FSFW_CFDP_PDU_EOFPDUDESERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_EOFPDUDESERIALIZER_H_
#include "EofInfo.h" #include "EofInfo.h"
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h"
class EofPduDeserializer : public FileDirectiveDeserializer { class EofPduDeserializer : public FileDirectiveReader {
public: public:
EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo); EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo);

View File

@ -4,18 +4,17 @@
#include "fsfw/serviceinterface.h" #include "fsfw/serviceinterface.h"
EofPduSerializer::EofPduSerializer(PduConfig &conf, EofInfo &info) EofPduSerializer::EofPduSerializer(PduConfig &conf, EofInfo &info)
: FileDirectiveSerializer(conf, cfdp::FileDirectives::EOF_DIRECTIVE, 9), info(info) { : FileDirectiveCreator(conf, cfdp::FileDirectives::EOF_DIRECTIVE, 9), info(info) {
setDirectiveDataFieldLen(info.getSerializedSize(getLargeFileFlag())); setDirectiveDataFieldLen(info.getSerializedSize(getLargeFileFlag()));
} }
size_t EofPduSerializer::getSerializedSize() const { size_t EofPduSerializer::getSerializedSize() const {
return FileDirectiveSerializer::getWholePduSize(); return FileDirectiveCreator::getWholePduSize();
} }
ReturnValue_t EofPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t EofPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
ReturnValue_t result = ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }

View File

@ -2,10 +2,10 @@
#define FSFW_SRC_FSFW_CFDP_PDU_EOFPDUSERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_EOFPDUSERIALIZER_H_
#include "EofInfo.h" #include "EofInfo.h"
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" #include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
#include "fsfw/cfdp/tlv/EntityIdTlv.h" #include "fsfw/cfdp/tlv/EntityIdTlv.h"
class EofPduSerializer : public FileDirectiveSerializer { class EofPduSerializer : public FileDirectiveCreator {
public: public:
EofPduSerializer(PduConfig& conf, EofInfo& info); EofPduSerializer(PduConfig& conf, EofInfo& info);

View File

@ -1,20 +1,20 @@
#include "FileDataSerializer.h" #include "FileDataCreator.h"
#include <cstring> #include <cstring>
FileDataSerializer::FileDataSerializer(PduConfig& conf, FileDataInfo& info) FileDataCreator::FileDataCreator(PduConfig& conf, FileDataInfo& info)
: HeaderCreator(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) { : HeaderCreator(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) {
update(); update();
} }
void FileDataSerializer::update() { void FileDataCreator::update() {
this->setSegmentMetadataFlag(info.getSegmentMetadataFlag()); this->setSegmentMetadataFlag(info.getSegmentMetadataFlag());
this->setSegmentationControl(info.getSegmentationControl()); this->setSegmentationControl(info.getSegmentationControl());
setPduDataFieldLen(info.getSerializedSize(this->getLargeFileFlag())); setPduDataFieldLen(info.getSerializedSize(this->getLargeFileFlag()));
} }
ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size_t maxSize, ReturnValue_t FileDataCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness); ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -49,6 +49,6 @@ ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
size_t FileDataSerializer::getSerializedSize() const { size_t FileDataCreator::getSerializedSize() const {
return HeaderCreator::getSerializedSize() + info.getSerializedSize(this->getLargeFileFlag()); return HeaderCreator::getSerializedSize() + info.getSerializedSize(this->getLargeFileFlag());
} }

View File

@ -0,0 +1,23 @@
#ifndef FSFW_CFDP_PDU_FILEDATASERIALIZER_H_
#define FSFW_CFDP_PDU_FILEDATASERIALIZER_H_
#include "../definitions.h"
#include "FileDataInfo.h"
#include "HeaderCreator.h"
class FileDataCreator : public HeaderCreator {
public:
FileDataCreator(PduConfig& conf, FileDataInfo& info);
void update();
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
[[nodiscard]] size_t getSerializedSize() const override;
private:
FileDataInfo& info;
};
#endif /* FSFW_CFDP_PDU_FILEDATASERIALIZER_H_ */

View File

@ -1,10 +1,9 @@
#include "FileDataDeserializer.h" #include "FileDataReader.h"
FileDataDeserializer::FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize, FileDataReader::FileDataReader(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info)
FileDataInfo& info)
: HeaderReader(pduBuf, maxSize), info(info) {} : HeaderReader(pduBuf, maxSize), info(info) {}
ReturnValue_t FileDataDeserializer::parseData() { ReturnValue_t FileDataReader::parseData() {
ReturnValue_t result = HeaderReader::parseData(); ReturnValue_t result = HeaderReader::parseData();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -41,8 +40,8 @@ ReturnValue_t FileDataDeserializer::parseData() {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
SerializeIF::Endianness FileDataDeserializer::getEndianness() const { return endianness; } SerializeIF::Endianness FileDataReader::getEndianness() const { return endianness; }
void FileDataDeserializer::setEndianness(SerializeIF::Endianness endianness) { void FileDataReader::setEndianness(SerializeIF::Endianness endianness_) {
this->endianness = endianness; endianness = endianness_;
} }

View File

@ -5,12 +5,12 @@
#include "FileDataInfo.h" #include "FileDataInfo.h"
#include "HeaderReader.h" #include "HeaderReader.h"
class FileDataDeserializer : public HeaderReader { class FileDataReader : public HeaderReader {
public: public:
FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info); FileDataReader(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info);
ReturnValue_t parseData(); ReturnValue_t parseData() override;
SerializeIF::Endianness getEndianness() const; [[nodiscard]] SerializeIF::Endianness getEndianness() const;
void setEndianness(SerializeIF::Endianness endianness = SerializeIF::Endianness::NETWORK); void setEndianness(SerializeIF::Endianness endianness = SerializeIF::Endianness::NETWORK);
private: private:

View File

@ -1,23 +0,0 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_FILEDATASERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_FILEDATASERIALIZER_H_
#include "../definitions.h"
#include "FileDataInfo.h"
#include "HeaderCreator.h"
class FileDataSerializer : public HeaderCreator {
public:
FileDataSerializer(PduConfig& conf, FileDataInfo& info);
void update();
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
size_t getSerializedSize() const override;
private:
FileDataInfo& info;
};
#endif /* FSFW_SRC_FSFW_CFDP_PDU_FILEDATADESERIALIZER_H_ */

View File

@ -1,21 +1,20 @@
#include "FileDirectiveSerializer.h" #include "FileDirectiveCreator.h"
FileDirectiveSerializer::FileDirectiveSerializer(PduConfig &pduConf, FileDirectiveCreator::FileDirectiveCreator(PduConfig &pduConf, cfdp::FileDirectives directiveCode,
cfdp::FileDirectives directiveCode, size_t directiveParamFieldLen)
size_t directiveParamFieldLen)
: HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, directiveParamFieldLen + 1), : HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, directiveParamFieldLen + 1),
directiveCode(directiveCode) {} directiveCode(directiveCode) {}
size_t FileDirectiveSerializer::getSerializedSize() const { size_t FileDirectiveCreator::getSerializedSize() const {
return HeaderCreator::getSerializedSize() + 1; return HeaderCreator::getSerializedSize() + 1;
} }
ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
if (buffer == nullptr or size == nullptr) { if (buffer == nullptr or size == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
if (FileDirectiveSerializer::getWholePduSize() > maxSize) { if (FileDirectiveCreator::getWholePduSize() > maxSize) {
return BUFFER_TOO_SHORT; return BUFFER_TOO_SHORT;
} }
ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness); ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness);
@ -32,7 +31,7 @@ ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
void FileDirectiveSerializer::setDirectiveDataFieldLen(size_t len) { void FileDirectiveCreator::setDirectiveDataFieldLen(size_t len) {
// Set length of data field plus 1 byte for the directive octet // Set length of data field plus 1 byte for the directive octet
HeaderCreator::setPduDataFieldLen(len + 1); HeaderCreator::setPduDataFieldLen(len + 1);
} }

View File

@ -3,18 +3,18 @@
#include "fsfw/cfdp/pdu/HeaderCreator.h" #include "fsfw/cfdp/pdu/HeaderCreator.h"
class FileDirectiveSerializer : public HeaderCreator { class FileDirectiveCreator : public HeaderCreator {
public: public:
FileDirectiveSerializer(PduConfig& pduConf, cfdp::FileDirectives directiveCode, FileDirectiveCreator(PduConfig& pduConf, cfdp::FileDirectives directiveCode,
size_t directiveParamFieldLen); size_t directiveParamFieldLen);
/** /**
* This only returns the size of the PDU header + 1 for the directive code octet. * This only returns the size of the PDU header + 1 for the directive code octet.
* Use FileDirectiveSerializer::getWholePduSize to get the full packet length, assuming * Use FileDirectiveCreator::getWholePduSize to get the full packet length, assuming
* the length fields was set correctly * the length fields was set correctly
* @return * @return
*/ */
size_t getSerializedSize() const override; [[nodiscard]] size_t getSerializedSize() const override;
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;

View File

@ -1,11 +1,11 @@
#include "FileDirectiveDeserializer.h" #include "FileDirectiveReader.h"
FileDirectiveDeserializer::FileDirectiveDeserializer(const uint8_t *pduBuf, size_t maxSize) FileDirectiveReader::FileDirectiveReader(const uint8_t *pduBuf, size_t maxSize)
: HeaderReader(pduBuf, maxSize) {} : HeaderReader(pduBuf, maxSize) {}
cfdp::FileDirectives FileDirectiveDeserializer::getFileDirective() const { return fileDirective; } cfdp::FileDirectives FileDirectiveReader::getFileDirective() const { return fileDirective; }
ReturnValue_t FileDirectiveDeserializer::parseData() { ReturnValue_t FileDirectiveReader::parseData() {
ReturnValue_t result = HeaderReader::parseData(); ReturnValue_t result = HeaderReader::parseData();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -13,7 +13,7 @@ ReturnValue_t FileDirectiveDeserializer::parseData() {
if (this->getPduDataFieldLen() < 1) { if (this->getPduDataFieldLen() < 1) {
return cfdp::INVALID_PDU_DATAFIELD_LEN; return cfdp::INVALID_PDU_DATAFIELD_LEN;
} }
if (FileDirectiveDeserializer::getWholePduSize() > maxSize) { if (FileDirectiveReader::getWholePduSize() > maxSize) {
return SerializeIF::STREAM_TOO_SHORT; return SerializeIF::STREAM_TOO_SHORT;
} }
size_t currentIdx = HeaderReader::getHeaderSize(); size_t currentIdx = HeaderReader::getHeaderSize();
@ -24,12 +24,12 @@ ReturnValue_t FileDirectiveDeserializer::parseData() {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
size_t FileDirectiveDeserializer::getHeaderSize() const { size_t FileDirectiveReader::getHeaderSize() const {
// return size of header plus the directive byte // return size of header plus the directive byte
return HeaderReader::getHeaderSize() + 1; return HeaderReader::getHeaderSize() + 1;
} }
bool FileDirectiveDeserializer::checkFileDirective(uint8_t rawByte) { bool FileDirectiveReader::checkFileDirective(uint8_t rawByte) {
if (rawByte < cfdp::FileDirectives::EOF_DIRECTIVE or if (rawByte < cfdp::FileDirectives::EOF_DIRECTIVE or
(rawByte > cfdp::FileDirectives::PROMPT and rawByte != cfdp::FileDirectives::KEEP_ALIVE)) { (rawByte > cfdp::FileDirectives::PROMPT and rawByte != cfdp::FileDirectives::KEEP_ALIVE)) {
// Invalid directive field. TODO: Custom returnvalue // Invalid directive field. TODO: Custom returnvalue
@ -38,12 +38,12 @@ bool FileDirectiveDeserializer::checkFileDirective(uint8_t rawByte) {
return true; return true;
} }
void FileDirectiveDeserializer::setFileDirective(cfdp::FileDirectives fileDirective) { void FileDirectiveReader::setFileDirective(cfdp::FileDirectives fileDirective_) {
this->fileDirective = fileDirective; fileDirective = fileDirective_;
} }
void FileDirectiveDeserializer::setEndianness(SerializeIF::Endianness endianness) { void FileDirectiveReader::setEndianness(SerializeIF::Endianness endianness_) {
this->endianness = endianness; endianness = endianness_;
} }
SerializeIF::Endianness FileDirectiveDeserializer::getEndianness() const { return endianness; } SerializeIF::Endianness FileDirectiveReader::getEndianness() const { return endianness; }

View File

@ -11,24 +11,24 @@
* This is a zero-copy implementation and #parseData needs to be called to ensure the data is * This is a zero-copy implementation and #parseData needs to be called to ensure the data is
* valid. * valid.
*/ */
class FileDirectiveDeserializer : public HeaderReader { class FileDirectiveReader : public HeaderReader {
public: public:
FileDirectiveDeserializer(const uint8_t* pduBuf, size_t maxSize); FileDirectiveReader(const uint8_t* pduBuf, size_t maxSize);
/** /**
* This needs to be called before accessing the PDU fields to avoid segmentation faults. * This needs to be called before accessing the PDU fields to avoid segmentation faults.
* @return * @return
*/ */
virtual ReturnValue_t parseData(); ReturnValue_t parseData() override;
size_t getHeaderSize() const; [[nodiscard]] size_t getHeaderSize() const override;
cfdp::FileDirectives getFileDirective() const; [[nodiscard]] cfdp::FileDirectives getFileDirective() const;
void setEndianness(SerializeIF::Endianness endianness); void setEndianness(SerializeIF::Endianness endianness);
SerializeIF::Endianness getEndianness() const; [[nodiscard]] SerializeIF::Endianness getEndianness() const;
protected: protected:
bool checkFileDirective(uint8_t rawByte); static bool checkFileDirective(uint8_t rawByte);
private: private:
void setFileDirective(cfdp::FileDirectives fileDirective); void setFileDirective(cfdp::FileDirectives fileDirective);

View File

@ -2,21 +2,21 @@
FinishPduDeserializer::FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSize, FinishPduDeserializer::FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSize,
FinishedInfo& info) FinishedInfo& info)
: FileDirectiveDeserializer(pduBuf, maxSize), finishedInfo(info) {} : FileDirectiveReader(pduBuf, maxSize), finishedInfo(info) {}
ReturnValue_t FinishPduDeserializer::parseData() { ReturnValue_t FinishPduDeserializer::parseData() {
ReturnValue_t result = FileDirectiveDeserializer::parseData(); ReturnValue_t result = FileDirectiveReader::parseData();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); size_t currentIdx = FileDirectiveReader::getHeaderSize();
const uint8_t* buf = rawPtr + currentIdx; const uint8_t* buf = rawPtr + currentIdx;
size_t remSize = FileDirectiveDeserializer::getWholePduSize() - currentIdx; size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx;
if (remSize < 1) { if (remSize < 1) {
return SerializeIF::STREAM_TOO_SHORT; return SerializeIF::STREAM_TOO_SHORT;
} }
uint8_t firstByte = *buf; uint8_t firstByte = *buf;
cfdp::ConditionCode condCode = static_cast<cfdp::ConditionCode>((firstByte >> 4) & 0x0f); auto condCode = static_cast<cfdp::ConditionCode>((firstByte >> 4) & 0x0f);
finishedInfo.setConditionCode(condCode); finishedInfo.setConditionCode(condCode);
finishedInfo.setDeliveryCode(static_cast<cfdp::FinishedDeliveryCode>(firstByte >> 2 & 0b1)); finishedInfo.setDeliveryCode(static_cast<cfdp::FinishedDeliveryCode>(firstByte >> 2 & 0b1));
finishedInfo.setFileStatus(static_cast<cfdp::FinishedFileStatus>(firstByte & 0b11)); finishedInfo.setFileStatus(static_cast<cfdp::FinishedFileStatus>(firstByte & 0b11));

View File

@ -1,10 +1,10 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ #ifndef FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h"
#include "fsfw/cfdp/pdu/FinishedInfo.h" #include "fsfw/cfdp/pdu/FinishedInfo.h"
class FinishPduDeserializer : public FileDirectiveDeserializer { class FinishPduDeserializer : public FileDirectiveReader {
public: public:
FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSize, FinishedInfo& info); FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSize, FinishedInfo& info);

View File

@ -1,7 +1,7 @@
#include "FinishedPduSerializer.h" #include "FinishedPduSerializer.h"
FinishPduSerializer::FinishPduSerializer(PduConfig &conf, FinishedInfo &finishInfo) FinishPduSerializer::FinishPduSerializer(PduConfig &conf, FinishedInfo &finishInfo)
: FileDirectiveSerializer(conf, cfdp::FileDirectives::FINISH, 0), finishInfo(finishInfo) { : FileDirectiveCreator(conf, cfdp::FileDirectives::FINISH, 0), finishInfo(finishInfo) {
updateDirectiveFieldLen(); updateDirectiveFieldLen();
} }
@ -15,8 +15,7 @@ void FinishPduSerializer::updateDirectiveFieldLen() {
ReturnValue_t FinishPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t FinishPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
ReturnValue_t result = ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }

View File

@ -2,10 +2,10 @@
#define FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_
#include "FinishedInfo.h" #include "FinishedInfo.h"
#include "fsfw/cfdp/pdu/FileDataSerializer.h" #include "fsfw/cfdp/pdu/FileDataCreator.h"
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" #include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
class FinishPduSerializer : public FileDirectiveSerializer { class FinishPduSerializer : public FileDirectiveCreator {
public: public:
FinishPduSerializer(PduConfig& pduConf, FinishedInfo& finishInfo); FinishPduSerializer(PduConfig& pduConf, FinishedInfo& finishInfo);

View File

@ -47,8 +47,7 @@ ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t ma
} }
size_t HeaderCreator::getSerializedSize() const { size_t HeaderCreator::getSerializedSize() const {
size_t shit = pduConf.seqNum.getWidth() + pduConf.sourceId.getWidth() * 2 + 4; return pduConf.seqNum.getWidth() + pduConf.sourceId.getWidth() * 2 + 4;
return shit;
} }
ReturnValue_t HeaderCreator::deSerialize(const uint8_t **buffer, size_t *size, ReturnValue_t HeaderCreator::deSerialize(const uint8_t **buffer, size_t *size,

View File

@ -38,11 +38,12 @@ size_t HeaderReader::getHeaderSize() const {
} }
size_t HeaderReader::getPduDataFieldLen() const { size_t HeaderReader::getPduDataFieldLen() const {
uint16_t pduFiedlLen = (fixedHeader->pduDataFieldLenH << 8) | fixedHeader->pduDataFieldLenL; return (fixedHeader->pduDataFieldLenH << 8) | fixedHeader->pduDataFieldLenL;
return pduFiedlLen;
} }
size_t HeaderReader::getWholePduSize() const { return getPduDataFieldLen() + getHeaderSize(); } size_t HeaderReader::getWholePduSize() const {
return getPduDataFieldLen() + HeaderReader::getHeaderSize();
}
cfdp::PduType HeaderReader::getPduType() const { cfdp::PduType HeaderReader::getPduType() const {
return static_cast<cfdp::PduType>((fixedHeader->firstByte >> 4) & 0x01); return static_cast<cfdp::PduType>((fixedHeader->firstByte >> 4) & 0x01);

View File

@ -41,7 +41,7 @@ class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF {
* - SerializeIF::BUFFER_TOO_SHORT if buffer is shorter than expected * - SerializeIF::BUFFER_TOO_SHORT if buffer is shorter than expected
*/ */
virtual ReturnValue_t parseData(); virtual ReturnValue_t parseData();
[[nodiscard]] size_t getHeaderSize() const; [[nodiscard]] virtual size_t getHeaderSize() const;
[[nodiscard]] size_t getPduDataFieldLen() const override; [[nodiscard]] size_t getPduDataFieldLen() const override;
[[nodiscard]] size_t getWholePduSize() const override; [[nodiscard]] size_t getWholePduSize() const override;

View File

@ -2,15 +2,15 @@
KeepAlivePduDeserializer::KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t maxSize, KeepAlivePduDeserializer::KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t maxSize,
cfdp::FileSize& progress) cfdp::FileSize& progress)
: FileDirectiveDeserializer(pduBuf, maxSize), progress(progress) {} : FileDirectiveReader(pduBuf, maxSize), progress(progress) {}
ReturnValue_t KeepAlivePduDeserializer::parseData() { ReturnValue_t KeepAlivePduDeserializer::parseData() {
ReturnValue_t result = FileDirectiveDeserializer::parseData(); ReturnValue_t result = FileDirectiveReader::parseData();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); size_t currentIdx = FileDirectiveReader::getHeaderSize();
size_t remLen = FileDirectiveDeserializer::getWholePduSize() - currentIdx; size_t remLen = FileDirectiveReader::getWholePduSize() - currentIdx;
const uint8_t* buffer = rawPtr + currentIdx; const uint8_t* buffer = rawPtr + currentIdx;
return progress.deSerialize(&buffer, &remLen, getEndianness()); return progress.deSerialize(&buffer, &remLen, getEndianness());
} }

View File

@ -2,9 +2,9 @@
#define FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUDESERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUDESERIALIZER_H_
#include "fsfw/cfdp/FileSize.h" #include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h"
class KeepAlivePduDeserializer : public FileDirectiveDeserializer { class KeepAlivePduDeserializer : public FileDirectiveReader {
public: public:
KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t maxSize, cfdp::FileSize& progress); KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t maxSize, cfdp::FileSize& progress);

View File

@ -1,12 +1,12 @@
#include "KeepAlivePduSerializer.h" #include "KeepAlivePduSerializer.h"
KeepAlivePduSerializer::KeepAlivePduSerializer(PduConfig &conf, cfdp::FileSize &progress) KeepAlivePduSerializer::KeepAlivePduSerializer(PduConfig &conf, cfdp::FileSize &progress)
: FileDirectiveSerializer(conf, cfdp::FileDirectives::KEEP_ALIVE, 4), progress(progress) { : FileDirectiveCreator(conf, cfdp::FileDirectives::KEEP_ALIVE, 4), progress(progress) {
updateDirectiveFieldLen(); updateDirectiveFieldLen();
} }
size_t KeepAlivePduSerializer::getSerializedSize() const { size_t KeepAlivePduSerializer::getSerializedSize() const {
return FileDirectiveSerializer::getWholePduSize(); return FileDirectiveCreator::getWholePduSize();
} }
void KeepAlivePduSerializer::updateDirectiveFieldLen() { void KeepAlivePduSerializer::updateDirectiveFieldLen() {
@ -17,8 +17,7 @@ void KeepAlivePduSerializer::updateDirectiveFieldLen() {
ReturnValue_t KeepAlivePduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t KeepAlivePduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
ReturnValue_t result = ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }

View File

@ -2,9 +2,9 @@
#define FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_
#include "fsfw/cfdp/FileSize.h" #include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" #include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
class KeepAlivePduSerializer : public FileDirectiveSerializer { class KeepAlivePduSerializer : public FileDirectiveCreator {
public: public:
KeepAlivePduSerializer(PduConfig& conf, cfdp::FileSize& progress); KeepAlivePduSerializer(PduConfig& conf, cfdp::FileSize& progress);

View File

@ -2,16 +2,16 @@
MetadataPduDeserializer::MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize, MetadataPduDeserializer::MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize,
MetadataInfo& info) MetadataInfo& info)
: FileDirectiveDeserializer(pduBuf, maxSize), info(info) {} : FileDirectiveReader(pduBuf, maxSize), info(info) {}
ReturnValue_t MetadataPduDeserializer::parseData() { ReturnValue_t MetadataPduDeserializer::parseData() {
ReturnValue_t result = FileDirectiveDeserializer::parseData(); ReturnValue_t result = FileDirectiveReader::parseData();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); size_t currentIdx = FileDirectiveReader::getHeaderSize();
const uint8_t* buf = rawPtr + currentIdx; const uint8_t* buf = rawPtr + currentIdx;
size_t remSize = FileDirectiveDeserializer::getWholePduSize() - currentIdx; size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx;
if (remSize < 1) { if (remSize < 1) {
return SerializeIF::STREAM_TOO_SHORT; return SerializeIF::STREAM_TOO_SHORT;
} }

View File

@ -1,10 +1,10 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_ #ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h"
#include "fsfw/cfdp/pdu/MetadataInfo.h" #include "fsfw/cfdp/pdu/MetadataInfo.h"
class MetadataPduDeserializer : public FileDirectiveDeserializer { class MetadataPduDeserializer : public FileDirectiveReader {
public: public:
MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info); MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info);

View File

@ -1,7 +1,7 @@
#include "MetadataPduSerializer.h" #include "MetadataPduSerializer.h"
MetadataPduSerializer::MetadataPduSerializer(PduConfig &conf, MetadataInfo &info) MetadataPduSerializer::MetadataPduSerializer(PduConfig &conf, MetadataInfo &info)
: FileDirectiveSerializer(conf, cfdp::FileDirectives::METADATA, 5), info(info) { : FileDirectiveCreator(conf, cfdp::FileDirectives::METADATA, 5), info(info) {
updateDirectiveFieldLen(); updateDirectiveFieldLen();
} }
@ -10,13 +10,12 @@ void MetadataPduSerializer::updateDirectiveFieldLen() {
} }
size_t MetadataPduSerializer::getSerializedSize() const { size_t MetadataPduSerializer::getSerializedSize() const {
return FileDirectiveSerializer::getWholePduSize(); return FileDirectiveCreator::getWholePduSize();
} }
ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
ReturnValue_t result = ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }

View File

@ -1,10 +1,10 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_ #ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" #include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
#include "fsfw/cfdp/pdu/MetadataInfo.h" #include "fsfw/cfdp/pdu/MetadataInfo.h"
class MetadataPduSerializer : public FileDirectiveSerializer { class MetadataPduSerializer : public FileDirectiveCreator {
public: public:
MetadataPduSerializer(PduConfig& conf, MetadataInfo& info); MetadataPduSerializer(PduConfig& conf, MetadataInfo& info);

View File

@ -26,7 +26,7 @@ bool NakInfo::hasSegmentRequests() const {
} }
bool NakInfo::canHoldSegmentRequests() const { bool NakInfo::canHoldSegmentRequests() const {
if (this->segmentRequests != nullptr and maxSegmentRequestsLen > 0) { if (segmentRequests != nullptr and maxSegmentRequestsLen > 0) {
return true; return true;
} }
return false; return false;

View File

@ -1,16 +1,16 @@
#include "NakPduDeserializer.h" #include "NakPduDeserializer.h"
NakPduDeserializer::NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, NakInfo& info) NakPduDeserializer::NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, NakInfo& info)
: FileDirectiveDeserializer(pduBuf, maxSize), nakInfo(info) {} : FileDirectiveReader(pduBuf, maxSize), nakInfo(info) {}
ReturnValue_t NakPduDeserializer::parseData() { ReturnValue_t NakPduDeserializer::parseData() {
ReturnValue_t result = FileDirectiveDeserializer::parseData(); ReturnValue_t result = FileDirectiveReader::parseData();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); size_t currentIdx = FileDirectiveReader::getHeaderSize();
const uint8_t* buffer = rawPtr + currentIdx; const uint8_t* buffer = rawPtr + currentIdx;
size_t remSize = FileDirectiveDeserializer::getWholePduSize() - currentIdx; size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx;
if (remSize < 1) { if (remSize < 1) {
return SerializeIF::STREAM_TOO_SHORT; return SerializeIF::STREAM_TOO_SHORT;
} }

View File

@ -1,10 +1,10 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_ #ifndef FSFW_SRC_FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h"
#include "fsfw/cfdp/pdu/NakInfo.h" #include "fsfw/cfdp/pdu/NakInfo.h"
class NakPduDeserializer : public FileDirectiveDeserializer { class NakPduDeserializer : public FileDirectiveReader {
public: public:
NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, NakInfo& info); NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, NakInfo& info);

View File

@ -1,7 +1,7 @@
#include "NakPduSerializer.h" #include "NakPduSerializer.h"
NakPduSerializer::NakPduSerializer(PduConfig &pduConf, NakInfo &nakInfo) NakPduSerializer::NakPduSerializer(PduConfig &pduConf, NakInfo &nakInfo)
: FileDirectiveSerializer(pduConf, cfdp::FileDirectives::NAK, 0), nakInfo(nakInfo) { : FileDirectiveCreator(pduConf, cfdp::FileDirectives::NAK, 0), nakInfo(nakInfo) {
updateDirectiveFieldLen(); updateDirectiveFieldLen();
} }
@ -10,13 +10,12 @@ void NakPduSerializer::updateDirectiveFieldLen() {
} }
size_t NakPduSerializer::getSerializedSize() const { size_t NakPduSerializer::getSerializedSize() const {
return FileDirectiveSerializer::getWholePduSize(); return FileDirectiveCreator::getWholePduSize();
} }
ReturnValue_t NakPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t NakPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
ReturnValue_t result = ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }

View File

@ -6,9 +6,9 @@
#include "NakInfo.h" #include "NakInfo.h"
#include "fsfw/cfdp/FileSize.h" #include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/definitions.h" #include "fsfw/cfdp/definitions.h"
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" #include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
class NakPduSerializer : public FileDirectiveSerializer { class NakPduSerializer : public FileDirectiveCreator {
public: public:
/** /**
* *

View File

@ -1,21 +1,21 @@
#include "PromptPduDeserializer.h" #include "PromptPduDeserializer.h"
PromptPduDeserializer::PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize) PromptPduDeserializer::PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize)
: FileDirectiveDeserializer(pduBuf, maxSize) {} : FileDirectiveReader(pduBuf, maxSize) {}
cfdp::PromptResponseRequired PromptPduDeserializer::getPromptResponseRequired() const { cfdp::PromptResponseRequired PromptPduDeserializer::getPromptResponseRequired() const {
return responseRequired; return responseRequired;
} }
ReturnValue_t PromptPduDeserializer::parseData() { ReturnValue_t PromptPduDeserializer::parseData() {
ReturnValue_t result = FileDirectiveDeserializer::parseData(); ReturnValue_t result = FileDirectiveReader::parseData();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); if (FileDirectiveReader::getWholePduSize() <= FileDirectiveReader::getHeaderSize()) {
if (FileDirectiveDeserializer::getWholePduSize() - currentIdx < 1) {
return SerializeIF::STREAM_TOO_SHORT; return SerializeIF::STREAM_TOO_SHORT;
} }
responseRequired = static_cast<cfdp::PromptResponseRequired>((rawPtr[currentIdx] >> 7) & 0x01); responseRequired = static_cast<cfdp::PromptResponseRequired>(
(rawPtr[FileDirectiveReader::getHeaderSize()] >> 7) & 0x01);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -1,9 +1,9 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUDESERIALIZER_H_ #ifndef FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUDESERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUDESERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUDESERIALIZER_H_
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h"
class PromptPduDeserializer : public FileDirectiveDeserializer { class PromptPduDeserializer : public FileDirectiveReader {
public: public:
PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize); PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize);

View File

@ -2,24 +2,23 @@
PromptPduSerializer::PromptPduSerializer(PduConfig &conf, PromptPduSerializer::PromptPduSerializer(PduConfig &conf,
cfdp::PromptResponseRequired responseRequired) cfdp::PromptResponseRequired responseRequired)
: FileDirectiveSerializer(conf, cfdp::FileDirectives::PROMPT, 1), : FileDirectiveCreator(conf, cfdp::FileDirectives::PROMPT, 1),
responseRequired(responseRequired) {} responseRequired(responseRequired) {}
size_t PromptPduSerializer::getSerializedSize() const { size_t PromptPduSerializer::getSerializedSize() const {
return FileDirectiveSerializer::getWholePduSize(); return FileDirectiveCreator::getWholePduSize();
} }
ReturnValue_t PromptPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t PromptPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
ReturnValue_t result = ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
if (*size + 1 > maxSize) { if (*size + 1 > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT; return SerializeIF::BUFFER_TOO_SHORT;
} }
**buffer = this->responseRequired << 7; **buffer = responseRequired << 7;
*buffer += 1; *buffer += 1;
*size += 1; *size += 1;
return result; return result;

View File

@ -1,13 +1,13 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUSERIALIZER_H_ #ifndef FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUSERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUSERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUSERIALIZER_H_
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" #include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
class PromptPduSerializer : public FileDirectiveSerializer { class PromptPduSerializer : public FileDirectiveCreator {
public: public:
PromptPduSerializer(PduConfig& conf, cfdp::PromptResponseRequired responseRequired); PromptPduSerializer(PduConfig& conf, cfdp::PromptResponseRequired responseRequired);
size_t getSerializedSize() const override; [[nodiscard]] size_t getSerializedSize() const override;
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;

View File

@ -3,8 +3,8 @@
#include <cstring> #include <cstring>
#include "fsfw/cfdp/FileSize.h" #include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" #include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h"
#include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/globalfunctions/arrayprinter.h"
#include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serialize/SerializeAdapter.h"
@ -22,7 +22,7 @@ TEST_CASE("CFDP Base", "[cfdp]") {
size_t serSize = 0; size_t serSize = 0;
SECTION("File Directive") { SECTION("File Directive") {
auto fdSer = FileDirectiveSerializer(pduConf, FileDirectives::ACK, 4); auto fdSer = FileDirectiveCreator(pduConf, FileDirectives::ACK, 4);
REQUIRE(fdSer.getSerializedSize() == 8); REQUIRE(fdSer.getSerializedSize() == 8);
serTarget = serBuf.data(); serTarget = serBuf.data();
serSize = 0; serSize = 0;
@ -59,7 +59,7 @@ TEST_CASE("CFDP Base", "[cfdp]") {
deserTarget = serBuf.data(); deserTarget = serBuf.data();
deserSize = 0; deserSize = 0;
auto fdDeser = FileDirectiveDeserializer(deserTarget, serBuf.size()); auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size());
REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::NETWORK); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::NETWORK);
fdDeser.setEndianness(SerializeIF::Endianness::MACHINE); fdDeser.setEndianness(SerializeIF::Endianness::MACHINE);
REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE);

View File

@ -1,8 +1,8 @@
#include <array> #include <array>
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include "fsfw/cfdp/pdu/FileDataDeserializer.h" #include "fsfw/cfdp/pdu/FileDataCreator.h"
#include "fsfw/cfdp/pdu/FileDataSerializer.h" #include "fsfw/cfdp/pdu/FileDataReader.h"
#include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/globalfunctions/arrayprinter.h"
#include "fsfw/serviceinterface.h" #include "fsfw/serviceinterface.h"
@ -26,7 +26,7 @@ TEST_CASE("File Data PDU", "[cfdp][pdu]") {
FileDataInfo info(offset, fileBuffer.data(), 10); FileDataInfo info(offset, fileBuffer.data(), 10);
SECTION("Serialization") { SECTION("Serialization") {
FileDataSerializer serializer(pduConf, info); FileDataCreator serializer(pduConf, info);
result = result =
serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK); serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
@ -102,14 +102,14 @@ TEST_CASE("File Data PDU", "[cfdp][pdu]") {
} }
SECTION("Deserialization") { SECTION("Deserialization") {
FileDataSerializer serializer(pduConf, info); FileDataCreator serializer(pduConf, info);
result = result =
serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK); serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
FileSize emptyOffset; FileSize emptyOffset;
FileDataInfo emptyInfo(emptyOffset); FileDataInfo emptyInfo(emptyOffset);
FileDataDeserializer deserializer(fileDataBuffer.data(), fileDataBuffer.size(), emptyInfo); FileDataReader deserializer(fileDataBuffer.data(), fileDataBuffer.size(), emptyInfo);
result = deserializer.parseData(); result = deserializer.parseData();
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(deserializer.getWholePduSize() == 24); REQUIRE(deserializer.getWholePduSize() == 24);

View File

@ -1,8 +1,8 @@
#include <array> #include <array>
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" #include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h"
TEST_CASE("CFDP File Directive", "[cfdp]") { TEST_CASE("CFDP File Directive", "[cfdp]") {
using namespace cfdp; using namespace cfdp;
@ -18,7 +18,7 @@ TEST_CASE("CFDP File Directive", "[cfdp]") {
size_t serSize = 0; size_t serSize = 0;
SECTION("File Directive") { SECTION("File Directive") {
auto fdSer = FileDirectiveSerializer(pduConf, FileDirectives::ACK, 4); auto fdSer = FileDirectiveCreator(pduConf, FileDirectives::ACK, 4);
REQUIRE(fdSer.getSerializedSize() == 8); REQUIRE(fdSer.getSerializedSize() == 8);
serTarget = serBuf.data(); serTarget = serBuf.data();
serSize = 0; serSize = 0;
@ -55,7 +55,7 @@ TEST_CASE("CFDP File Directive", "[cfdp]") {
deserTarget = serBuf.data(); deserTarget = serBuf.data();
deserSize = 0; deserSize = 0;
auto fdDeser = FileDirectiveDeserializer(deserTarget, serBuf.size()); auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size());
REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::NETWORK); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::NETWORK);
fdDeser.setEndianness(SerializeIF::Endianness::MACHINE); fdDeser.setEndianness(SerializeIF::Endianness::MACHINE);
REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE);

View File

@ -25,7 +25,7 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") {
result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(serializer.getSerializedSize() == 19); REQUIRE(serializer.getSerializedSize() == 19);
REQUIRE(serializer.FileDirectiveSerializer::getSerializedSize() == 11); REQUIRE(serializer.FileDirectiveCreator::getSerializedSize() == 11);
REQUIRE(sz == 19); REQUIRE(sz == 19);
REQUIRE(serializer.getPduDataFieldLen() == 9); REQUIRE(serializer.getPduDataFieldLen() == 9);
REQUIRE(((nakBuffer[1] << 8) | nakBuffer[2]) == 0x09); REQUIRE(((nakBuffer[1] << 8) | nakBuffer[2]) == 0x09);

View File

@ -51,8 +51,10 @@ TEST_CASE("Prompt PDU", "[cfdp][pdu]") {
REQUIRE(deserializer.getPromptResponseRequired() == REQUIRE(deserializer.getPromptResponseRequired() ==
cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE);
sz = deserializer.getWholePduSize(); sz = deserializer.getWholePduSize();
// Set invalid size
rawBuf[2] = 1; rawBuf[2] = 1;
result = deserializer.parseData(); result = deserializer.parseData();
size_t sz2 = deserializer.getWholePduSize();
REQUIRE(result == SerializeIF::STREAM_TOO_SHORT); REQUIRE(result == SerializeIF::STREAM_TOO_SHORT);
rawBuf[2] = 2; rawBuf[2] = 2;