continue with the msg to user / put request architecture

This commit is contained in:
Robin Müller 2023-07-24 10:52:38 +02:00
parent 98cbf38432
commit e4665c9394
Signed by: muellerr
GPG Key ID: 407F9B00F858F270
5 changed files with 71 additions and 16 deletions

View File

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

View File

@ -0,0 +1 @@
#include "MsgToUserParser.h"

View File

@ -0,0 +1 @@
#pragma once

View File

@ -1,10 +1,55 @@
#include "PutRequest.h"
using namespace returnvalue;
[[nodiscard]] bool cfdp::PutRequest::isMetadataOnly() const {
return !destNameSize.has_value() and !sourceNameSize.has_value();
return destNameSize > 0 and sourceNameSize > 0;
}
ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const {
ReturnValue_t result = destId.serialize(buffer, size, maxSize, streamEndianness);
if (result != OK) {
return result;
}
if (*size + 1 > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
**buffer = metadataOnly;
*size += 1;
if (transmissionMode) {
**buffer = transmissionMode;
*size += 1;
*buffer += 1;
}
if (!metadataOnly) {
result = SerializeAdapter::serialize(&sourceNameSize, buffer, size, maxSize, streamEndianness);
if (result != OK) {
return result;
}
if (*size + sourceNameSize > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
std::memcpy(*buffer, sourceName, sourceNameSize);
*buffer += sourceNameSize;
*size += sourceNameSize;
result = SerializeAdapter::serialize(&destNameSize, buffer, size, maxSize, streamEndianness);
if (result != OK) {
return result;
}
std::memcpy(*buffer, destName, destNameSize);
*buffer += destNameSize;
*size += destNameSize;
if (*size + 1 > maxSize) {
**buffer = transmissionMode;
*size += 1;
*buffer += 1;
}
if (*size + 1 > maxSize) {
**buffer = closureRequested;
*size += 1;
*buffer += 1;
}
}
return returnvalue::OK;
}
ReturnValue_t cfdp::PutRequest::deSerialize(const uint8_t **buffer, size_t *size,

View File

@ -9,24 +9,31 @@
namespace cfdp {
class PutRequest: public SerializeIF {
class PutRequest : public SerializeIF {
public:
EntityId destId;
std::optional<TransmissionMode> transmissionMode;
char destName[524]{};
std::optional<size_t> destNameSize;
char sourceName[524]{};
std::optional<size_t> sourceNameSize;
std::optional<bool> closureRequested;
std::vector<MessageToUserTlv> messagesToUser;
std::vector<FilestoreRequestTlv> fsRequest;
bool metadataOnly = true;
char* destName = nullptr;
uint64_t destNameSize = 0;
char* sourceName = nullptr;
uint64_t sourceNameSize = 0;
TransmissionMode transmissionMode = TransmissionMode::UNACKNOWLEDGED;
bool closureRequested = false;
[[nodiscard]] ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const override;
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) override;
[[nodiscard]] ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
[[nodiscard]] size_t getSerializedSize() const override;
[[nodiscard]] bool isMetadataOnly() const;
private:
size_t msgsToUsersTotalSize = 0;
uint32_t numOfMsgsToUser = 0;
uint8_t* messagesToUserStartPtr = nullptr;
size_t fsRequestsTotalSize = 0;
uint32_t numOfFsRequests = 0;
uint8_t* fsRequest = nullptr;
};
} // namespace cfdp