Bump FSFW #31

Merged
muellerr merged 139 commits from bump-fsfw into develop 2023-12-18 13:16:28 +01:00
2 changed files with 37 additions and 31 deletions
Showing only changes of commit 7bf7336d4a - Show all commits

View File

@ -2,9 +2,18 @@
using namespace returnvalue; using namespace returnvalue;
[[nodiscard]] bool cfdp::PutRequest::isMetadataOnly() const { cfdp::PutRequest::PutRequest(cfdp::EntityId destId, const uint8_t *msgsToUser,
return destNameSize > 0 and sourceNameSize > 0; size_t msgsToUserTotalSize, const uint8_t *fsRequests,
} size_t fsRequestsSize)
: destId(std::move(destId)),
metadataOnly(true),
msgsToUsersTotalSize(msgsToUserTotalSize),
msgsToUserStartPtr(msgsToUser),
fsRequestsTotalSize(fsRequestsSize),
fsRequestStartPtr(fsRequests) {}
[[nodiscard]] bool cfdp::PutRequest::isMetadataOnly() const { return metadataOnly; }
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); ReturnValue_t result = destId.serialize(buffer, size, maxSize, streamEndianness);
@ -16,11 +25,6 @@ ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t
} }
**buffer = metadataOnly; **buffer = metadataOnly;
*size += 1; *size += 1;
if (transmissionMode) {
**buffer = transmissionMode;
*size += 1;
*buffer += 1;
}
if (!metadataOnly) { if (!metadataOnly) {
result = SerializeAdapter::serialize(&sourceNameSize, buffer, size, maxSize, streamEndianness); result = SerializeAdapter::serialize(&sourceNameSize, buffer, size, maxSize, streamEndianness);
if (result != OK) { if (result != OK) {
@ -52,11 +56,7 @@ ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t
if (result != OK) { if (result != OK) {
return result; return result;
} }
result = SerializeAdapter::serialize(&numOfMsgsToUser, buffer, size, maxSize, streamEndianness); std::memcpy(*buffer, msgsToUserStartPtr, msgsToUsersTotalSize);
if (result != OK) {
return result;
}
std::memcpy(*buffer, messagesToUserStartPtr, msgsToUsersTotalSize);
*buffer += msgsToUsersTotalSize; *buffer += msgsToUsersTotalSize;
*size += msgsToUsersTotalSize; *size += msgsToUsersTotalSize;
@ -65,11 +65,7 @@ ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t
if (result != OK) { if (result != OK) {
return result; return result;
} }
result = SerializeAdapter::serialize(&numOfFsRequests, buffer, size, maxSize, streamEndianness); std::memcpy(*buffer, fsRequestStartPtr, fsRequestsTotalSize);
if (result != OK) {
return result;
}
std::memcpy(*buffer, fsRequest, fsRequestsTotalSize);
*buffer += fsRequestsTotalSize; *buffer += fsRequestsTotalSize;
*size += fsRequestsTotalSize; *size += fsRequestsTotalSize;
return OK; return OK;
@ -84,7 +80,7 @@ size_t cfdp::PutRequest::getSerializedSize() const {
if (!metadataOnly) { if (!metadataOnly) {
baseSize += sizeof(sourceNameSize) + sourceNameSize + sizeof(destNameSize) + destNameSize + 2; baseSize += sizeof(sourceNameSize) + sourceNameSize + sizeof(destNameSize) + destNameSize + 2;
} }
baseSize += sizeof(msgsToUsersTotalSize) + sizeof(numOfMsgsToUser) + msgsToUsersTotalSize + baseSize += sizeof(msgsToUsersTotalSize) + msgsToUsersTotalSize + sizeof(fsRequestsTotalSize) +
sizeof(fsRequestsTotalSize) + sizeof(numOfFsRequests) + fsRequestsTotalSize; fsRequestsTotalSize;
return baseSize; return baseSize;
} }

View File

@ -12,14 +12,17 @@ namespace cfdp {
class PutRequest : public SerializeIF { class PutRequest : public SerializeIF {
public: public:
EntityId destId; EntityId destId;
bool metadataOnly = true;
char* destName = nullptr;
uint64_t destNameSize = 0;
char* sourceName = nullptr;
uint64_t sourceNameSize = 0;
TransmissionMode transmissionMode = TransmissionMode::UNACKNOWLEDGED;
bool closureRequested = false;
/**
* Metadata only constructor.
* @param destId
* @param msgsToUser
* @param msgsToUserTotalSize
* @param fsRequests
* @param fsRequestsSize
*/
PutRequest(EntityId destId, const uint8_t* msgsToUser, size_t msgsToUserTotalSize,
const uint8_t* fsRequests, size_t fsRequestsSize);
[[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,
@ -28,12 +31,19 @@ class PutRequest : public SerializeIF {
[[nodiscard]] bool isMetadataOnly() const; [[nodiscard]] bool isMetadataOnly() const;
private: private:
bool metadataOnly = true;
// Transaction parameters. Omitted if the put request is metadata only.
char* destName = nullptr;
uint64_t destNameSize = 0;
char* sourceName = nullptr;
uint64_t sourceNameSize = 0;
TransmissionMode transmissionMode = TransmissionMode::UNACKNOWLEDGED;
bool closureRequested = false;
// Metadata
size_t msgsToUsersTotalSize = 0; size_t msgsToUsersTotalSize = 0;
uint32_t numOfMsgsToUser = 0; const uint8_t* msgsToUserStartPtr = nullptr;
uint8_t* messagesToUserStartPtr = nullptr;
size_t fsRequestsTotalSize = 0; size_t fsRequestsTotalSize = 0;
uint32_t numOfFsRequests = 0; const uint8_t* fsRequestStartPtr = nullptr;
uint8_t* fsRequest = nullptr;
}; };
} // namespace cfdp } // namespace cfdp