implemented fle data PDUs

This commit is contained in:
Robin Müller 2023-07-19 13:44:52 +02:00
parent 896b7a7358
commit 1561b9a247
Signed by: muellerr
GPG Key ID: 407F9B00F858F270
28 changed files with 135 additions and 104 deletions

View File

@ -8,11 +8,11 @@
namespace cfdp {
struct FileSize : public SerializeIF {
struct Fss : public SerializeIF {
public:
FileSize() = default;
Fss() = default;
explicit FileSize(uint64_t fileSize, bool isLarge = false) { setFileSize(fileSize, isLarge); };
explicit Fss(uint64_t fileSize, bool isLarge = false) { setFileSize(fileSize, isLarge); };
[[nodiscard]] uint64_t value() const { return fileSize; }

View File

@ -158,7 +158,7 @@ ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info)
// TODO: This is not a CFDP error. Event and/or warning?
return constAccessorPair.first;
}
cfdp::FileSize offset;
cfdp::Fss offset;
FileDataInfo fdInfo(offset);
FileDataReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(), fdInfo);
ReturnValue_t result = reader.parseData();

View File

@ -131,7 +131,7 @@ class DestHandler {
uint16_t vfsErrorCount = 0;
std::vector<char> sourceName;
std::vector<char> destName;
cfdp::FileSize fileSize;
cfdp::Fss fileSize;
TransactionId transactionId;
PduConfig pduConf;
ConditionCode conditionCode = ConditionCode::NO_ERROR;

View File

@ -125,6 +125,9 @@ ReturnValue_t cfdp::SourceHandler::putRequest(PutRequestFull& putRequest, Remote
if (!sourceParams.user.vfs.fileExists(params)) {
return FILE_DOES_NOT_EXIST;
}
if (cfg.maxFileSegmentLen > fileBuf.size() or cfg.maxFileSegmentLen == 0) {
return FILE_SEGMENT_LEN_INVALID;
}
transactionParams.closureRequested = putRequest.closureRequested;
transactionParams.pduConf.mode = putRequest.transmissionMode;
transactionParams.pduConf.destId = putRequest.destId;
@ -138,52 +141,60 @@ ReturnValue_t cfdp::SourceHandler::putRequest(PutRequestFull& putRequest, Remote
state = cfdp::CfdpState::BUSY_CLASS_1_NACKED;
}
step = TransactionStep::IDLE;
size_t fileSize = 0;
uint64_t fileSize = 0;
sourceParams.user.vfs.getFileSize(params, fileSize);
transactionParams.pduConf.largeFile = false;
if (fileSize > UINT32_MAX) {
transactionParams.pduConf.largeFile = true;
}
transactionParams.fileSize.setFileSize(fileSize, transactionParams.pduConf.largeFile);
currentRemoteCfg = cfg;
transactionParams.remoteCfg = cfg;
return OK;
}
ReturnValue_t cfdp::SourceHandler::prepareAndSendMetadataPdu() {
cfdp::StringLv sourceName(transactionParams.sourceName.data(), transactionParams.sourceNameSize);
cfdp::StringLv destName(transactionParams.sourceName.data(), transactionParams.sourceNameSize);
cfdp::StringLv destName(transactionParams.destName.data(), transactionParams.destNameSize);
auto metadataInfo = MetadataInfo(transactionParams.fileSize, sourceName, destName);
auto metadataPdu = MetadataPduCreator(transactionParams.pduConf, metadataInfo);
uint8_t* dataPtr;
store_address_t storeId;
ReturnValue_t result =
fsfwParams.tcStore->getFreeElement(&storeId, metadataPdu.getSerializedSize(), &dataPtr);
if (result != OK) {
// TODO: Better error handling?
return result;
}
size_t serializedLen = 0;
result = metadataPdu.serializeBe(dataPtr, serializedLen, metadataPdu.getSerializedSize());
if (result != OK) {
return result;
}
TmTcMessage tcMsg(storeId);
result =
fsfwParams.msgQueue->sendMessage(fsfwParams.packetDest.getReportReceptionQueue(), &tcMsg);
if (result != OK) {
return result;
}
sendGenericPdu(metadataPdu);
// Advance FSM if everything works
step = TransactionStep::SENDING_FILE_DATA;
return OK;
}
ReturnValue_t cfdp::SourceHandler::prepareAndSendNextFileDataPdu() {
// TODO: Implement
// auto fileDataInfo = FileDataInfo(transactionParams.fileSize);
// auto fileDataPdu = FileDataCreator();
// Advance FSM after all file data PDUs were sent
step = TransactionStep::SENDING_EOF;
cfdp::Fss offset(transactionParams.progress);
uint64_t readLen;
uint64_t fileSize = transactionParams.fileSize.value();
if (fileSize == 0) {
// We are done, no need to send file data PDUs for an empty file.
step = TransactionStep::SENDING_EOF;
return OK;
}
if (fileSize < transactionParams.remoteCfg.maxFileSegmentLen) {
readLen = transactionParams.fileSize.value();
} else {
if (transactionParams.progress + transactionParams.remoteCfg.maxFileSegmentLen > fileSize) {
readLen = fileSize - transactionParams.progress;
} else {
readLen = transactionParams.remoteCfg.maxFileSegmentLen;
}
}
FileOpParams fileParams(transactionParams.sourceName.data(), readLen);
ReturnValue_t result =
sourceParams.user.vfs.readFromFile(fileParams, fileBuf.data(), fileBuf.size());
if (result != returnvalue::OK) {
return result;
}
auto fileDataInfo = FileDataInfo(offset, fileBuf.data(), readLen);
auto fileDataPdu = FileDataCreator(transactionParams.pduConf, fileDataInfo);
sendGenericPdu(fileDataPdu);
transactionParams.progress += readLen;
if (transactionParams.progress >= fileSize) {
// Advance FSM after all file data PDUs were sent.
step = TransactionStep::SENDING_EOF;
}
return OK;
}
@ -213,3 +224,21 @@ ReturnValue_t cfdp::SourceHandler::initialize() {
}
return OK;
}
ReturnValue_t cfdp::SourceHandler::sendGenericPdu(const SerializeIF& pdu) const {
uint8_t* dataPtr;
store_address_t storeId;
ReturnValue_t result =
fsfwParams.tcStore->getFreeElement(&storeId, pdu.getSerializedSize(), &dataPtr);
if (result != OK) {
// TODO: Better error handling?
return result;
}
size_t serializedLen = 0;
result = pdu.serializeBe(dataPtr, serializedLen, pdu.getSerializedSize());
if (result != OK) {
return result;
}
TmTcMessage tcMsg(storeId);
return fsfwParams.msgQueue->sendMessage(fsfwParams.packetDest.getReportReceptionQueue(), &tcMsg);
}

