CFDP SOURCE handler #157
@ -1,3 +1,4 @@
|
||||
target_sources(
|
||||
${LIB_FSFW_NAME} PRIVATE SourceHandler.cpp DestHandler.cpp PutRequest.cpp
|
||||
${LIB_FSFW_NAME}
|
||||
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"
|
||||
|
||||
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,
|
||||
|
@ -12,14 +12,13 @@ namespace cfdp {
|
||||
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;
|
||||
@ -27,6 +26,14 @@ class PutRequest: public SerializeIF {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user