continue with the msg to user / put request architecture
This commit is contained in:
parent
98cbf38432
commit
e4665c9394
@ -1,3 +1,4 @@
|
|||||||
target_sources(
|
target_sources(
|
||||||
${LIB_FSFW_NAME} PRIVATE SourceHandler.cpp DestHandler.cpp PutRequest.cpp
|
${LIB_FSFW_NAME}
|
||||||
FaultHandlerBase.cpp UserBase.cpp)
|
PRIVATE SourceHandler.cpp DestHandler.cpp PutRequest.cpp MsgToUserParser.cpp
|
||||||
|
FaultHandlerBase.cpp UserBase.cpp)
|
||||||
|
1
src/fsfw/cfdp/handler/MsgToUserParser.cpp
Normal file
1
src/fsfw/cfdp/handler/MsgToUserParser.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "MsgToUserParser.h"
|
1
src/fsfw/cfdp/handler/MsgToUserParser.h
Normal file
1
src/fsfw/cfdp/handler/MsgToUserParser.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
#pragma once
|
@ -1,10 +1,55 @@
|
|||||||
#include "PutRequest.h"
|
#include "PutRequest.h"
|
||||||
|
|
||||||
|
using namespace returnvalue;
|
||||||
[[nodiscard]] bool cfdp::PutRequest::isMetadataOnly() const {
|
[[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,
|
ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||||
SerializeIF::Endianness streamEndianness) const {
|
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;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
ReturnValue_t cfdp::PutRequest::deSerialize(const uint8_t **buffer, size_t *size,
|
ReturnValue_t cfdp::PutRequest::deSerialize(const uint8_t **buffer, size_t *size,
|
||||||
|
@ -9,24 +9,31 @@
|
|||||||
|
|
||||||
namespace cfdp {
|
namespace cfdp {
|
||||||
|
|
||||||
class PutRequest: public SerializeIF {
|
class PutRequest : public SerializeIF {
|
||||||
public:
|
public:
|
||||||
EntityId destId;
|
EntityId destId;
|
||||||
std::optional<TransmissionMode> transmissionMode;
|
bool metadataOnly = true;
|
||||||
char destName[524]{};
|
char* destName = nullptr;
|
||||||
std::optional<size_t> destNameSize;
|
uint64_t destNameSize = 0;
|
||||||
char sourceName[524]{};
|
char* sourceName = nullptr;
|
||||||
std::optional<size_t> sourceNameSize;
|
uint64_t sourceNameSize = 0;
|
||||||
std::optional<bool> closureRequested;
|
TransmissionMode transmissionMode = TransmissionMode::UNACKNOWLEDGED;
|
||||||
std::vector<MessageToUserTlv> messagesToUser;
|
bool closureRequested = false;
|
||||||
std::vector<FilestoreRequestTlv> fsRequest;
|
|
||||||
|
|
||||||
[[nodiscard]] ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
[[nodiscard]] ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||||
Endianness streamEndianness) const override;
|
Endianness streamEndianness) const override;
|
||||||
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) override;
|
Endianness streamEndianness) override;
|
||||||
[[nodiscard]] size_t getSerializedSize() const override;
|
[[nodiscard]] size_t getSerializedSize() const override;
|
||||||
[[nodiscard]] bool isMetadataOnly() const;
|
[[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
|
} // namespace cfdp
|
||||||
|
Loading…
Reference in New Issue
Block a user