better names for CFDP components
This commit is contained in:
parent
b20e8a9679
commit
7fb9e14555
@ -1,7 +1,5 @@
|
|||||||
#include "CfdpRouter.h"
|
#include "CfdpRouter.h"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "fsfw/tcdistribution/definitions.h"
|
#include "fsfw/tcdistribution/definitions.h"
|
||||||
|
|
||||||
CfdpRouter::CfdpRouter(CfdpRouterCfg cfg) : TcDistributorBase(cfg.objectId), tmQueue(cfg.tmQueue) {}
|
CfdpRouter::CfdpRouter(CfdpRouterCfg cfg) : TcDistributorBase(cfg.objectId), tmQueue(cfg.tmQueue) {}
|
||||||
|
@ -2,8 +2,8 @@ target_sources(
|
|||||||
${LIB_FSFW_NAME}
|
${LIB_FSFW_NAME}
|
||||||
PRIVATE PduConfig.cpp
|
PRIVATE PduConfig.cpp
|
||||||
VarLenField.cpp
|
VarLenField.cpp
|
||||||
HeaderSerializer.cpp
|
HeaderCreator.cpp
|
||||||
HeaderDeserializer.cpp
|
HeaderReader.cpp
|
||||||
FileDirectiveDeserializer.cpp
|
FileDirectiveDeserializer.cpp
|
||||||
FileDirectiveSerializer.cpp
|
FileDirectiveSerializer.cpp
|
||||||
AckInfo.cpp
|
AckInfo.cpp
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
FileDataDeserializer::FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize,
|
FileDataDeserializer::FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize,
|
||||||
FileDataInfo& info)
|
FileDataInfo& info)
|
||||||
: HeaderDeserializer(pduBuf, maxSize), info(info) {}
|
: HeaderReader(pduBuf, maxSize), info(info) {}
|
||||||
|
|
||||||
ReturnValue_t FileDataDeserializer::parseData() {
|
ReturnValue_t FileDataDeserializer::parseData() {
|
||||||
ReturnValue_t result = HeaderDeserializer::parseData();
|
ReturnValue_t result = HeaderReader::parseData();
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
size_t currentIdx = HeaderDeserializer::getHeaderSize();
|
size_t currentIdx = HeaderReader::getHeaderSize();
|
||||||
const uint8_t* buf = rawPtr + currentIdx;
|
const uint8_t* buf = rawPtr + currentIdx;
|
||||||
size_t remSize = HeaderDeserializer::getWholePduSize() - currentIdx;
|
size_t remSize = HeaderReader::getWholePduSize() - currentIdx;
|
||||||
if (remSize < 1) {
|
if (remSize < 1) {
|
||||||
return SerializeIF::STREAM_TOO_SHORT;
|
return SerializeIF::STREAM_TOO_SHORT;
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#include "../definitions.h"
|
#include "../definitions.h"
|
||||||
#include "FileDataInfo.h"
|
#include "FileDataInfo.h"
|
||||||
#include "HeaderDeserializer.h"
|
#include "HeaderReader.h"
|
||||||
|
|
||||||
class FileDataDeserializer : public HeaderDeserializer {
|
class FileDataDeserializer : public HeaderReader {
|
||||||
public:
|
public:
|
||||||
FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info);
|
FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info);
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
FileDataSerializer::FileDataSerializer(PduConfig& conf, FileDataInfo& info)
|
FileDataSerializer::FileDataSerializer(PduConfig& conf, FileDataInfo& info)
|
||||||
: HeaderSerializer(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()),
|
: HeaderCreator(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) {
|
||||||
info(info) {
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,7 +15,7 @@ void FileDataSerializer::update() {
|
|||||||
|
|
||||||
ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||||
Endianness streamEndianness) const {
|
Endianness streamEndianness) const {
|
||||||
ReturnValue_t result = HeaderSerializer::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;
|
||||||
}
|
}
|
||||||
@ -51,5 +50,5 @@ ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t FileDataSerializer::getSerializedSize() const {
|
size_t FileDataSerializer::getSerializedSize() const {
|
||||||
return HeaderSerializer::getSerializedSize() + info.getSerializedSize(this->getLargeFileFlag());
|
return HeaderCreator::getSerializedSize() + info.getSerializedSize(this->getLargeFileFlag());
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#include "../definitions.h"
|
#include "../definitions.h"
|
||||||
#include "FileDataInfo.h"
|
#include "FileDataInfo.h"
|
||||||
#include "HeaderSerializer.h"
|
#include "HeaderCreator.h"
|
||||||
|
|
||||||
class FileDataSerializer : public HeaderSerializer {
|
class FileDataSerializer : public HeaderCreator {
|
||||||
public:
|
public:
|
||||||
FileDataSerializer(PduConfig& conf, FileDataInfo& info);
|
FileDataSerializer(PduConfig& conf, FileDataInfo& info);
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#include "FileDirectiveDeserializer.h"
|
#include "FileDirectiveDeserializer.h"
|
||||||
|
|
||||||
FileDirectiveDeserializer::FileDirectiveDeserializer(const uint8_t *pduBuf, size_t maxSize)
|
FileDirectiveDeserializer::FileDirectiveDeserializer(const uint8_t *pduBuf, size_t maxSize)
|
||||||
: HeaderDeserializer(pduBuf, maxSize) {}
|
: HeaderReader(pduBuf, maxSize) {}
|
||||||
|
|
||||||
cfdp::FileDirectives FileDirectiveDeserializer::getFileDirective() const { return fileDirective; }
|
cfdp::FileDirectives FileDirectiveDeserializer::getFileDirective() const { return fileDirective; }
|
||||||
|
|
||||||
ReturnValue_t FileDirectiveDeserializer::parseData() {
|
ReturnValue_t FileDirectiveDeserializer::parseData() {
|
||||||
ReturnValue_t result = HeaderDeserializer::parseData();
|
ReturnValue_t result = HeaderReader::parseData();
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -16,7 +16,7 @@ ReturnValue_t FileDirectiveDeserializer::parseData() {
|
|||||||
if (FileDirectiveDeserializer::getWholePduSize() > maxSize) {
|
if (FileDirectiveDeserializer::getWholePduSize() > maxSize) {
|
||||||
return SerializeIF::STREAM_TOO_SHORT;
|
return SerializeIF::STREAM_TOO_SHORT;
|
||||||
}
|
}
|
||||||
size_t currentIdx = HeaderDeserializer::getHeaderSize();
|
size_t currentIdx = HeaderReader::getHeaderSize();
|
||||||
if (not checkFileDirective(rawPtr[currentIdx])) {
|
if (not checkFileDirective(rawPtr[currentIdx])) {
|
||||||
return cfdp::INVALID_DIRECTIVE_FIELDS;
|
return cfdp::INVALID_DIRECTIVE_FIELDS;
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ ReturnValue_t FileDirectiveDeserializer::parseData() {
|
|||||||
|
|
||||||
size_t FileDirectiveDeserializer::getHeaderSize() const {
|
size_t FileDirectiveDeserializer::getHeaderSize() const {
|
||||||
// return size of header plus the directive byte
|
// return size of header plus the directive byte
|
||||||
return HeaderDeserializer::getHeaderSize() + 1;
|
return HeaderReader::getHeaderSize() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileDirectiveDeserializer::checkFileDirective(uint8_t rawByte) {
|
bool FileDirectiveDeserializer::checkFileDirective(uint8_t rawByte) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVEDESERIALIZER_H_
|
#define FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVEDESERIALIZER_H_
|
||||||
|
|
||||||
#include "../definitions.h"
|
#include "../definitions.h"
|
||||||
#include "fsfw/cfdp/pdu/HeaderDeserializer.h"
|
#include "fsfw/cfdp/pdu/HeaderReader.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class is used to deserialize a PDU file directive header from raw memory.
|
* @brief This class is used to deserialize a PDU file directive header from raw memory.
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* 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 HeaderDeserializer {
|
class FileDirectiveDeserializer : public HeaderReader {
|
||||||
public:
|
public:
|
||||||
FileDirectiveDeserializer(const uint8_t* pduBuf, size_t maxSize);
|
FileDirectiveDeserializer(const uint8_t* pduBuf, size_t maxSize);
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
FileDirectiveSerializer::FileDirectiveSerializer(PduConfig &pduConf,
|
FileDirectiveSerializer::FileDirectiveSerializer(PduConfig &pduConf,
|
||||||
cfdp::FileDirectives directiveCode,
|
cfdp::FileDirectives directiveCode,
|
||||||
size_t directiveParamFieldLen)
|
size_t directiveParamFieldLen)
|
||||||
: HeaderSerializer(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 FileDirectiveSerializer::getSerializedSize() const {
|
||||||
return HeaderSerializer::getSerializedSize() + 1;
|
return HeaderCreator::getSerializedSize() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||||
@ -18,7 +18,7 @@ ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size,
|
|||||||
if (FileDirectiveSerializer::getWholePduSize() > maxSize) {
|
if (FileDirectiveSerializer::getWholePduSize() > maxSize) {
|
||||||
return BUFFER_TOO_SHORT;
|
return BUFFER_TOO_SHORT;
|
||||||
}
|
}
|
||||||
ReturnValue_t result = HeaderSerializer::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;
|
||||||
}
|
}
|
||||||
@ -34,5 +34,5 @@ ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size,
|
|||||||
|
|
||||||
void FileDirectiveSerializer::setDirectiveDataFieldLen(size_t len) {
|
void FileDirectiveSerializer::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
|
||||||
HeaderSerializer::setPduDataFieldLen(len + 1);
|
HeaderCreator::setPduDataFieldLen(len + 1);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_
|
#ifndef FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_
|
||||||
#define FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_
|
#define FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_
|
||||||
|
|
||||||
#include "fsfw/cfdp/pdu/HeaderSerializer.h"
|
#include "fsfw/cfdp/pdu/HeaderCreator.h"
|
||||||
|
|
||||||
class FileDirectiveSerializer : public HeaderSerializer {
|
class FileDirectiveSerializer : public HeaderCreator {
|
||||||
public:
|
public:
|
||||||
FileDirectiveSerializer(PduConfig& pduConf, cfdp::FileDirectives directiveCode,
|
FileDirectiveSerializer(PduConfig& pduConf, cfdp::FileDirectives directiveCode,
|
||||||
size_t directiveParamFieldLen);
|
size_t directiveParamFieldLen);
|
||||||
|
114
src/fsfw/cfdp/pdu/HeaderCreator.cpp
Normal file
114
src/fsfw/cfdp/pdu/HeaderCreator.cpp
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
#include "HeaderCreator.h"
|
||||||
|
|
||||||
|
#include "HeaderReader.h"
|
||||||
|
|
||||||
|
HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen,
|
||||||
|
cfdp::SegmentMetadataFlag segmentMetadataFlag,
|
||||||
|
cfdp::SegmentationControl segCtrl)
|
||||||
|
: pduType(pduType),
|
||||||
|
segmentMetadataFlag(segmentMetadataFlag),
|
||||||
|
segmentationCtrl(segCtrl),
|
||||||
|
pduDataFieldLen(initPduDataFieldLen),
|
||||||
|
pduConf(pduConf) {}
|
||||||
|
|
||||||
|
ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||||
|
Endianness streamEndianness) const {
|
||||||
|
if (buffer == nullptr or size == nullptr) {
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
if (maxSize < this->getSerializedSize()) {
|
||||||
|
return BUFFER_TOO_SHORT;
|
||||||
|
}
|
||||||
|
**buffer = cfdp::VERSION_BITS | this->pduType << 4 | pduConf.direction << 3 | pduConf.mode << 2 |
|
||||||
|
pduConf.crcFlag << 1 | pduConf.largeFile;
|
||||||
|
*buffer += 1;
|
||||||
|
**buffer = (pduDataFieldLen & 0xff00) >> 8;
|
||||||
|
*buffer += 1;
|
||||||
|
**buffer = pduDataFieldLen & 0x00ff;
|
||||||
|
*buffer += 1;
|
||||||
|
**buffer = segmentationCtrl << 7 | pduConf.sourceId.getWidth() << 4 | segmentMetadataFlag << 3 |
|
||||||
|
pduConf.seqNum.getWidth();
|
||||||
|
*buffer += 1;
|
||||||
|
*size += 4;
|
||||||
|
ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t HeaderCreator::getSerializedSize() const {
|
||||||
|
size_t shit = pduConf.seqNum.getWidth() + pduConf.sourceId.getWidth() * 2 + 4;
|
||||||
|
return shit;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t HeaderCreator::deSerialize(const uint8_t **buffer, size_t *size,
|
||||||
|
Endianness streamEndianness) {
|
||||||
|
// We could implement this, but I prefer dedicated classes
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t HeaderCreator::getWholePduSize() const {
|
||||||
|
// Return size of header plus the PDU data field length
|
||||||
|
return pduDataFieldLen + HeaderCreator::getSerializedSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t HeaderCreator::getPduDataFieldLen() const { return pduDataFieldLen; }
|
||||||
|
|
||||||
|
void HeaderCreator::setPduDataFieldLen(size_t pduDataFieldLen_) {
|
||||||
|
pduDataFieldLen = pduDataFieldLen_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HeaderCreator::setPduType(cfdp::PduType pduType_) { pduType = pduType_; }
|
||||||
|
|
||||||
|
void HeaderCreator::setSegmentMetadataFlag(cfdp::SegmentMetadataFlag segmentMetadataFlag_) {
|
||||||
|
segmentMetadataFlag = segmentMetadataFlag_;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfdp::PduType HeaderCreator::getPduType() const { return pduType; }
|
||||||
|
|
||||||
|
cfdp::Direction HeaderCreator::getDirection() const { return pduConf.direction; }
|
||||||
|
|
||||||
|
cfdp::TransmissionModes HeaderCreator::getTransmissionMode() const { return pduConf.mode; }
|
||||||
|
|
||||||
|
bool HeaderCreator::getCrcFlag() const { return pduConf.crcFlag; }
|
||||||
|
|
||||||
|
bool HeaderCreator::getLargeFileFlag() const { return pduConf.largeFile; }
|
||||||
|
|
||||||
|
cfdp::SegmentationControl HeaderCreator::getSegmentationControl() const { return segmentationCtrl; }
|
||||||
|
|
||||||
|
cfdp::WidthInBytes HeaderCreator::getLenEntityIds() const { return pduConf.sourceId.getWidth(); }
|
||||||
|
|
||||||
|
cfdp::WidthInBytes HeaderCreator::getLenSeqNum() const { return pduConf.seqNum.getWidth(); }
|
||||||
|
|
||||||
|
cfdp::SegmentMetadataFlag HeaderCreator::getSegmentMetadataFlag() const {
|
||||||
|
return segmentMetadataFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HeaderCreator::getSourceId(cfdp::EntityId &sourceId) const { sourceId = pduConf.sourceId; }
|
||||||
|
|
||||||
|
void HeaderCreator::getDestId(cfdp::EntityId &destId) const { destId = pduConf.destId; }
|
||||||
|
|
||||||
|
void HeaderCreator::setSegmentationControl(cfdp::SegmentationControl segmentationControl) {
|
||||||
|
this->segmentationCtrl = segmentationControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HeaderCreator::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const {
|
||||||
|
seqNum = pduConf.seqNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HeaderCreator::hasSegmentMetadataFlag() const {
|
||||||
|
if (this->segmentMetadataFlag == cfdp::SegmentMetadataFlag::PRESENT) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
@ -6,9 +6,9 @@
|
|||||||
#include "PduHeaderIF.h"
|
#include "PduHeaderIF.h"
|
||||||
#include "fsfw/serialize/SerializeIF.h"
|
#include "fsfw/serialize/SerializeIF.h"
|
||||||
|
|
||||||
class HeaderSerializer : public SerializeIF, public PduHeaderIF {
|
class HeaderCreator : public SerializeIF, public PduHeaderIF {
|
||||||
public:
|
public:
|
||||||
HeaderSerializer(
|
HeaderCreator(
|
||||||
PduConfig& pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen,
|
PduConfig& pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen,
|
||||||
cfdp::SegmentMetadataFlag segmentMetadataFlag = cfdp::SegmentMetadataFlag::NOT_PRESENT,
|
cfdp::SegmentMetadataFlag segmentMetadataFlag = cfdp::SegmentMetadataFlag::NOT_PRESENT,
|
||||||
cfdp::SegmentationControl segCtrl =
|
cfdp::SegmentationControl segCtrl =
|
@ -1,20 +1,20 @@
|
|||||||
#include "HeaderDeserializer.h"
|
#include "HeaderReader.h"
|
||||||
|
|
||||||
#include <fsfw/serialize/SerializeAdapter.h>
|
#include <fsfw/serialize/SerializeAdapter.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
HeaderDeserializer::HeaderDeserializer(const uint8_t *pduBuf, size_t maxSize)
|
HeaderReader::HeaderReader(const uint8_t *pduBuf, size_t maxSize)
|
||||||
: rawPtr(pduBuf), maxSize(maxSize) {}
|
: rawPtr(pduBuf), maxSize(maxSize) {}
|
||||||
|
|
||||||
ReturnValue_t HeaderDeserializer::parseData() {
|
ReturnValue_t HeaderReader::parseData() {
|
||||||
if (maxSize < 7) {
|
if (maxSize < 7) {
|
||||||
return SerializeIF::STREAM_TOO_SHORT;
|
return SerializeIF::STREAM_TOO_SHORT;
|
||||||
}
|
}
|
||||||
return setData(const_cast<uint8_t *>(rawPtr), maxSize);
|
return setData(const_cast<uint8_t *>(rawPtr), maxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t HeaderDeserializer::setData(uint8_t *dataPtr, size_t maxSize, void *args) {
|
ReturnValue_t HeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) {
|
||||||
if (dataPtr == nullptr) {
|
if (dataPtr == nullptr) {
|
||||||
// Allowed for now
|
// Allowed for now
|
||||||
this->fixedHeader = nullptr;
|
this->fixedHeader = nullptr;
|
||||||
@ -26,76 +26,74 @@ ReturnValue_t HeaderDeserializer::setData(uint8_t *dataPtr, size_t maxSize, void
|
|||||||
cfdp::WidthInBytes widthSeqNum = getLenSeqNum();
|
cfdp::WidthInBytes widthSeqNum = getLenSeqNum();
|
||||||
seqNumRaw = static_cast<uint8_t *>(sourceIdRaw) + static_cast<uint8_t>(widthEntityIds);
|
seqNumRaw = static_cast<uint8_t *>(sourceIdRaw) + static_cast<uint8_t>(widthEntityIds);
|
||||||
destIdRaw = static_cast<uint8_t *>(seqNumRaw) + static_cast<uint8_t>(widthSeqNum);
|
destIdRaw = static_cast<uint8_t *>(seqNumRaw) + static_cast<uint8_t>(widthSeqNum);
|
||||||
this->maxSize = maxSize;
|
maxSize = maxSize_;
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t HeaderDeserializer::getHeaderSize() const {
|
size_t HeaderReader::getHeaderSize() const {
|
||||||
if (fixedHeader != nullptr) {
|
if (fixedHeader != nullptr) {
|
||||||
return getLenEntityIds() * 2 + getLenSeqNum() + 4;
|
return getLenEntityIds() * 2 + getLenSeqNum() + 4;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t HeaderDeserializer::getPduDataFieldLen() const {
|
size_t HeaderReader::getPduDataFieldLen() const {
|
||||||
uint16_t pduFiedlLen = (fixedHeader->pduDataFieldLenH << 8) | fixedHeader->pduDataFieldLenL;
|
uint16_t pduFiedlLen = (fixedHeader->pduDataFieldLenH << 8) | fixedHeader->pduDataFieldLenL;
|
||||||
return pduFiedlLen;
|
return pduFiedlLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t HeaderDeserializer::getWholePduSize() const {
|
size_t HeaderReader::getWholePduSize() const { return getPduDataFieldLen() + getHeaderSize(); }
|
||||||
return getPduDataFieldLen() + getHeaderSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
cfdp::PduType HeaderDeserializer::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);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfdp::Direction HeaderDeserializer::getDirection() const {
|
cfdp::Direction HeaderReader::getDirection() const {
|
||||||
return static_cast<cfdp::Direction>((fixedHeader->firstByte >> 3) & 0x01);
|
return static_cast<cfdp::Direction>((fixedHeader->firstByte >> 3) & 0x01);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfdp::TransmissionModes HeaderDeserializer::getTransmissionMode() const {
|
cfdp::TransmissionModes HeaderReader::getTransmissionMode() const {
|
||||||
return static_cast<cfdp::TransmissionModes>((fixedHeader->firstByte >> 2) & 0x01);
|
return static_cast<cfdp::TransmissionModes>((fixedHeader->firstByte >> 2) & 0x01);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HeaderDeserializer::getCrcFlag() const { return (fixedHeader->firstByte >> 1) & 0x01; }
|
bool HeaderReader::getCrcFlag() const { return (fixedHeader->firstByte >> 1) & 0x01; }
|
||||||
|
|
||||||
bool HeaderDeserializer::getLargeFileFlag() const { return fixedHeader->firstByte & 0x01; }
|
bool HeaderReader::getLargeFileFlag() const { return fixedHeader->firstByte & 0x01; }
|
||||||
|
|
||||||
cfdp::SegmentationControl HeaderDeserializer::getSegmentationControl() const {
|
cfdp::SegmentationControl HeaderReader::getSegmentationControl() const {
|
||||||
return static_cast<cfdp::SegmentationControl>((fixedHeader->fourthByte >> 7) & 0x01);
|
return static_cast<cfdp::SegmentationControl>((fixedHeader->fourthByte >> 7) & 0x01);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfdp::WidthInBytes HeaderDeserializer::getLenEntityIds() const {
|
cfdp::WidthInBytes HeaderReader::getLenEntityIds() const {
|
||||||
return static_cast<cfdp::WidthInBytes>((fixedHeader->fourthByte >> 4) & 0x07);
|
return static_cast<cfdp::WidthInBytes>((fixedHeader->fourthByte >> 4) & 0x07);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfdp::WidthInBytes HeaderDeserializer::getLenSeqNum() const {
|
cfdp::WidthInBytes HeaderReader::getLenSeqNum() const {
|
||||||
return static_cast<cfdp::WidthInBytes>(fixedHeader->fourthByte & 0x07);
|
return static_cast<cfdp::WidthInBytes>(fixedHeader->fourthByte & 0x07);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfdp::SegmentMetadataFlag HeaderDeserializer::getSegmentMetadataFlag() const {
|
cfdp::SegmentMetadataFlag HeaderReader::getSegmentMetadataFlag() const {
|
||||||
return static_cast<cfdp::SegmentMetadataFlag>((fixedHeader->fourthByte >> 3) & 0x01);
|
return static_cast<cfdp::SegmentMetadataFlag>((fixedHeader->fourthByte >> 3) & 0x01);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeaderDeserializer::getSourceId(cfdp::EntityId &sourceId) const {
|
void HeaderReader::getSourceId(cfdp::EntityId &sourceId) const {
|
||||||
assignVarLenField(dynamic_cast<cfdp::VarLenField *>(&sourceId), getLenEntityIds(),
|
assignVarLenField(dynamic_cast<cfdp::VarLenField *>(&sourceId), getLenEntityIds(),
|
||||||
this->sourceIdRaw);
|
this->sourceIdRaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeaderDeserializer::getDestId(cfdp::EntityId &destId) const {
|
void HeaderReader::getDestId(cfdp::EntityId &destId) const {
|
||||||
assignVarLenField(dynamic_cast<cfdp::VarLenField *>(&destId), getLenEntityIds(), this->destIdRaw);
|
assignVarLenField(dynamic_cast<cfdp::VarLenField *>(&destId), getLenEntityIds(), this->destIdRaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeaderDeserializer::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const {
|
void HeaderReader::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const {
|
||||||
assignVarLenField(dynamic_cast<cfdp::VarLenField *>(&seqNum), getLenSeqNum(), this->seqNumRaw);
|
assignVarLenField(dynamic_cast<cfdp::VarLenField *>(&seqNum), getLenSeqNum(), this->seqNumRaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeaderDeserializer::assignVarLenField(cfdp::VarLenField *field, cfdp::WidthInBytes width,
|
void HeaderReader::assignVarLenField(cfdp::VarLenField *field, cfdp::WidthInBytes width,
|
||||||
void *sourcePtr) const {
|
void *sourcePtr) const {
|
||||||
switch (width) {
|
switch (width) {
|
||||||
case (cfdp::WidthInBytes::ONE_BYTE): {
|
case (cfdp::WidthInBytes::ONE_BYTE): {
|
||||||
uint8_t *fieldTyped = static_cast<uint8_t *>(sourcePtr);
|
auto *fieldTyped = static_cast<uint8_t *>(sourcePtr);
|
||||||
field->setValue(width, *fieldTyped);
|
field->setValue(width, *fieldTyped);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -118,11 +116,15 @@ void HeaderDeserializer::assignVarLenField(cfdp::VarLenField *field, cfdp::Width
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t HeaderDeserializer::getMaxSize() const { return maxSize; }
|
size_t HeaderReader::getMaxSize() const { return maxSize; }
|
||||||
|
|
||||||
bool HeaderDeserializer::hasSegmentMetadataFlag() const {
|
bool HeaderReader::hasSegmentMetadataFlag() const {
|
||||||
if (this->getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT) {
|
if (this->getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t HeaderReader::setData(const uint8_t *dataPtr, size_t maxSize_) {
|
||||||
|
return setData(const_cast<uint8_t *>(dataPtr), maxSize_, nullptr);
|
||||||
|
}
|
@ -23,7 +23,7 @@ struct PduHeaderFixedStruct {
|
|||||||
* 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 HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF {
|
class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Initialize a PDU header from raw data. This is a zero-copy implementation and #parseData
|
* Initialize a PDU header from raw data. This is a zero-copy implementation and #parseData
|
||||||
@ -31,7 +31,7 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF
|
|||||||
* @param pduBuf
|
* @param pduBuf
|
||||||
* @param maxSize
|
* @param maxSize
|
||||||
*/
|
*/
|
||||||
HeaderDeserializer(const uint8_t* pduBuf, size_t maxSize);
|
HeaderReader(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.
|
||||||
@ -41,21 +41,21 @@ class HeaderDeserializer : 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();
|
||||||
size_t getHeaderSize() const;
|
[[nodiscard]] size_t getHeaderSize() const;
|
||||||
|
|
||||||
size_t getPduDataFieldLen() const override;
|
[[nodiscard]] size_t getPduDataFieldLen() const override;
|
||||||
size_t getWholePduSize() const override;
|
[[nodiscard]] size_t getWholePduSize() const override;
|
||||||
|
|
||||||
cfdp::PduType getPduType() const override;
|
[[nodiscard]] cfdp::PduType getPduType() const override;
|
||||||
cfdp::Direction getDirection() const override;
|
[[nodiscard]] cfdp::Direction getDirection() const override;
|
||||||
cfdp::TransmissionModes getTransmissionMode() const override;
|
[[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override;
|
||||||
bool getCrcFlag() const override;
|
[[nodiscard]] bool getCrcFlag() const override;
|
||||||
bool getLargeFileFlag() const override;
|
[[nodiscard]] bool getLargeFileFlag() const override;
|
||||||
cfdp::SegmentationControl getSegmentationControl() const override;
|
[[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const override;
|
||||||
cfdp::WidthInBytes getLenEntityIds() const override;
|
[[nodiscard]] cfdp::WidthInBytes getLenEntityIds() const override;
|
||||||
cfdp::WidthInBytes getLenSeqNum() const override;
|
[[nodiscard]] cfdp::WidthInBytes getLenSeqNum() const override;
|
||||||
cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override;
|
[[nodiscard]] cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override;
|
||||||
bool hasSegmentMetadataFlag() const override;
|
[[nodiscard]] bool hasSegmentMetadataFlag() const override;
|
||||||
|
|
||||||
void getSourceId(cfdp::EntityId& sourceId) const override;
|
void getSourceId(cfdp::EntityId& sourceId) const override;
|
||||||
void getDestId(cfdp::EntityId& destId) const override;
|
void getDestId(cfdp::EntityId& destId) const override;
|
||||||
@ -63,6 +63,8 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF
|
|||||||
|
|
||||||
ReturnValue_t deserResult = HasReturnvaluesIF::RETURN_OK;
|
ReturnValue_t deserResult = HasReturnvaluesIF::RETURN_OK;
|
||||||
|
|
||||||
|
[[nodiscard]] size_t getMaxSize() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can also be used to reset the pointer to a nullptr, but the getter functions will not
|
* Can also be used to reset the pointer to a nullptr, but the getter functions will not
|
||||||
* perform nullptr checks!
|
* perform nullptr checks!
|
||||||
@ -71,9 +73,7 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF
|
|||||||
* @param args
|
* @param args
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) override;
|
ReturnValue_t setData(const uint8_t* dataPtr, size_t maxSize);
|
||||||
|
|
||||||
size_t getMaxSize() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PduHeaderFixedStruct* fixedHeader = nullptr;
|
PduHeaderFixedStruct* fixedHeader = nullptr;
|
||||||
@ -81,6 +81,15 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF
|
|||||||
size_t maxSize = 0;
|
size_t maxSize = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* Can also be used to reset the pointer to a nullptr, but the getter functions will not
|
||||||
|
* perform nullptr checks!
|
||||||
|
* @param dataPtr
|
||||||
|
* @param maxSize
|
||||||
|
* @param args
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args) override;
|
||||||
void assignVarLenField(cfdp::VarLenField* field, cfdp::WidthInBytes width, void* sourcePtr) const;
|
void assignVarLenField(cfdp::VarLenField* field, cfdp::WidthInBytes width, void* sourcePtr) const;
|
||||||
void* sourceIdRaw = nullptr;
|
void* sourceIdRaw = nullptr;
|
||||||
void* seqNumRaw = nullptr;
|
void* seqNumRaw = nullptr;
|
@ -1,117 +0,0 @@
|
|||||||
#include "HeaderSerializer.h"
|
|
||||||
|
|
||||||
#include "HeaderDeserializer.h"
|
|
||||||
|
|
||||||
HeaderSerializer::HeaderSerializer(PduConfig &pduConf, cfdp::PduType pduType,
|
|
||||||
size_t initPduDataFieldLen,
|
|
||||||
cfdp::SegmentMetadataFlag segmentMetadataFlag,
|
|
||||||
cfdp::SegmentationControl segCtrl)
|
|
||||||
: pduType(pduType),
|
|
||||||
segmentMetadataFlag(segmentMetadataFlag),
|
|
||||||
segmentationCtrl(segCtrl),
|
|
||||||
pduDataFieldLen(initPduDataFieldLen),
|
|
||||||
pduConf(pduConf) {}
|
|
||||||
|
|
||||||
ReturnValue_t HeaderSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
|
||||||
Endianness streamEndianness) const {
|
|
||||||
if (buffer == nullptr or size == nullptr) {
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
}
|
|
||||||
if (maxSize < this->getSerializedSize()) {
|
|
||||||
return BUFFER_TOO_SHORT;
|
|
||||||
}
|
|
||||||
**buffer = cfdp::VERSION_BITS | this->pduType << 4 | pduConf.direction << 3 | pduConf.mode << 2 |
|
|
||||||
pduConf.crcFlag << 1 | pduConf.largeFile;
|
|
||||||
*buffer += 1;
|
|
||||||
**buffer = (pduDataFieldLen & 0xff00) >> 8;
|
|
||||||
*buffer += 1;
|
|
||||||
**buffer = pduDataFieldLen & 0x00ff;
|
|
||||||
*buffer += 1;
|
|
||||||
**buffer = segmentationCtrl << 7 | pduConf.sourceId.getWidth() << 4 | segmentMetadataFlag << 3 |
|
|
||||||
pduConf.seqNum.getWidth();
|
|
||||||
*buffer += 1;
|
|
||||||
*size += 4;
|
|
||||||
ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t HeaderSerializer::getSerializedSize() const {
|
|
||||||
size_t shit = pduConf.seqNum.getWidth() + pduConf.sourceId.getWidth() * 2 + 4;
|
|
||||||
return shit;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t HeaderSerializer::deSerialize(const uint8_t **buffer, size_t *size,
|
|
||||||
Endianness streamEndianness) {
|
|
||||||
// We could implement this, but I prefer dedicated classes
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t HeaderSerializer::getWholePduSize() const {
|
|
||||||
// Return size of header plus the PDU data field length
|
|
||||||
return pduDataFieldLen + HeaderSerializer::getSerializedSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t HeaderSerializer::getPduDataFieldLen() const { return pduDataFieldLen; }
|
|
||||||
|
|
||||||
void HeaderSerializer::setPduDataFieldLen(size_t pduDataFieldLen) {
|
|
||||||
this->pduDataFieldLen = pduDataFieldLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeaderSerializer::setPduType(cfdp::PduType pduType) { this->pduType = pduType; }
|
|
||||||
|
|
||||||
void HeaderSerializer::setSegmentMetadataFlag(cfdp::SegmentMetadataFlag segmentMetadataFlag) {
|
|
||||||
this->segmentMetadataFlag = segmentMetadataFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfdp::PduType HeaderSerializer::getPduType() const { return pduType; }
|
|
||||||
|
|
||||||
cfdp::Direction HeaderSerializer::getDirection() const { return pduConf.direction; }
|
|
||||||
|
|
||||||
cfdp::TransmissionModes HeaderSerializer::getTransmissionMode() const { return pduConf.mode; }
|
|
||||||
|
|
||||||
bool HeaderSerializer::getCrcFlag() const { return pduConf.crcFlag; }
|
|
||||||
|
|
||||||
bool HeaderSerializer::getLargeFileFlag() const { return pduConf.largeFile; }
|
|
||||||
|
|
||||||
cfdp::SegmentationControl HeaderSerializer::getSegmentationControl() const {
|
|
||||||
return segmentationCtrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfdp::WidthInBytes HeaderSerializer::getLenEntityIds() const { return pduConf.sourceId.getWidth(); }
|
|
||||||
|
|
||||||
cfdp::WidthInBytes HeaderSerializer::getLenSeqNum() const { return pduConf.seqNum.getWidth(); }
|
|
||||||
|
|
||||||
cfdp::SegmentMetadataFlag HeaderSerializer::getSegmentMetadataFlag() const {
|
|
||||||
return segmentMetadataFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeaderSerializer::getSourceId(cfdp::EntityId &sourceId) const { sourceId = pduConf.sourceId; }
|
|
||||||
|
|
||||||
void HeaderSerializer::getDestId(cfdp::EntityId &destId) const { destId = pduConf.destId; }
|
|
||||||
|
|
||||||
void HeaderSerializer::setSegmentationControl(cfdp::SegmentationControl segmentationControl) {
|
|
||||||
this->segmentationCtrl = segmentationControl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeaderSerializer::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const {
|
|
||||||
seqNum = pduConf.seqNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HeaderSerializer::hasSegmentMetadataFlag() const {
|
|
||||||
if (this->segmentMetadataFlag == cfdp::SegmentMetadataFlag::PRESENT) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
@ -13,20 +13,20 @@
|
|||||||
*/
|
*/
|
||||||
class PduHeaderIF {
|
class PduHeaderIF {
|
||||||
public:
|
public:
|
||||||
virtual ~PduHeaderIF(){};
|
virtual ~PduHeaderIF() = default;
|
||||||
|
|
||||||
virtual size_t getWholePduSize() const = 0;
|
[[nodiscard]] virtual size_t getWholePduSize() const = 0;
|
||||||
virtual size_t getPduDataFieldLen() const = 0;
|
[[nodiscard]] virtual size_t getPduDataFieldLen() const = 0;
|
||||||
virtual cfdp::PduType getPduType() const = 0;
|
[[nodiscard]] virtual cfdp::PduType getPduType() const = 0;
|
||||||
virtual cfdp::Direction getDirection() const = 0;
|
[[nodiscard]] virtual cfdp::Direction getDirection() const = 0;
|
||||||
virtual cfdp::TransmissionModes getTransmissionMode() const = 0;
|
[[nodiscard]] virtual cfdp::TransmissionModes getTransmissionMode() const = 0;
|
||||||
virtual bool getCrcFlag() const = 0;
|
[[nodiscard]] virtual bool getCrcFlag() const = 0;
|
||||||
virtual bool getLargeFileFlag() const = 0;
|
[[nodiscard]] virtual bool getLargeFileFlag() const = 0;
|
||||||
virtual cfdp::SegmentationControl getSegmentationControl() const = 0;
|
[[nodiscard]] virtual cfdp::SegmentationControl getSegmentationControl() const = 0;
|
||||||
virtual cfdp::WidthInBytes getLenEntityIds() const = 0;
|
[[nodiscard]] virtual cfdp::WidthInBytes getLenEntityIds() const = 0;
|
||||||
virtual cfdp::WidthInBytes getLenSeqNum() const = 0;
|
[[nodiscard]] virtual cfdp::WidthInBytes getLenSeqNum() const = 0;
|
||||||
virtual cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const = 0;
|
[[nodiscard]] virtual cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const = 0;
|
||||||
virtual bool hasSegmentMetadataFlag() const = 0;
|
[[nodiscard]] virtual bool hasSegmentMetadataFlag() const = 0;
|
||||||
virtual void getSourceId(cfdp::EntityId& sourceId) const = 0;
|
virtual void getSourceId(cfdp::EntityId& sourceId) const = 0;
|
||||||
virtual void getDestId(cfdp::EntityId& destId) const = 0;
|
virtual void getDestId(cfdp::EntityId& destId) const = 0;
|
||||||
virtual void getTransactionSeqNum(cfdp::TransactionSeqNum& seqNum) const = 0;
|
virtual void getTransactionSeqNum(cfdp::TransactionSeqNum& seqNum) const = 0;
|
||||||
|
@ -7,7 +7,7 @@ class PromptPduDeserializer : public FileDirectiveDeserializer {
|
|||||||
public:
|
public:
|
||||||
PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize);
|
PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize);
|
||||||
|
|
||||||
cfdp::PromptResponseRequired getPromptResponseRequired() const;
|
[[nodiscard]] cfdp::PromptResponseRequired getPromptResponseRequired() const;
|
||||||
ReturnValue_t parseData() override;
|
ReturnValue_t parseData() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "fsfw/cfdp/pdu/HeaderDeserializer.h"
|
#include "fsfw/cfdp/pdu/HeaderCreator.h"
|
||||||
#include "fsfw/cfdp/pdu/HeaderSerializer.h"
|
#include "fsfw/cfdp/pdu/HeaderReader.h"
|
||||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
TEST_CASE("CFDP Header", "[cfdp]") {
|
TEST_CASE("CFDP Header", "[cfdp]") {
|
||||||
@ -19,7 +19,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
|
|||||||
size_t serSize = 0;
|
size_t serSize = 0;
|
||||||
|
|
||||||
SECTION("Header Serialization") {
|
SECTION("Header Serialization") {
|
||||||
auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0);
|
auto headerSerializer = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0);
|
||||||
const uint8_t** dummyPtr = nullptr;
|
const uint8_t** dummyPtr = nullptr;
|
||||||
ReturnValue_t deserResult =
|
ReturnValue_t deserResult =
|
||||||
headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK);
|
headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK);
|
||||||
@ -186,7 +186,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
|
|||||||
SECTION("Header Deserialization") {
|
SECTION("Header Deserialization") {
|
||||||
// We unittested the serializer before, so we can use it now to generate valid raw CFDP
|
// We unittested the serializer before, so we can use it now to generate valid raw CFDP
|
||||||
// data
|
// data
|
||||||
auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0);
|
auto headerSerializer = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0);
|
||||||
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
|
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
|
||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
REQUIRE(result == result::OK);
|
REQUIRE(result == result::OK);
|
||||||
@ -196,7 +196,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
|
|||||||
REQUIRE(serBuf[3] == 0b00010001);
|
REQUIRE(serBuf[3] == 0b00010001);
|
||||||
REQUIRE(serSize == 7);
|
REQUIRE(serSize == 7);
|
||||||
// Deser call not strictly necessary
|
// Deser call not strictly necessary
|
||||||
auto headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size());
|
auto headerDeser = HeaderReader(serBuf.data(), serBuf.size());
|
||||||
|
|
||||||
ReturnValue_t serResult = headerDeser.parseData();
|
ReturnValue_t serResult = headerDeser.parseData();
|
||||||
REQUIRE(serResult == result::OK);
|
REQUIRE(serResult == result::OK);
|
||||||
@ -231,7 +231,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
|
|||||||
serSize = 0;
|
serSize = 0;
|
||||||
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
|
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
|
||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size());
|
headerDeser = HeaderReader(serBuf.data(), serBuf.size());
|
||||||
|
|
||||||
result = headerDeser.parseData();
|
result = headerDeser.parseData();
|
||||||
REQUIRE(result == result::OK);
|
REQUIRE(result == result::OK);
|
||||||
|
Loading…
Reference in New Issue
Block a user