View File

@ -6,7 +6,7 @@
#include "UserBase.h"
#include "defs.h"
#include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/Fss.h"
#include "fsfw/cfdp/handler/mib.h"
#include "fsfw/events/EventReportingProxyIF.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
@ -64,16 +64,17 @@ class SourceHandler {
size_t sourceNameSize = 0;
std::array<char, 524> destName{};
size_t destNameSize = 0;
cfdp::FileSize fileSize;
size_t currentFilePos = 0;
cfdp::Fss fileSize;
size_t progress = 0;
bool closureRequested = false;
RemoteEntityCfg remoteCfg;
PduConfig pduConf;
} transactionParams;
cfdp::CfdpState state = cfdp::CfdpState::IDLE;
TransactionStep step = TransactionStep::IDLE;
std::array<uint8_t, 4096> fileBuf{};
SourceHandlerParams sourceParams;
cfdp::FsfwParams fsfwParams;
RemoteEntityCfg currentRemoteCfg;
FsmResult fsmResult;
FsmResult& fsmNacked();
@ -81,6 +82,8 @@ class SourceHandler {
ReturnValue_t prepareAndSendMetadataPdu();
ReturnValue_t prepareAndSendNextFileDataPdu();
ReturnValue_t prepareAndSendEofPdu();
ReturnValue_t sendGenericPdu(const SerializeIF& pdu) const;
};
} // namespace cfdp

View File

@ -74,6 +74,7 @@ static constexpr Event FILENAME_TOO_LARGE_ERROR = event::makeEvent(SSID, 4, seve
static constexpr ReturnValue_t SOURCE_TRANSACTION_PENDING = returnvalue::makeCode(CID, 0);
static constexpr ReturnValue_t FILE_DOES_NOT_EXIST = returnvalue::makeCode(CID, 1);
static constexpr ReturnValue_t FILE_SEGMENT_LEN_INVALID = returnvalue::makeCode(CID, 1);
} // namespace cfdp
#endif // FSFW_CFDP_HANDLER_DEFS_H

