we already have CFDP messages

This commit is contained in:
Robin Müller 2023-07-24 11:05:11 +02:00
parent a1f36a0dd8
commit b0b6c68720
Signed by: muellerr
GPG Key ID: 407F9B00F858F270
3 changed files with 16 additions and 17 deletions

View File

@ -4,8 +4,9 @@ CfdpMessage::CfdpMessage() = default;
CfdpMessage::~CfdpMessage() = default;
void CfdpMessage::setCommand(CommandMessage *message, store_address_t cfdpPacket) {
message->setParameter(cfdpPacket.raw);
void CfdpMessage::setPutRequest(CommandMessage *message, store_address_t putRequest) {
message->setCommand(PUT_REQUEST);
message->setParameter(putRequest.raw);
}
store_address_t CfdpMessage::getStoreId(const CommandMessage *message) {

View File

@ -11,9 +11,11 @@ class CfdpMessage {
public:
static const uint8_t MESSAGE_ID = messagetypes::CFDP;
static const Command_t PUT_REQUEST = MAKE_COMMAND_ID(1);
static const Command_t CANCEL_REQUEST = MAKE_COMMAND_ID(1);
virtual ~CfdpMessage();
static void setCommand(CommandMessage* message, store_address_t cfdpPacket);
static void setPutRequest(CommandMessage* message, store_address_t putRequest);
static store_address_t getStoreId(const CommandMessage* message);

View File

@ -11,7 +11,7 @@ ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t
if (result != OK) {
return result;
}
if (*size + 1 > maxSize) {
if (*size + getSerializedSize() > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
**buffer = metadataOnly;
@ -26,9 +26,6 @@ ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t
if (result != OK) {
return result;
}
if (*size + sourceNameSize > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
std::memcpy(*buffer, sourceName, sourceNameSize);
*buffer += sourceNameSize;
*size += sourceNameSize;
@ -36,9 +33,6 @@ ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t
if (result != OK) {
return result;
}
if (*size + destNameSize > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
std::memcpy(*buffer, destName, destNameSize);
*buffer += destNameSize;
*size += destNameSize;
@ -62,9 +56,6 @@ ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t
if (result != OK) {
return result;
}
if (*size + msgsToUsersTotalSize > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
std::memcpy(*buffer, messagesToUserStartPtr, msgsToUsersTotalSize);
*buffer += msgsToUsersTotalSize;
*size += msgsToUsersTotalSize;
@ -78,9 +69,6 @@ ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t
if (result != OK) {
return result;
}
if (*size + fsRequestsTotalSize > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
std::memcpy(*buffer, fsRequest, fsRequestsTotalSize);
*buffer += fsRequestsTotalSize;
*size += fsRequestsTotalSize;
@ -91,4 +79,12 @@ ReturnValue_t cfdp::PutRequest::deSerialize(const uint8_t **buffer, size_t *size
SerializeIF::Endianness streamEndianness) {
return OK;
}
size_t cfdp::PutRequest::getSerializedSize() const { return 0; }
size_t cfdp::PutRequest::getSerializedSize() const {
size_t baseSize = destId.getSerializedSize() + 1;
if (!metadataOnly) {
baseSize += sizeof(sourceNameSize) + sourceNameSize + sizeof(destNameSize) + destNameSize + 2;
}
baseSize += sizeof(msgsToUsersTotalSize) + sizeof(numOfMsgsToUser) + msgsToUsersTotalSize +
sizeof(fsRequestsTotalSize) + sizeof(numOfFsRequests) + fsRequestsTotalSize;
return baseSize;
}