This commit is contained in:
parent
4ed516e0bc
commit
398e7a3a05
@ -6,10 +6,10 @@
|
||||
#include <linux/payload/mpsocRetvals.h>
|
||||
#include <mission/payload/plocSpBase.h>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "eive/definitions.h"
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/serialize/SerializeAdapter.h"
|
||||
#include "fsfw/serialize/SerializeIF.h"
|
||||
|
||||
namespace mpsoc {
|
||||
|
||||
@ -838,20 +838,45 @@ class TcSimplexSendFile : public TcBase {
|
||||
: TcBase(params, apid::TC_SIMPLEX_SEND_FILE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||
if (commandDataLen < MIN_DATA_LENGTH) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
if (commandDataLen > MAX_DATA_LENGTH) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
std::string fileName(reinterpret_cast<const char*>(commandData));
|
||||
const uint8_t** dataPtr = &commandData;
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&chunkParameter, dataPtr, &commandDataLen,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
if (chunkParameter == 0) {
|
||||
return INVALID_PARAMETER;
|
||||
}
|
||||
std::string fileName(reinterpret_cast<const char*>(*dataPtr));
|
||||
if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) {
|
||||
return FILENAME_TOO_LONG;
|
||||
}
|
||||
spParams.setFullPayloadLen(commandDataLen + CRC_SIZE);
|
||||
std::memcpy(payloadStart, commandData, commandDataLen);
|
||||
size_t currentCopyIdx = 0;
|
||||
size_t payloadLen = fileName.length() + sizeof(NULL_TERMINATOR) + CRC_SIZE;
|
||||
if (chunkParameter > 1) {
|
||||
char divStr[12]{};
|
||||
sprintf(divStr, "DIV%03d", chunkParameter);
|
||||
std::memcpy(payloadStart, divStr, DIV_STR_LEN);
|
||||
payloadLen += DIV_STR_LEN;
|
||||
currentCopyIdx += DIV_STR_LEN;
|
||||
}
|
||||
|
||||
std::memcpy(payloadStart + currentCopyIdx, *dataPtr, fileName.length());
|
||||
spParams.setFullPayloadLen(payloadLen);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
private:
|
||||
static const size_t MAX_DATA_LENGTH = 256;
|
||||
uint32_t chunkParameter = 0;
|
||||
static constexpr size_t MAX_DATA_LENGTH = 256;
|
||||
static constexpr size_t MIN_DATA_LENGTH = 4;
|
||||
static constexpr size_t DIV_STR_LEN = 6;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user