View File

@ -1,6 +1,6 @@
#include "EofInfo.h"
EofInfo::EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::FileSize fileSize,
EofInfo::EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::Fss fileSize,
EntityIdTlv* faultLoc)
: conditionCode(conditionCode), checksum(checksum), fileSize(fileSize), faultLoc(faultLoc) {}
@ -16,7 +16,7 @@ cfdp::ConditionCode EofInfo::getConditionCode() const { return conditionCode; }
EntityIdTlv* EofInfo::getFaultLoc() const { return faultLoc; }
cfdp::FileSize& EofInfo::getFileSize() { return fileSize; }
cfdp::Fss& EofInfo::getFileSize() { return fileSize; }
void EofInfo::setChecksum(uint32_t checksum) { this->checksum = checksum; }

View File

@ -1,14 +1,14 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_EOFINFO_H_
#define FSFW_SRC_FSFW_CFDP_PDU_EOFINFO_H_
#include "../FileSize.h"
#include "../Fss.h"
#include "../definitions.h"
#include "fsfw/cfdp/tlv/EntityIdTlv.h"
struct EofInfo {
public:
explicit EofInfo(EntityIdTlv* faultLoc = nullptr);
EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::FileSize fileSize,
EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::Fss fileSize,
EntityIdTlv* faultLoc = nullptr);
size_t getSerializedSize(bool fssLarge = false);
@ -17,7 +17,7 @@ struct EofInfo {
[[nodiscard]] cfdp::ConditionCode getConditionCode() const;
[[nodiscard]] EntityIdTlv* getFaultLoc() const;
cfdp::FileSize& getFileSize();
cfdp::Fss& getFileSize();
void setChecksum(uint32_t checksum);
void setConditionCode(cfdp::ConditionCode conditionCode);
void setFaultLoc(EntityIdTlv* faultLoc);
@ -26,7 +26,7 @@ struct EofInfo {
private:
cfdp::ConditionCode conditionCode;
uint32_t checksum;
cfdp::FileSize fileSize;
cfdp::Fss fileSize;
EntityIdTlv* faultLoc = nullptr;
};

View File

@ -37,7 +37,7 @@ ReturnValue_t FileDataCreator::serialize(uint8_t** buffer, size_t* size, size_t
*buffer += segmentMetadataLen;
*size += segmentMetadataLen;
}
cfdp::FileSize& offset = info.getOffset();
cfdp::Fss& offset = info.getOffset();
result = offset.serialize(this->getLargeFileFlag(), buffer, size, maxSize, streamEndianness);
if (result != returnvalue::OK) {
return result;

View File

@ -1,9 +1,9 @@
#include "FileDataInfo.h"
FileDataInfo::FileDataInfo(cfdp::FileSize &offset, const uint8_t *fileData, size_t fileSize)
FileDataInfo::FileDataInfo(cfdp::Fss &offset, const uint8_t *fileData, size_t fileSize)
: offset(offset), fileData(fileData), fileSize(fileSize) {}
FileDataInfo::FileDataInfo(cfdp::FileSize &offset) : offset(offset) {}
FileDataInfo::FileDataInfo(cfdp::Fss &offset) : offset(offset) {}
void FileDataInfo::setSegmentMetadataFlag(bool enable) {
if (enable) {
@ -71,7 +71,7 @@ const uint8_t *FileDataInfo::getSegmentMetadata(size_t *segmentMetadataLen_) {
return segmentMetadata;
}
cfdp::FileSize &FileDataInfo::getOffset() { return offset; }
cfdp::Fss &FileDataInfo::getOffset() { return offset; }
void FileDataInfo::setRecordContinuationState(cfdp::RecordContinuationState recContState) {
this->recContState = recContState;

View File

@ -1,17 +1,17 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_FILEDATAINFO_H_
#define FSFW_SRC_FSFW_CFDP_PDU_FILEDATAINFO_H_
#include <fsfw/cfdp/FileSize.h>
#include <fsfw/cfdp/Fss.h>
#include <fsfw/cfdp/definitions.h>
class FileDataInfo {
public:
explicit FileDataInfo(cfdp::FileSize& offset);
FileDataInfo(cfdp::FileSize& offset, const uint8_t* fileData, size_t fileSize);
explicit FileDataInfo(cfdp::Fss& offset);
FileDataInfo(cfdp::Fss& offset, const uint8_t* fileData, size_t fileSize);
[[nodiscard]] size_t getSerializedSize(bool largeFile = false) const;
cfdp::FileSize& getOffset();
cfdp::Fss& getOffset();
const uint8_t* getFileData(size_t* fileSize = nullptr) const;
void setFileData(const uint8_t* fileData, size_t fileSize);
@ -33,7 +33,7 @@ class FileDataInfo {
private:
cfdp::SegmentMetadataFlag segmentMetadataFlag = cfdp::SegmentMetadataFlag::NOT_PRESENT;
cfdp::SegmentationControl segCtrl = cfdp::SegmentationControl::NO_RECORD_BOUNDARIES_PRESERVATION;
cfdp::FileSize& offset;
cfdp::Fss& offset;
const uint8_t* fileData = nullptr;
size_t fileSize = 0;
cfdp::RecordContinuationState recContState = cfdp::RecordContinuationState::NO_START_NO_END;

View File

@ -1,6 +1,6 @@
#include "KeepAlivePduCreator.h"
KeepAlivePduCreator::KeepAlivePduCreator(PduConfig &conf, cfdp::FileSize &progress)
KeepAlivePduCreator::KeepAlivePduCreator(PduConfig &conf, cfdp::Fss &progress)
: FileDirectiveCreator(conf, cfdp::FileDirective::KEEP_ALIVE, 4), progress(progress) {
updateDirectiveFieldLen();
}

View File

@ -1,12 +1,12 @@
#ifndef FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_
#define FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_
#include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/Fss.h"
#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
class KeepAlivePduCreator : public FileDirectiveCreator {
public:
KeepAlivePduCreator(PduConfig& conf, cfdp::FileSize& progress);
KeepAlivePduCreator(PduConfig& conf, cfdp::Fss& progress);
void updateDirectiveFieldLen();
@ -16,7 +16,7 @@ class KeepAlivePduCreator : public FileDirectiveCreator {
Endianness streamEndianness) const override;
private:
cfdp::FileSize& progress;
cfdp::Fss& progress;
};
#endif /* FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_ */

View File

@ -1,7 +1,6 @@
#include "KeepAlivePduReader.h"
KeepAlivePduReader::KeepAlivePduReader(const uint8_t* pduBuf, size_t maxSize,
cfdp::FileSize& progress)
KeepAlivePduReader::KeepAlivePduReader(const uint8_t* pduBuf, size_t maxSize, cfdp::Fss& progress)
: FileDirectiveReader(pduBuf, maxSize), progress(progress) {}
ReturnValue_t KeepAlivePduReader::parseData() {
@ -15,4 +14,4 @@ ReturnValue_t KeepAlivePduReader::parseData() {
return progress.deSerialize(&buffer, &remLen, getEndianness());
}
cfdp::FileSize& KeepAlivePduReader::getProgress() { return progress; }
cfdp::Fss& KeepAlivePduReader::getProgress() { return progress; }

View File

@ -1,19 +1,19 @@
#ifndef FSFW_CFDP_PDU_KEEPALIVEREADER_H_
#define FSFW_CFDP_PDU_KEEPALIVEREADER_H_
#include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/Fss.h"
#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
class KeepAlivePduReader : public FileDirectiveReader {
public:
KeepAlivePduReader(const uint8_t* pduBuf, size_t maxSize, cfdp::FileSize& progress);
KeepAlivePduReader(const uint8_t* pduBuf, size_t maxSize, cfdp::Fss& progress);
ReturnValue_t parseData() override;
cfdp::FileSize& getProgress();
cfdp::Fss& getProgress();
private:
cfdp::FileSize& progress;
cfdp::Fss& progress;
};
#endif /* FSFW_CFDP_PDU_KEEPALIVEPDUREADER_H_ */

View File

@ -1,14 +1,14 @@
#include "MetadataInfo.h"
MetadataInfo::MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumType,
cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName,
cfdp::Fss& fileSize, cfdp::StringLv& sourceFileName,
cfdp::StringLv& destFileName)
: MetadataInfo(fileSize, sourceFileName, destFileName) {
this->closureRequested = closureRequested;
this->checksumType = checksumType;
}
MetadataInfo::MetadataInfo(cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName,
MetadataInfo::MetadataInfo(cfdp::Fss& fileSize, cfdp::StringLv& sourceFileName,
cfdp::StringLv& destFileName)
: fileSize(fileSize), sourceFileName(sourceFileName), destFileName(destFileName) {}
@ -37,7 +37,7 @@ void MetadataInfo::setClosureRequested(bool closureRequested_) {
cfdp::StringLv& MetadataInfo::getDestFileName() { return destFileName; }
cfdp::FileSize& MetadataInfo::getFileSize() { return fileSize; }
cfdp::Fss& MetadataInfo::getFileSize() { return fileSize; }
ReturnValue_t MetadataInfo::getOptions(cfdp::Tlv*** optionsArray_, size_t* optionsLen_,
size_t* maxOptsLen) {

View File

@ -3,7 +3,7 @@
#include <optional>
#include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/Fss.h"
#include "fsfw/cfdp/definitions.h"
#include "fsfw/cfdp/tlv/Lv.h"
#include "fsfw/cfdp/tlv/StringLv.h"
@ -11,9 +11,8 @@
class MetadataInfo {
public:
MetadataInfo(cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName,
cfdp::StringLv& destFileName);
MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumType, cfdp::FileSize& fileSize,
MetadataInfo(cfdp::Fss& fileSize, cfdp::StringLv& sourceFileName, cfdp::StringLv& destFileName);
MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumType, cfdp::Fss& fileSize,
cfdp::StringLv& sourceFileName, cfdp::StringLv& destFileName);
size_t getSerializedSize(bool fssLarge = false);
@ -30,7 +29,7 @@ class MetadataInfo {
cfdp::StringLv& getDestFileName();
cfdp::StringLv& getSourceFileName();
cfdp::FileSize& getFileSize();
cfdp::Fss& getFileSize();
[[nodiscard]] bool hasOptions() const;
[[nodiscard]] bool canHoldOptions() const;
@ -43,7 +42,7 @@ class MetadataInfo {
private:
bool closureRequested = false;
cfdp::ChecksumType checksumType = cfdp::ChecksumType::NULL_CHECKSUM;
cfdp::FileSize& fileSize;
cfdp::Fss& fileSize;
cfdp::StringLv& sourceFileName;
cfdp::StringLv& destFileName;

View File

@ -1,6 +1,6 @@
#include "NakInfo.h"
NakInfo::NakInfo(cfdp::FileSize startOfScope, cfdp::FileSize endOfScope)
NakInfo::NakInfo(cfdp::Fss startOfScope, cfdp::Fss endOfScope)
: startOfScope(startOfScope), endOfScope(endOfScope) {}
size_t NakInfo::getSerializedSize(bool fssLarge) {
@ -57,9 +57,9 @@ void NakInfo::setSegmentRequests(SegmentRequest* segmentRequests, size_t* segmen
}
}
cfdp::FileSize& NakInfo::getStartOfScope() { return startOfScope; }
cfdp::Fss& NakInfo::getStartOfScope() { return startOfScope; }
cfdp::FileSize& NakInfo::getEndOfScope() { return endOfScope; }
cfdp::Fss& NakInfo::getEndOfScope() { return endOfScope; }
size_t NakInfo::getSegmentRequestsLen() const { return segmentRequestsLen; }

View File

@ -3,21 +3,21 @@
#include <utility>
#include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/Fss.h"
class NakInfo {
public:
using SegmentRequest = std::pair<cfdp::FileSize, cfdp::FileSize>;
using SegmentRequest = std::pair<cfdp::Fss, cfdp::Fss>;
NakInfo(cfdp::FileSize startOfScope, cfdp::FileSize endOfScope);
NakInfo(cfdp::Fss startOfScope, cfdp::Fss endOfScope);
void setSegmentRequests(SegmentRequest* segmentRequests, size_t* segmentRequestLen,
size_t* maxSegmentRequestLen);
size_t getSerializedSize(bool fssLarge = false);
cfdp::FileSize& getStartOfScope();
cfdp::FileSize& getEndOfScope();
cfdp::Fss& getStartOfScope();
cfdp::Fss& getEndOfScope();
bool hasSegmentRequests() const;
bool canHoldSegmentRequests() const;
@ -31,8 +31,8 @@ class NakInfo {
void setSegmentRequestLen(size_t readLen);
private:
cfdp::FileSize startOfScope;
cfdp::FileSize endOfScope;
cfdp::Fss startOfScope;
cfdp::Fss endOfScope;
SegmentRequest* segmentRequests = nullptr;
size_t segmentRequestsLen = 0;
size_t maxSegmentRequestsLen = 0;

View File

@ -4,7 +4,7 @@
#include <vector>
#include "NakInfo.h"
#include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/Fss.h"
#include "fsfw/cfdp/definitions.h"
#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"

View File

@ -50,7 +50,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
auto destHandler = DestHandler(dp, fp);
CHECK(destHandler.initialize() == OK);
auto metadataPreparation = [&](FileSize cfdpFileSize, ChecksumType checksumType) {
auto metadataPreparation = [&](Fss cfdpFileSize, ChecksumType checksumType) {
std::string srcNameString = "hello.txt";
std::string destNameString = "hello-cpy.txt";
StringLv srcName(srcNameString);
@ -91,7 +91,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
REQUIRE(res.step == DestHandler::TransactionStep::RECEIVING_FILE_DATA_PDUS);
};
auto eofPreparation = [&](FileSize cfdpFileSize, uint32_t crc) {
auto eofPreparation = [&](Fss cfdpFileSize, uint32_t crc) {
EofInfo eofInfo(cfdp::ConditionCode::NO_ERROR, crc, std::move(cfdpFileSize));
EofPduCreator eofCreator(conf, eofInfo);
REQUIRE(tcStore.getFreeElement(&storeId, eofCreator.getSerializedSize(), &buf) == OK);
@ -145,7 +145,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
SECTION("Empty File Transfer") {
const DestHandler::FsmResult& res = destHandler.performStateMachine();
CHECK(res.result == OK);
FileSize cfdpFileSize(0);
Fss cfdpFileSize(0);
metadataPreparation(cfdpFileSize, ChecksumType::NULL_CHECKSUM);
destHandler.performStateMachine();
metadataCheck(res, "hello.txt", "hello-cpy.txt", 0);
@ -165,14 +165,14 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
etl::crc32 crcCalc;
crcCalc.add(fileData.begin(), fileData.end());
uint32_t crc32 = crcCalc.value();
FileSize cfdpFileSize(fileData.size());
Fss cfdpFileSize(fileData.size());
metadataPreparation(cfdpFileSize, ChecksumType::CRC_32);
destHandler.performStateMachine();
metadataCheck(res, "hello.txt", "hello-cpy.txt", fileData.size());
destHandler.performStateMachine();
REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY);
auto transactionId = destHandler.getTransactionId();
FileSize offset(0);
Fss offset(0);
FileDataInfo fdPduInfo(offset, reinterpret_cast<const uint8_t*>(fileData.data()),
fileData.size());
FileDataCreator fdPduCreator(conf, fdPduInfo);
@ -201,7 +201,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
etl::crc32 crcCalc;
crcCalc.add(largerFileData.begin(), largerFileData.end());
uint32_t crc32 = crcCalc.value();
FileSize cfdpFileSize(largerFileData.size());
Fss cfdpFileSize(largerFileData.size());
metadataPreparation(cfdpFileSize, ChecksumType::CRC_32);
destHandler.performStateMachine();
metadataCheck(res, "hello.txt", "hello-cpy.txt", largerFileData.size());
@ -211,7 +211,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
std::vector<store_address_t> idsToCheck;
{
FileSize offset(0);
Fss offset(0);
FileDataInfo fdPduInfo(offset, reinterpret_cast<const uint8_t*>(largerFileData.data()),
largerFileData.size() / 2);
FileDataCreator fdPduCreator(conf, fdPduInfo);
@ -223,7 +223,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
}
{
FileSize offset(512);
Fss offset(512);
FileDataInfo fdPduInfo(offset, reinterpret_cast<const uint8_t*>(largerFileData.data() + 512),
largerFileData.size() / 2);
FileDataCreator fdPduCreator(conf, fdPduInfo);

View File

@ -21,7 +21,7 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
auto tcAcceptor = AcceptsTcMock("CFDP Receiver", 0, receiverQueueId);
// Set up Metadata PDU for generate test data.
cfdp::FileSize fileSize(12);
cfdp::Fss fileSize(12);
const cfdp::EntityId& sourceId(groundEntityId);
const cfdp::EntityId& destId(obswEntityId);
cfdp::TransactionSeqNum seqNum(UnsignedByteField<uint16_t>(12));

View File

@ -14,7 +14,7 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") {
size_t sz = 0;
EntityId destId(WidthInBytes::TWO_BYTES, 2);
EntityIdTlv faultLoc(destId);
FileSize fileSize(12);
Fss fileSize(12);
// We can already set the fault location, it will be ignored
EofInfo eofInfo(cfdp::ConditionCode::NO_ERROR, 5, fileSize, &faultLoc);
TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15);

View File

@ -22,7 +22,7 @@ TEST_CASE("File Data PDU", "[cfdp][pdu]") {
for (uint8_t idx = 0; idx < 10; idx++) {
fileBuffer[idx] = idx;
}
FileSize offset(50);
Fss offset(50);
FileDataInfo info(offset, fileBuffer.data(), 10);
SECTION("Serialization") {
@ -107,7 +107,7 @@ TEST_CASE("File Data PDU", "[cfdp][pdu]") {
serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK);
FileSize emptyOffset;
Fss emptyOffset;
FileDataInfo emptyInfo(emptyOffset);
FileDataReader deserializer(fileDataBuffer.data(), fileDataBuffer.size(), emptyInfo);
result = deserializer.parseData();

View File

@ -16,7 +16,7 @@ TEST_CASE("Keep Alive PDU", "[cfdp][pdu]") {
EntityId sourceId(WidthInBytes::TWO_BYTES, 1);
PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum);
FileSize progress(0x50);
Fss progress(0x50);
SECTION("Serialize") {
KeepAlivePduCreator serializer(pduConf, progress);

View File

@ -22,7 +22,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
std::string firstFileName = "hello.txt";
cfdp::StringLv sourceFileName(firstFileName);
cfdp::StringLv destFileName;
FileSize fileSize(35);
Fss fileSize(35);
MetadataInfo info(false, ChecksumType::MODULAR, fileSize, sourceFileName, destFileName);
FilestoreResponseTlv response(FilestoreActionCode::CREATE_DIRECTORY, FSR_CREATE_NOT_ALLOWED,

View File

@ -17,8 +17,8 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") {
EntityId sourceId(WidthInBytes::TWO_BYTES, 1);
PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum);
FileSize startOfScope(50);
FileSize endOfScope(1050);
Fss startOfScope(50);
Fss endOfScope(1050);
NakInfo info(startOfScope, endOfScope);
SECTION("Serializer") {
NakPduCreator serializer(pduConf, info);
@ -40,8 +40,8 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") {
REQUIRE(result == returnvalue::OK);
REQUIRE(scope == 1050);
NakInfo::SegmentRequest segReq0(cfdp::FileSize(2020), cfdp::FileSize(2520));
NakInfo::SegmentRequest segReq1(cfdp::FileSize(2932), cfdp::FileSize(3021));
NakInfo::SegmentRequest segReq0(cfdp::Fss(2020), cfdp::Fss(2520));
NakInfo::SegmentRequest segReq1(cfdp::Fss(2932), cfdp::Fss(3021));
// Now add 2 segment requests to NAK info and serialize them as well
std::array<NakInfo::SegmentRequest, 2> segReqs = {segReq0, segReq1};
size_t segReqsLen = segReqs.size();
@ -100,8 +100,8 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") {
REQUIRE(info.getStartOfScope().getSize() == 50);
REQUIRE(info.getEndOfScope().getSize() == 1050);
NakInfo::SegmentRequest segReq0(cfdp::FileSize(2020), cfdp::FileSize(2520));
NakInfo::SegmentRequest segReq1(cfdp::FileSize(2932), cfdp::FileSize(3021));
NakInfo::SegmentRequest segReq0(cfdp::Fss(2020), cfdp::Fss(2520));
NakInfo::SegmentRequest segReq1(cfdp::Fss(2932), cfdp::Fss(3021));
// Now add 2 segment requests to NAK info and serialize them as well
std::array<NakInfo::SegmentRequest, 2> segReqs = {segReq0, segReq1};
size_t segReqsLen = segReqs.size();

View File

@ -2,7 +2,7 @@
#include <catch2/catch_test_macros.hpp>
#include <cstring>
#include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/Fss.h"
#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
#include "fsfw/globalfunctions/arrayprinter.h"
@ -79,7 +79,7 @@ TEST_CASE("CFDP Base", "[cfdp]") {
std::array<uint8_t, 8> fssBuf = {};
uint8_t* buffer = fssBuf.data();
size_t size = 0;
cfdp::FileSize fss;
cfdp::Fss fss;
REQUIRE(fss.getSize() == 0);
fss.setFileSize(0x20, false);
result = fss.serialize(&buffer, &size, fssBuf.size(), SerializeIF::Endianness::MACHINE);