better names
This commit is contained in:
parent
7fb9e14555
commit
acf5c2a56d
@ -1,14 +1,14 @@
|
||||
#include "AckPduDeserializer.h"
|
||||
|
||||
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 result = FileDirectiveDeserializer::parseData();
|
||||
ReturnValue_t result = FileDirectiveReader::parseData();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
|
||||
size_t currentIdx = FileDirectiveReader::getHeaderSize();
|
||||
if (currentIdx + 2 > this->maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define FSFW_SRC_FSFW_CFDP_PDU_ACKPDUDESERIALIZER_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:
|
||||
AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, AckInfo& info);
|
||||
|
||||
|
@ -1,16 +1,15 @@
|
||||
#include "AckPduSerializer.h"
|
||||
|
||||
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 {
|
||||
return FileDirectiveSerializer::getWholePduSize();
|
||||
return FileDirectiveCreator::getWholePduSize();
|
||||
}
|
||||
|
||||
ReturnValue_t AckPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
ReturnValue_t result =
|
||||
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
|
||||
ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
#define FSFW_SRC_FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_
|
||||
|
||||
#include "AckInfo.h"
|
||||
#include "FileDirectiveDeserializer.h"
|
||||
#include "FileDirectiveSerializer.h"
|
||||
#include "FileDirectiveCreator.h"
|
||||
#include "FileDirectiveReader.h"
|
||||
|
||||
class AckPduSerializer : public FileDirectiveSerializer {
|
||||
class AckPduSerializer : public FileDirectiveCreator {
|
||||
public:
|
||||
/**
|
||||
* @brief Serializer to pack ACK PDUs
|
||||
|
@ -4,8 +4,8 @@ target_sources(
|
||||
VarLenField.cpp
|
||||
HeaderCreator.cpp
|
||||
HeaderReader.cpp
|
||||
FileDirectiveDeserializer.cpp
|
||||
FileDirectiveSerializer.cpp
|
||||
FileDirectiveReader.cpp
|
||||
FileDirectiveCreator.cpp
|
||||
AckInfo.cpp
|
||||
AckPduSerializer.cpp
|
||||
AckPduDeserializer.cpp
|
||||
@ -25,6 +25,6 @@ target_sources(
|
||||
KeepAlivePduDeserializer.cpp
|
||||
PromptPduSerializer.cpp
|
||||
PromptPduDeserializer.cpp
|
||||
FileDataSerializer.cpp
|
||||
FileDataDeserializer.cpp
|
||||
FileDataCreator.cpp
|
||||
FileDataReader.cpp
|
||||
FileDataInfo.cpp)
|
||||
|
@ -4,10 +4,10 @@
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
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 result = FileDirectiveDeserializer::parseData();
|
||||
ReturnValue_t result = FileDirectiveReader::parseData();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -17,7 +17,7 @@ ReturnValue_t EofPduDeserializer::parseData() {
|
||||
if (this->getLargeFileFlag()) {
|
||||
expectedFileFieldLen = 8;
|
||||
}
|
||||
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
|
||||
size_t currentIdx = FileDirectiveReader::getHeaderSize();
|
||||
size_t deserLen = maxSize;
|
||||
if (maxSize < currentIdx + 5 + expectedFileFieldLen) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define FSFW_SRC_FSFW_CFDP_PDU_EOFPDUDESERIALIZER_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:
|
||||
EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo);
|
||||
|
||||
|
@ -4,18 +4,17 @@
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
size_t EofPduSerializer::getSerializedSize() const {
|
||||
return FileDirectiveSerializer::getWholePduSize();
|
||||
return FileDirectiveCreator::getWholePduSize();
|
||||
}
|
||||
|
||||
ReturnValue_t EofPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
ReturnValue_t result =
|
||||
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
|
||||
ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
#define FSFW_SRC_FSFW_CFDP_PDU_EOFPDUSERIALIZER_H_
|
||||
|
||||
#include "EofInfo.h"
|
||||
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
|
||||
#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
|
||||
#include "fsfw/cfdp/tlv/EntityIdTlv.h"
|
||||
|
||||
class EofPduSerializer : public FileDirectiveSerializer {
|
||||
class EofPduSerializer : public FileDirectiveCreator {
|
||||
public:
|
||||
EofPduSerializer(PduConfig& conf, EofInfo& info);
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
#include "FileDataSerializer.h"
|
||||
#include "FileDataCreator.h"
|
||||
|
||||
#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) {
|
||||
update();
|
||||
}
|
||||
|
||||
void FileDataSerializer::update() {
|
||||
void FileDataCreator::update() {
|
||||
this->setSegmentMetadataFlag(info.getSegmentMetadataFlag());
|
||||
this->setSegmentationControl(info.getSegmentationControl());
|
||||
setPduDataFieldLen(info.getSerializedSize(this->getLargeFileFlag()));
|
||||
}
|
||||
|
||||
ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
ReturnValue_t FileDataCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
@ -49,6 +49,6 @@ ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
size_t FileDataSerializer::getSerializedSize() const {
|
||||
size_t FileDataCreator::getSerializedSize() const {
|
||||
return HeaderCreator::getSerializedSize() + info.getSerializedSize(this->getLargeFileFlag());
|
||||
}
|
23
src/fsfw/cfdp/pdu/FileDataCreator.h
Normal file
23
src/fsfw/cfdp/pdu/FileDataCreator.h
Normal 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_ */
|
@ -1,10 +1,9 @@
|
||||
#include "FileDataDeserializer.h"
|
||||
#include "FileDataReader.h"
|
||||
|
||||
FileDataDeserializer::FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize,
|
||||
FileDataInfo& info)
|
||||
FileDataReader::FileDataReader(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info)
|
||||
: HeaderReader(pduBuf, maxSize), info(info) {}
|
||||
|
||||
ReturnValue_t FileDataDeserializer::parseData() {
|
||||
ReturnValue_t FileDataReader::parseData() {
|
||||
ReturnValue_t result = HeaderReader::parseData();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
@ -41,8 +40,8 @@ ReturnValue_t FileDataDeserializer::parseData() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
SerializeIF::Endianness FileDataDeserializer::getEndianness() const { return endianness; }
|
||||
SerializeIF::Endianness FileDataReader::getEndianness() const { return endianness; }
|
||||
|
||||
void FileDataDeserializer::setEndianness(SerializeIF::Endianness endianness) {
|
||||
this->endianness = endianness;
|
||||
void FileDataReader::setEndianness(SerializeIF::Endianness endianness_) {
|
||||
endianness = endianness_;
|
||||
}
|
@ -5,12 +5,12 @@
|
||||
#include "FileDataInfo.h"
|
||||
#include "HeaderReader.h"
|
||||
|
||||
class FileDataDeserializer : public HeaderReader {
|
||||
class FileDataReader : public HeaderReader {
|
||||
public:
|
||||
FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info);
|
||||
FileDataReader(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info);
|
||||
|
||||
ReturnValue_t parseData();
|
||||
SerializeIF::Endianness getEndianness() const;
|
||||
ReturnValue_t parseData() override;
|
||||
[[nodiscard]] SerializeIF::Endianness getEndianness() const;
|
||||
void setEndianness(SerializeIF::Endianness endianness = SerializeIF::Endianness::NETWORK);
|
||||
|
||||
private:
|
@ -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_ */
|
@ -1,21 +1,20 @@
|
||||
#include "FileDirectiveSerializer.h"
|
||||
#include "FileDirectiveCreator.h"
|
||||
|
||||
FileDirectiveSerializer::FileDirectiveSerializer(PduConfig &pduConf,
|
||||
cfdp::FileDirectives directiveCode,
|
||||
size_t directiveParamFieldLen)
|
||||
FileDirectiveCreator::FileDirectiveCreator(PduConfig &pduConf, cfdp::FileDirectives directiveCode,
|
||||
size_t directiveParamFieldLen)
|
||||
: HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, directiveParamFieldLen + 1),
|
||||
directiveCode(directiveCode) {}
|
||||
|
||||
size_t FileDirectiveSerializer::getSerializedSize() const {
|
||||
size_t FileDirectiveCreator::getSerializedSize() const {
|
||||
return HeaderCreator::getSerializedSize() + 1;
|
||||
}
|
||||
|
||||
ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
if (buffer == nullptr or size == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if (FileDirectiveSerializer::getWholePduSize() > maxSize) {
|
||||
if (FileDirectiveCreator::getWholePduSize() > maxSize) {
|
||||
return BUFFER_TOO_SHORT;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
void FileDirectiveSerializer::setDirectiveDataFieldLen(size_t len) {
|
||||
void FileDirectiveCreator::setDirectiveDataFieldLen(size_t len) {
|
||||
// Set length of data field plus 1 byte for the directive octet
|
||||
HeaderCreator::setPduDataFieldLen(len + 1);
|
||||
}
|
@ -3,18 +3,18 @@
|
||||
|
||||
#include "fsfw/cfdp/pdu/HeaderCreator.h"
|
||||
|
||||
class FileDirectiveSerializer : public HeaderCreator {
|
||||
class FileDirectiveCreator : public HeaderCreator {
|
||||
public:
|
||||
FileDirectiveSerializer(PduConfig& pduConf, cfdp::FileDirectives directiveCode,
|
||||
size_t directiveParamFieldLen);
|
||||
FileDirectiveCreator(PduConfig& pduConf, cfdp::FileDirectives directiveCode,
|
||||
size_t directiveParamFieldLen);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return
|
||||
*/
|
||||
size_t getSerializedSize() const override;
|
||||
[[nodiscard]] size_t getSerializedSize() const override;
|
||||
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) const override;
|
@ -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) {}
|
||||
|
||||
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();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
@ -13,7 +13,7 @@ ReturnValue_t FileDirectiveDeserializer::parseData() {
|
||||
if (this->getPduDataFieldLen() < 1) {
|
||||
return cfdp::INVALID_PDU_DATAFIELD_LEN;
|
||||
}
|
||||
if (FileDirectiveDeserializer::getWholePduSize() > maxSize) {
|
||||
if (FileDirectiveReader::getWholePduSize() > maxSize) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
size_t currentIdx = HeaderReader::getHeaderSize();
|
||||
@ -24,12 +24,12 @@ ReturnValue_t FileDirectiveDeserializer::parseData() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
size_t FileDirectiveDeserializer::getHeaderSize() const {
|
||||
size_t FileDirectiveReader::getHeaderSize() const {
|
||||
// return size of header plus the directive byte
|
||||
return HeaderReader::getHeaderSize() + 1;
|
||||
}
|
||||
|
||||
bool FileDirectiveDeserializer::checkFileDirective(uint8_t rawByte) {
|
||||
bool FileDirectiveReader::checkFileDirective(uint8_t rawByte) {
|
||||
if (rawByte < cfdp::FileDirectives::EOF_DIRECTIVE or
|
||||
(rawByte > cfdp::FileDirectives::PROMPT and rawByte != cfdp::FileDirectives::KEEP_ALIVE)) {
|
||||
// Invalid directive field. TODO: Custom returnvalue
|
||||
@ -38,12 +38,12 @@ bool FileDirectiveDeserializer::checkFileDirective(uint8_t rawByte) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileDirectiveDeserializer::setFileDirective(cfdp::FileDirectives fileDirective) {
|
||||
this->fileDirective = fileDirective;
|
||||
void FileDirectiveReader::setFileDirective(cfdp::FileDirectives fileDirective_) {
|
||||
fileDirective = fileDirective_;
|
||||
}
|
||||
|
||||
void FileDirectiveDeserializer::setEndianness(SerializeIF::Endianness endianness) {
|
||||
this->endianness = endianness;
|
||||
void FileDirectiveReader::setEndianness(SerializeIF::Endianness endianness_) {
|
||||
endianness = endianness_;
|
||||
}
|
||||
|
||||
SerializeIF::Endianness FileDirectiveDeserializer::getEndianness() const { return endianness; }
|
||||
SerializeIF::Endianness FileDirectiveReader::getEndianness() const { return endianness; }
|
@ -11,24 +11,24 @@
|
||||
* This is a zero-copy implementation and #parseData needs to be called to ensure the data is
|
||||
* valid.
|
||||
*/
|
||||
class FileDirectiveDeserializer : public HeaderReader {
|
||||
class FileDirectiveReader : public HeaderReader {
|
||||
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.
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t parseData();
|
||||
size_t getHeaderSize() const;
|
||||
ReturnValue_t parseData() override;
|
||||
[[nodiscard]] size_t getHeaderSize() const override;
|
||||
|
||||
cfdp::FileDirectives getFileDirective() const;
|
||||
[[nodiscard]] cfdp::FileDirectives getFileDirective() const;
|
||||
|
||||
void setEndianness(SerializeIF::Endianness endianness);
|
||||
SerializeIF::Endianness getEndianness() const;
|
||||
[[nodiscard]] SerializeIF::Endianness getEndianness() const;
|
||||
|
||||
protected:
|
||||
bool checkFileDirective(uint8_t rawByte);
|
||||
static bool checkFileDirective(uint8_t rawByte);
|
||||
|
||||
private:
|
||||
void setFileDirective(cfdp::FileDirectives fileDirective);
|
@ -2,21 +2,21 @@
|
||||
|
||||
FinishPduDeserializer::FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSize,
|
||||
FinishedInfo& info)
|
||||
: FileDirectiveDeserializer(pduBuf, maxSize), finishedInfo(info) {}
|
||||
: FileDirectiveReader(pduBuf, maxSize), finishedInfo(info) {}
|
||||
|
||||
ReturnValue_t FinishPduDeserializer::parseData() {
|
||||
ReturnValue_t result = FileDirectiveDeserializer::parseData();
|
||||
ReturnValue_t result = FileDirectiveReader::parseData();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
|
||||
size_t currentIdx = FileDirectiveReader::getHeaderSize();
|
||||
const uint8_t* buf = rawPtr + currentIdx;
|
||||
size_t remSize = FileDirectiveDeserializer::getWholePduSize() - currentIdx;
|
||||
size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx;
|
||||
if (remSize < 1) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
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.setDeliveryCode(static_cast<cfdp::FinishedDeliveryCode>(firstByte >> 2 & 0b1));
|
||||
finishedInfo.setFileStatus(static_cast<cfdp::FinishedFileStatus>(firstByte & 0b11));
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef 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"
|
||||
|
||||
class FinishPduDeserializer : public FileDirectiveDeserializer {
|
||||
class FinishPduDeserializer : public FileDirectiveReader {
|
||||
public:
|
||||
FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSize, FinishedInfo& info);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "FinishedPduSerializer.h"
|
||||
|
||||
FinishPduSerializer::FinishPduSerializer(PduConfig &conf, FinishedInfo &finishInfo)
|
||||
: FileDirectiveSerializer(conf, cfdp::FileDirectives::FINISH, 0), finishInfo(finishInfo) {
|
||||
: FileDirectiveCreator(conf, cfdp::FileDirectives::FINISH, 0), finishInfo(finishInfo) {
|
||||
updateDirectiveFieldLen();
|
||||
}
|
||||
|
||||
@ -15,8 +15,7 @@ void FinishPduSerializer::updateDirectiveFieldLen() {
|
||||
|
||||
ReturnValue_t FinishPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
ReturnValue_t result =
|
||||
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
|
||||
ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
#define FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_
|
||||
|
||||
#include "FinishedInfo.h"
|
||||
#include "fsfw/cfdp/pdu/FileDataSerializer.h"
|
||||
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
|
||||
#include "fsfw/cfdp/pdu/FileDataCreator.h"
|
||||
#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
|
||||
|
||||
class FinishPduSerializer : public FileDirectiveSerializer {
|
||||
class FinishPduSerializer : public FileDirectiveCreator {
|
||||
public:
|
||||
FinishPduSerializer(PduConfig& pduConf, FinishedInfo& finishInfo);
|
||||
|
||||
|
@ -47,8 +47,7 @@ ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t ma
|
||||
}
|
||||
|
||||
size_t HeaderCreator::getSerializedSize() const {
|
||||
size_t shit = pduConf.seqNum.getWidth() + pduConf.sourceId.getWidth() * 2 + 4;
|
||||
return shit;
|
||||
return pduConf.seqNum.getWidth() + pduConf.sourceId.getWidth() * 2 + 4;
|
||||
}
|
||||
|
||||
ReturnValue_t HeaderCreator::deSerialize(const uint8_t **buffer, size_t *size,
|
||||
|
@ -38,11 +38,12 @@ size_t HeaderReader::getHeaderSize() const {
|
||||
}
|
||||
|
||||
size_t HeaderReader::getPduDataFieldLen() const {
|
||||
uint16_t pduFiedlLen = (fixedHeader->pduDataFieldLenH << 8) | fixedHeader->pduDataFieldLenL;
|
||||
return pduFiedlLen;
|
||||
return (fixedHeader->pduDataFieldLenH << 8) | fixedHeader->pduDataFieldLenL;
|
||||
}
|
||||
|
||||
size_t HeaderReader::getWholePduSize() const { return getPduDataFieldLen() + getHeaderSize(); }
|
||||
size_t HeaderReader::getWholePduSize() const {
|
||||
return getPduDataFieldLen() + HeaderReader::getHeaderSize();
|
||||
}
|
||||
|
||||
cfdp::PduType HeaderReader::getPduType() const {
|
||||
return static_cast<cfdp::PduType>((fixedHeader->firstByte >> 4) & 0x01);
|
||||
|
@ -41,7 +41,7 @@ class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF {
|
||||
* - SerializeIF::BUFFER_TOO_SHORT if buffer is shorter than expected
|
||||
*/
|
||||
virtual ReturnValue_t parseData();
|
||||
[[nodiscard]] size_t getHeaderSize() const;
|
||||
[[nodiscard]] virtual size_t getHeaderSize() const;
|
||||
|
||||
[[nodiscard]] size_t getPduDataFieldLen() const override;
|
||||
[[nodiscard]] size_t getWholePduSize() const override;
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
KeepAlivePduDeserializer::KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t maxSize,
|
||||
cfdp::FileSize& progress)
|
||||
: FileDirectiveDeserializer(pduBuf, maxSize), progress(progress) {}
|
||||
: FileDirectiveReader(pduBuf, maxSize), progress(progress) {}
|
||||
|
||||
ReturnValue_t KeepAlivePduDeserializer::parseData() {
|
||||
ReturnValue_t result = FileDirectiveDeserializer::parseData();
|
||||
ReturnValue_t result = FileDirectiveReader::parseData();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
|
||||
size_t remLen = FileDirectiveDeserializer::getWholePduSize() - currentIdx;
|
||||
size_t currentIdx = FileDirectiveReader::getHeaderSize();
|
||||
size_t remLen = FileDirectiveReader::getWholePduSize() - currentIdx;
|
||||
const uint8_t* buffer = rawPtr + currentIdx;
|
||||
return progress.deSerialize(&buffer, &remLen, getEndianness());
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUDESERIALIZER_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:
|
||||
KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t maxSize, cfdp::FileSize& progress);
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "KeepAlivePduSerializer.h"
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
size_t KeepAlivePduSerializer::getSerializedSize() const {
|
||||
return FileDirectiveSerializer::getWholePduSize();
|
||||
return FileDirectiveCreator::getWholePduSize();
|
||||
}
|
||||
|
||||
void KeepAlivePduSerializer::updateDirectiveFieldLen() {
|
||||
@ -17,8 +17,7 @@ void KeepAlivePduSerializer::updateDirectiveFieldLen() {
|
||||
|
||||
ReturnValue_t KeepAlivePduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
ReturnValue_t result =
|
||||
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
|
||||
ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_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:
|
||||
KeepAlivePduSerializer(PduConfig& conf, cfdp::FileSize& progress);
|
||||
|
||||
|
@ -2,16 +2,16 @@
|
||||
|
||||
MetadataPduDeserializer::MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize,
|
||||
MetadataInfo& info)
|
||||
: FileDirectiveDeserializer(pduBuf, maxSize), info(info) {}
|
||||
: FileDirectiveReader(pduBuf, maxSize), info(info) {}
|
||||
|
||||
ReturnValue_t MetadataPduDeserializer::parseData() {
|
||||
ReturnValue_t result = FileDirectiveDeserializer::parseData();
|
||||
ReturnValue_t result = FileDirectiveReader::parseData();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
|
||||
size_t currentIdx = FileDirectiveReader::getHeaderSize();
|
||||
const uint8_t* buf = rawPtr + currentIdx;
|
||||
size_t remSize = FileDirectiveDeserializer::getWholePduSize() - currentIdx;
|
||||
size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx;
|
||||
if (remSize < 1) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef 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"
|
||||
|
||||
class MetadataPduDeserializer : public FileDirectiveDeserializer {
|
||||
class MetadataPduDeserializer : public FileDirectiveReader {
|
||||
public:
|
||||
MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "MetadataPduSerializer.h"
|
||||
|
||||
MetadataPduSerializer::MetadataPduSerializer(PduConfig &conf, MetadataInfo &info)
|
||||
: FileDirectiveSerializer(conf, cfdp::FileDirectives::METADATA, 5), info(info) {
|
||||
: FileDirectiveCreator(conf, cfdp::FileDirectives::METADATA, 5), info(info) {
|
||||
updateDirectiveFieldLen();
|
||||
}
|
||||
|
||||
@ -10,13 +10,12 @@ void MetadataPduSerializer::updateDirectiveFieldLen() {
|
||||
}
|
||||
|
||||
size_t MetadataPduSerializer::getSerializedSize() const {
|
||||
return FileDirectiveSerializer::getWholePduSize();
|
||||
return FileDirectiveCreator::getWholePduSize();
|
||||
}
|
||||
|
||||
ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
ReturnValue_t result =
|
||||
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
|
||||
ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef 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"
|
||||
|
||||
class MetadataPduSerializer : public FileDirectiveSerializer {
|
||||
class MetadataPduSerializer : public FileDirectiveCreator {
|
||||
public:
|
||||
MetadataPduSerializer(PduConfig& conf, MetadataInfo& info);
|
||||
|
||||
|
@ -26,7 +26,7 @@ bool NakInfo::hasSegmentRequests() const {
|
||||
}
|
||||
|
||||
bool NakInfo::canHoldSegmentRequests() const {
|
||||
if (this->segmentRequests != nullptr and maxSegmentRequestsLen > 0) {
|
||||
if (segmentRequests != nullptr and maxSegmentRequestsLen > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "NakPduDeserializer.h"
|
||||
|
||||
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 result = FileDirectiveDeserializer::parseData();
|
||||
ReturnValue_t result = FileDirectiveReader::parseData();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
|
||||
size_t currentIdx = FileDirectiveReader::getHeaderSize();
|
||||
const uint8_t* buffer = rawPtr + currentIdx;
|
||||
size_t remSize = FileDirectiveDeserializer::getWholePduSize() - currentIdx;
|
||||
size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx;
|
||||
if (remSize < 1) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef 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"
|
||||
|
||||
class NakPduDeserializer : public FileDirectiveDeserializer {
|
||||
class NakPduDeserializer : public FileDirectiveReader {
|
||||
public:
|
||||
NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, NakInfo& info);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "NakPduSerializer.h"
|
||||
|
||||
NakPduSerializer::NakPduSerializer(PduConfig &pduConf, NakInfo &nakInfo)
|
||||
: FileDirectiveSerializer(pduConf, cfdp::FileDirectives::NAK, 0), nakInfo(nakInfo) {
|
||||
: FileDirectiveCreator(pduConf, cfdp::FileDirectives::NAK, 0), nakInfo(nakInfo) {
|
||||
updateDirectiveFieldLen();
|
||||
}
|
||||
|
||||
@ -10,13 +10,12 @@ void NakPduSerializer::updateDirectiveFieldLen() {
|
||||
}
|
||||
|
||||
size_t NakPduSerializer::getSerializedSize() const {
|
||||
return FileDirectiveSerializer::getWholePduSize();
|
||||
return FileDirectiveCreator::getWholePduSize();
|
||||
}
|
||||
|
||||
ReturnValue_t NakPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
ReturnValue_t result =
|
||||
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
|
||||
ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
#include "NakInfo.h"
|
||||
#include "fsfw/cfdp/FileSize.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:
|
||||
/**
|
||||
*
|
||||
|
@ -1,21 +1,21 @@
|
||||
#include "PromptPduDeserializer.h"
|
||||
|
||||
PromptPduDeserializer::PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize)
|
||||
: FileDirectiveDeserializer(pduBuf, maxSize) {}
|
||||
: FileDirectiveReader(pduBuf, maxSize) {}
|
||||
|
||||
cfdp::PromptResponseRequired PromptPduDeserializer::getPromptResponseRequired() const {
|
||||
return responseRequired;
|
||||
}
|
||||
|
||||
ReturnValue_t PromptPduDeserializer::parseData() {
|
||||
ReturnValue_t result = FileDirectiveDeserializer::parseData();
|
||||
ReturnValue_t result = FileDirectiveReader::parseData();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
size_t currentIdx = FileDirectiveDeserializer::getHeaderSize();
|
||||
if (FileDirectiveDeserializer::getWholePduSize() - currentIdx < 1) {
|
||||
if (FileDirectiveReader::getWholePduSize() <= FileDirectiveReader::getHeaderSize()) {
|
||||
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;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
#ifndef 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:
|
||||
PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize);
|
||||
|
||||
|
@ -2,24 +2,23 @@
|
||||
|
||||
PromptPduSerializer::PromptPduSerializer(PduConfig &conf,
|
||||
cfdp::PromptResponseRequired responseRequired)
|
||||
: FileDirectiveSerializer(conf, cfdp::FileDirectives::PROMPT, 1),
|
||||
: FileDirectiveCreator(conf, cfdp::FileDirectives::PROMPT, 1),
|
||||
responseRequired(responseRequired) {}
|
||||
|
||||
size_t PromptPduSerializer::getSerializedSize() const {
|
||||
return FileDirectiveSerializer::getWholePduSize();
|
||||
return FileDirectiveCreator::getWholePduSize();
|
||||
}
|
||||
|
||||
ReturnValue_t PromptPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const {
|
||||
ReturnValue_t result =
|
||||
FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness);
|
||||
ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
if (*size + 1 > maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
**buffer = this->responseRequired << 7;
|
||||
**buffer = responseRequired << 7;
|
||||
*buffer += 1;
|
||||
*size += 1;
|
||||
return result;
|
||||
|
@ -1,13 +1,13 @@
|
||||
#ifndef 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:
|
||||
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,
|
||||
Endianness streamEndianness) const override;
|
||||
|
@ -3,8 +3,8 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/cfdp/FileSize.h"
|
||||
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h"
|
||||
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
|
||||
#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
|
||||
#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
|
||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||
#include "fsfw/serialize/SerializeAdapter.h"
|
||||
|
||||
@ -22,7 +22,7 @@ TEST_CASE("CFDP Base", "[cfdp]") {
|
||||
size_t serSize = 0;
|
||||
|
||||
SECTION("File Directive") {
|
||||
auto fdSer = FileDirectiveSerializer(pduConf, FileDirectives::ACK, 4);
|
||||
auto fdSer = FileDirectiveCreator(pduConf, FileDirectives::ACK, 4);
|
||||
REQUIRE(fdSer.getSerializedSize() == 8);
|
||||
serTarget = serBuf.data();
|
||||
serSize = 0;
|
||||
@ -59,7 +59,7 @@ TEST_CASE("CFDP Base", "[cfdp]") {
|
||||
|
||||
deserTarget = serBuf.data();
|
||||
deserSize = 0;
|
||||
auto fdDeser = FileDirectiveDeserializer(deserTarget, serBuf.size());
|
||||
auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size());
|
||||
REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::NETWORK);
|
||||
fdDeser.setEndianness(SerializeIF::Endianness::MACHINE);
|
||||
REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE);
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <array>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "fsfw/cfdp/pdu/FileDataDeserializer.h"
|
||||
#include "fsfw/cfdp/pdu/FileDataSerializer.h"
|
||||
#include "fsfw/cfdp/pdu/FileDataCreator.h"
|
||||
#include "fsfw/cfdp/pdu/FileDataReader.h"
|
||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
@ -26,7 +26,7 @@ TEST_CASE("File Data PDU", "[cfdp][pdu]") {
|
||||
FileDataInfo info(offset, fileBuffer.data(), 10);
|
||||
|
||||
SECTION("Serialization") {
|
||||
FileDataSerializer serializer(pduConf, info);
|
||||
FileDataCreator serializer(pduConf, info);
|
||||
result =
|
||||
serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK);
|
||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||
@ -102,14 +102,14 @@ TEST_CASE("File Data PDU", "[cfdp][pdu]") {
|
||||
}
|
||||
|
||||
SECTION("Deserialization") {
|
||||
FileDataSerializer serializer(pduConf, info);
|
||||
FileDataCreator serializer(pduConf, info);
|
||||
result =
|
||||
serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK);
|
||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||
|
||||
FileSize emptyOffset;
|
||||
FileDataInfo emptyInfo(emptyOffset);
|
||||
FileDataDeserializer deserializer(fileDataBuffer.data(), fileDataBuffer.size(), emptyInfo);
|
||||
FileDataReader deserializer(fileDataBuffer.data(), fileDataBuffer.size(), emptyInfo);
|
||||
result = deserializer.parseData();
|
||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||
REQUIRE(deserializer.getWholePduSize() == 24);
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <array>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h"
|
||||
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
|
||||
#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
|
||||
#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
|
||||
|
||||
TEST_CASE("CFDP File Directive", "[cfdp]") {
|
||||
using namespace cfdp;
|
||||
@ -18,7 +18,7 @@ TEST_CASE("CFDP File Directive", "[cfdp]") {
|
||||
size_t serSize = 0;
|
||||
|
||||
SECTION("File Directive") {
|
||||
auto fdSer = FileDirectiveSerializer(pduConf, FileDirectives::ACK, 4);
|
||||
auto fdSer = FileDirectiveCreator(pduConf, FileDirectives::ACK, 4);
|
||||
REQUIRE(fdSer.getSerializedSize() == 8);
|
||||
serTarget = serBuf.data();
|
||||
serSize = 0;
|
||||
@ -55,7 +55,7 @@ TEST_CASE("CFDP File Directive", "[cfdp]") {
|
||||
|
||||
deserTarget = serBuf.data();
|
||||
deserSize = 0;
|
||||
auto fdDeser = FileDirectiveDeserializer(deserTarget, serBuf.size());
|
||||
auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size());
|
||||
REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::NETWORK);
|
||||
fdDeser.setEndianness(SerializeIF::Endianness::MACHINE);
|
||||
REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE);
|
||||
|
@ -25,7 +25,7 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") {
|
||||
result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK);
|
||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||
REQUIRE(serializer.getSerializedSize() == 19);
|
||||
REQUIRE(serializer.FileDirectiveSerializer::getSerializedSize() == 11);
|
||||
REQUIRE(serializer.FileDirectiveCreator::getSerializedSize() == 11);
|
||||
REQUIRE(sz == 19);
|
||||
REQUIRE(serializer.getPduDataFieldLen() == 9);
|
||||
REQUIRE(((nakBuffer[1] << 8) | nakBuffer[2]) == 0x09);
|
||||
|
@ -51,8 +51,10 @@ TEST_CASE("Prompt PDU", "[cfdp][pdu]") {
|
||||
REQUIRE(deserializer.getPromptResponseRequired() ==
|
||||
cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE);
|
||||
sz = deserializer.getWholePduSize();
|
||||
// Set invalid size
|
||||
rawBuf[2] = 1;
|
||||
result = deserializer.parseData();
|
||||
size_t sz2 = deserializer.getWholePduSize();
|
||||
REQUIRE(result == SerializeIF::STREAM_TOO_SHORT);
|
||||
rawBuf[2] = 2;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user