that should do the job

This commit is contained in:
Robin Müller 2023-07-24 10:06:45 +02:00
parent 69fd6d0f6a
commit 5d3f00da7f
Signed by: muellerr
GPG Key ID: 407F9B00F858F270
7 changed files with 23 additions and 28 deletions

View File

@ -1,4 +1,3 @@
target_sources(
${LIB_FSFW_NAME}
PRIVATE SourceHandler.cpp DestHandler.cpp MetadataParser.cpp
PutRequest.cpp FaultHandlerBase.cpp UserBase.cpp)
${LIB_FSFW_NAME} PRIVATE SourceHandler.cpp DestHandler.cpp PutRequest.cpp
FaultHandlerBase.cpp UserBase.cpp)

View File

@ -16,7 +16,7 @@ using namespace returnvalue;
cfdp::DestHandler::DestHandler(DestHandlerParams params, FsfwParams fsfwParams)
: tlvVec(params.maxTlvsInOnePdu),
userTlvVec(params.maxTlvsInOnePdu),
msgToUserVec(params.maxTlvsInOnePdu),
destParams(std::move(params)),
fsfwParams(fsfwParams),
transactionParams(params.maxFilenameLen) {
@ -137,7 +137,7 @@ ReturnValue_t cfdp::DestHandler::handleMetadataPdu(const PacketInfo& info) {
cfdp::StringLv destFileName;
MetadataInfo metadataInfo(transactionParams.fileSize, sourceFileName, destFileName);
MetadataPduReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(),
metadataInfo, nullptr, 0);
metadataInfo, tlvVec.data(), tlvVec.size());
ReturnValue_t result = reader.parseData();
// TODO: The standard does not really specify what happens if this kind of error happens
// I think it might be a good idea to cache some sort of error code, which
@ -355,9 +355,15 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met
params.fileSize = transactionParams.fileSize.getSize();
params.destFileName = transactionParams.destName.data();
params.sourceFileName = transactionParams.sourceName.data();
// TODO: Is this really correct? Implement this correctly..
// params.msgsToUserArray = dynamic_cast<MessageToUserTlv*>(userTlvVec.data());
// params.msgsToUserLen = reader.getNumberOfParsedOptions();
unsigned tlvIdx = 0;
for (const auto& opt : tlvVec) {
if (opt.getType() == TlvType::MSG_TO_USER) {
msgToUserVec[tlvIdx] = MessageToUserTlv(opt.getValue(), opt.getLengthField());
tlvIdx++;
}
}
params.msgsToUserArray = msgToUserVec.data();
params.msgsToUserLen = tlvIdx;
destParams.user.metadataRecvdIndication(params);
return result;
}

View File

@ -13,6 +13,7 @@
#include "fsfw/cfdp/handler/mib.h"
#include "fsfw/cfdp/pdu/MetadataPduReader.h"
#include "fsfw/cfdp/pdu/PduConfig.h"
#include "fsfw/cfdp/tlv/MessageToUserTlv.h"
#include "fsfw/container/DynamicFIFO.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/storagemanager/storeAddress.h"
@ -30,6 +31,9 @@ struct DestHandlerParams {
// TODO: This container can potentially take tons of space. For a better
// memory efficient implementation, an additional abstraction could be
// be used so users can use uint32_t as the pair type
// TODO: Actually, we can provide a better abstraction via interface, which
// allows using something like a bounded map. This simplifies
// the implementation significantly.
LostSegmentsListBase& lostSegmentsContainer)
: cfg(std::move(cfg)),
user(user),
@ -43,7 +47,7 @@ struct DestHandlerParams {
PacketInfoListBase& packetListRef;
LostSegmentsListBase& lostSegmentsContainer;
uint8_t maxTlvsInOnePdu = 10;
uint8_t maxTlvsInOnePdu = 20;
size_t maxFilenameLen = 255;
};
@ -143,7 +147,7 @@ class DestHandler {
};
std::vector<cfdp::Tlv> tlvVec;
std::vector<cfdp::Tlv> userTlvVec;
std::vector<MessageToUserTlv> msgToUserVec;
DestHandlerParams destParams;
cfdp::FsfwParams fsfwParams;
TransactionParams transactionParams;

View File

@ -1,3 +0,0 @@
#include "MetadataParser.h"
cfdp::MetadataParser::MetadataParser(MetadataPduReader& reader) {}

View File

@ -1,15 +0,0 @@
#pragma once
#include "fsfw/cfdp/pdu/MetadataPduReader.h"
namespace cfdp {
class MetadataParser {
public:
explicit MetadataParser(MetadataPduReader& reader);
private:
};
} // namespace cfdp

View File

@ -7,3 +7,6 @@ MessageToUserTlv::MessageToUserTlv() : Tlv() {}
MessageToUserTlv::MessageToUserTlv(const std::vector<uint8_t>& data)
: Tlv(cfdp::TlvType::MSG_TO_USER, data.data(), data.size()) {}
MessageToUserTlv::MessageToUserTlv(const uint8_t* value, size_t size)
: Tlv(cfdp::TlvType::MSG_TO_USER, value, size) {}

View File

@ -9,6 +9,7 @@ class MessageToUserTlv : public cfdp::Tlv {
public:
MessageToUserTlv();
MessageToUserTlv(uint8_t* value, size_t size);
MessageToUserTlv(const uint8_t* value, size_t size);
explicit MessageToUserTlv(const std::vector<uint8_t>& data);
private: