change PLOC/MPSOC code to using new SP code
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
#include "eive/definitions.h"
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "fsfw/serialize/SerializeAdapter.h"
|
||||
#include "fsfw/tmtcpacket/SpacePacket.h"
|
||||
#include "mission/devices/devicedefinitions/SpBase.h"
|
||||
|
||||
namespace mpsoc {
|
||||
|
||||
@ -73,6 +73,8 @@ static const char NULL_TERMINATOR = '\0';
|
||||
static const uint8_t MIN_SPACE_PACKET_LENGTH = 7;
|
||||
static const uint8_t SPACE_PACKET_HEADER_SIZE = 6;
|
||||
|
||||
static constexpr size_t CRC_SIZE = 2;
|
||||
|
||||
/**
|
||||
* The size of payload data which will be forwarded to the requesting object. e.g. PUS Service
|
||||
* 8.
|
||||
@ -88,8 +90,12 @@ static const size_t MAX_FILENAME_SIZE = 256;
|
||||
static const uint16_t LENGTH_TC_MEM_WRITE = 12;
|
||||
static const uint16_t LENGTH_TC_MEM_READ = 8;
|
||||
|
||||
static const size_t MAX_REPLY_SIZE = SpacePacket::PACKET_MAX_SIZE * 3;
|
||||
static const size_t MAX_COMMAND_SIZE = SpacePacket::PACKET_MAX_SIZE;
|
||||
/**
|
||||
* TODO: Might be a good idea to document where this is coming from
|
||||
*/
|
||||
static constexpr size_t SP_MAX_SIZE = 1024;
|
||||
static const size_t MAX_REPLY_SIZE = SP_MAX_SIZE * 3;
|
||||
static const size_t MAX_COMMAND_SIZE = SP_MAX_SIZE;
|
||||
static const size_t MAX_DATA_SIZE = 1016;
|
||||
|
||||
/**
|
||||
@ -130,8 +136,10 @@ static const uint16_t RESERVED_4 = 0x5F4;
|
||||
/**
|
||||
* @brief Abstract base class for TC space packet of MPSoC.
|
||||
*/
|
||||
class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
|
||||
class TcBase : public SpacePacketBase, public MPSoCReturnValuesIF {
|
||||
public:
|
||||
virtual ~TcBase() = default;
|
||||
|
||||
// Initial length field of space packet. Will always be updated when packet is created.
|
||||
static const uint16_t INIT_LENGTH = 1;
|
||||
|
||||
@ -141,8 +149,12 @@ class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
|
||||
* @param sequenceCount Sequence count of space packet which will be incremented with each
|
||||
* sent and received packets.
|
||||
*/
|
||||
TcBase(uint16_t apid, uint16_t sequenceCount)
|
||||
: SpacePacket(INIT_LENGTH, true, apid, sequenceCount) {}
|
||||
TcBase(SpBaseParams params, uint16_t apid, uint16_t sequenceCount)
|
||||
: SpacePacketBase(params, apid, sequenceCount) {
|
||||
spParams.setDataFieldLen(INIT_LENGTH);
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket() { return buildPacket(nullptr, 0); }
|
||||
|
||||
/**
|
||||
* @brief Function to initialize the space packet
|
||||
@ -152,17 +164,22 @@ class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
|
||||
*
|
||||
* @return RETURN_OK if packet creation was successful, otherwise error return value
|
||||
*/
|
||||
virtual ReturnValue_t createPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = initPacket(commandData, commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
ReturnValue_t buildPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
payloadStart = spParams.buf + ccsds::HEADER_LEN;
|
||||
ReturnValue_t res;
|
||||
if (commandData != nullptr and commandDataLen > 0) {
|
||||
res = initPacket(commandData, commandDataLen);
|
||||
if (res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
|
||||
updateFields();
|
||||
res = checkSizeAndSerializeHeader();
|
||||
if (res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
return result;
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -175,23 +192,6 @@ class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
|
||||
virtual ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates and adds the CRC
|
||||
*/
|
||||
ReturnValue_t addCrc() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
size_t serializedSize = 0;
|
||||
uint32_t full_size = getFullSize();
|
||||
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
|
||||
result = SerializeAdapter::serialize<uint16_t>(
|
||||
&crc, this->localData.byteStream + full_size - CRC_SIZE, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::debug << "TcBase::addCrc: Failed to serialize crc field" << std::endl;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -224,22 +224,22 @@ class TcMemRead : public TcBase {
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
TcMemRead(uint16_t sequenceCount) : TcBase(apid::TC_MEM_READ, sequenceCount) {
|
||||
this->setPacketDataLength(PACKET_LENGTH);
|
||||
TcMemRead(SpBaseParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_MEM_READ, sequenceCount) {
|
||||
spParams.setPayloadLen(COMMAND_LENGTH);
|
||||
}
|
||||
|
||||
uint16_t getMemLen() const { return memLen; }
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->localData.fields.buffer, commandData, MEM_ADDRESS_SIZE);
|
||||
std::memcpy(this->localData.fields.buffer + MEM_ADDRESS_SIZE, commandData + MEM_ADDRESS_SIZE,
|
||||
MEM_LEN_SIZE);
|
||||
std::memcpy(payloadStart, commandData, MEM_ADDRESS_SIZE);
|
||||
std::memcpy(payloadStart + MEM_ADDRESS_SIZE, commandData + MEM_ADDRESS_SIZE, MEM_LEN_SIZE);
|
||||
size_t size = sizeof(memLen);
|
||||
const uint8_t* memLenPtr = commandData + MEM_ADDRESS_SIZE;
|
||||
result =
|
||||
@ -247,6 +247,7 @@ class TcMemRead : public TcBase {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
spParams.setPayloadLen(MEM_ADDRESS_SIZE + MEM_LEN_SIZE);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -275,19 +276,21 @@ class TcMemWrite : public TcBase {
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
TcMemWrite(uint16_t sequenceCount) : TcBase(apid::TC_MEM_WRITE, sequenceCount) {}
|
||||
TcMemWrite(SpBaseParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
// TODO: Confusing, recheck..
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||
std::memcpy(payloadStart, commandData, commandDataLen);
|
||||
uint16_t memLen =
|
||||
*(commandData + MEM_ADDRESS_SIZE) << 8 | *(commandData + MEM_ADDRESS_SIZE + 1);
|
||||
this->setPacketDataLength(memLen * 4 + FIX_LENGTH - 1);
|
||||
spParams.setPayloadLen(FIX_LENGTH + memLen * 4);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -309,9 +312,10 @@ class TcMemWrite : public TcBase {
|
||||
/**
|
||||
* @brief Class to help creation of flash fopen command.
|
||||
*/
|
||||
class FlashFopen : public TcBase {
|
||||
class FlashFopen : public SpacePacketBase {
|
||||
public:
|
||||
FlashFopen(uint16_t sequenceCount) : TcBase(apid::TC_FLASHFOPEN, sequenceCount) {}
|
||||
FlashFopen(SpBaseParams params, uint16_t sequenceCount)
|
||||
: SpacePacketBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
|
||||
|
||||
static const char APPEND = 'a';
|
||||
static const char WRITE = 'w';
|
||||
@ -321,17 +325,12 @@ class FlashFopen : public TcBase {
|
||||
accessMode = accessMode_;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
size_t nameSize = filename.size();
|
||||
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
|
||||
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
|
||||
std::memcpy(this->getPacketData() + nameSize + sizeof(NULL_TERMINATOR), &accessMode,
|
||||
sizeof(accessMode));
|
||||
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode) + CRC_SIZE -
|
||||
1);
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||
*(spParams.buf + nameSize) = NULL_TERMINATOR;
|
||||
std::memcpy(payloadStart + nameSize + sizeof(NULL_TERMINATOR), &accessMode, sizeof(accessMode));
|
||||
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode));
|
||||
updateFields();
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -343,28 +342,25 @@ class FlashFopen : public TcBase {
|
||||
*/
|
||||
class FlashFclose : public TcBase {
|
||||
public:
|
||||
FlashFclose(uint16_t sequenceCount) : TcBase(apid::TC_FLASHFCLOSE, sequenceCount) {}
|
||||
FlashFclose(SpBaseParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket(std::string filename) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
size_t nameSize = filename.size();
|
||||
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
|
||||
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
|
||||
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||
*(payloadStart + nameSize) = NULL_TERMINATOR;
|
||||
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR));
|
||||
return calcCrc();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class to build flash write space packet.
|
||||
*/
|
||||
class TcFlashWrite : public TcBase {
|
||||
class TcFlashWrite : public SpacePacketBase {
|
||||
public:
|
||||
TcFlashWrite(uint16_t sequenceCount) : TcBase(apid::TC_FLASHWRITE, sequenceCount) {}
|
||||
TcFlashWrite(SpBaseParams params, uint16_t sequenceCount)
|
||||
: SpacePacketBase(params, apid::TC_FLASHWRITE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket(const uint8_t* writeData, uint32_t writeLen_) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
@ -374,19 +370,19 @@ class TcFlashWrite : public TcBase {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
size_t serializedSize = 0;
|
||||
result =
|
||||
SerializeAdapter::serialize<uint32_t>(&writeLen, this->getPacketData(), &serializedSize,
|
||||
sizeof(writeLen), SerializeIF::Endianness::BIG);
|
||||
result = SerializeAdapter::serialize(&writeLen, payloadStart, &serializedSize, sizeof(writeLen),
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->getPacketData() + sizeof(writeLen), writeData, writeLen);
|
||||
this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1));
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
std::memcpy(payloadStart + sizeof(writeLen), writeData, writeLen);
|
||||
spParams.setPayloadLen(static_cast<uint16_t>(writeLen) + 4);
|
||||
updateFields();
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if (res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -396,21 +392,23 @@ class TcFlashWrite : public TcBase {
|
||||
/**
|
||||
* @brief Class to help creation of flash delete command.
|
||||
*/
|
||||
class TcFlashDelete : public TcBase {
|
||||
class TcFlashDelete : public SpacePacketBase {
|
||||
public:
|
||||
TcFlashDelete(uint16_t sequenceCount) : TcBase(apid::TC_FLASHDELETE, sequenceCount) {}
|
||||
TcFlashDelete(SpBaseParams params, uint16_t sequenceCount)
|
||||
: SpacePacketBase(params, apid::TC_FLASHDELETE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket(std::string filename) {
|
||||
ReturnValue_t buildPacket(std::string filename) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
size_t nameSize = filename.size();
|
||||
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
|
||||
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
|
||||
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||
*(payloadStart + nameSize) = NULL_TERMINATOR;
|
||||
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR));
|
||||
updateFields();
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if (res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
return result;
|
||||
return calcCrc();
|
||||
}
|
||||
};
|
||||
|
||||
@ -419,17 +417,8 @@ class TcFlashDelete : public TcBase {
|
||||
*/
|
||||
class TcReplayStop : public TcBase {
|
||||
public:
|
||||
TcReplayStop(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_STOP, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
TcReplayStop(SpBaseParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_REPLAY_STOP, sequenceCount) {}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -440,10 +429,11 @@ class TcReplayStart : public TcBase {
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
TcReplayStart(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_START, sequenceCount) {}
|
||||
TcReplayStart(SpBaseParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_REPLAY_START, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@ -453,8 +443,8 @@ class TcReplayStart : public TcBase {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||
this->setPacketDataLength(commandDataLen + CRC_SIZE - 1);
|
||||
std::memcpy(payloadStart, commandData, commandDataLen);
|
||||
spParams.setPayloadLen(commandDataLen);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -488,10 +478,11 @@ class TcDownlinkPwrOn : public TcBase {
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
TcDownlinkPwrOn(uint16_t sequenceCount) : TcBase(apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
|
||||
TcDownlinkPwrOn(SpBaseParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@ -505,10 +496,9 @@ class TcDownlinkPwrOn : public TcBase {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||
std::memcpy(this->localData.fields.buffer + commandDataLen, &MAX_AMPLITUDE,
|
||||
sizeof(MAX_AMPLITUDE));
|
||||
this->setPacketDataLength(commandDataLen + sizeof(MAX_AMPLITUDE) + CRC_SIZE - 1);
|
||||
std::memcpy(payloadStart, commandData, commandDataLen);
|
||||
std::memcpy(payloadStart + commandDataLen, &MAX_AMPLITUDE, sizeof(MAX_AMPLITUDE));
|
||||
spParams.setPayloadLen(commandDataLen + sizeof(MAX_AMPLITUDE));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -555,17 +545,8 @@ class TcDownlinkPwrOn : public TcBase {
|
||||
*/
|
||||
class TcDownlinkPwrOff : public TcBase {
|
||||
public:
|
||||
TcDownlinkPwrOff(uint16_t sequenceCount) : TcBase(apid::TC_DOWNLINK_PWR_OFF, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
TcDownlinkPwrOff(SpBaseParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_DOWNLINK_PWR_OFF, sequenceCount) {}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -576,19 +557,19 @@ class TcReplayWriteSeq : public TcBase {
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
TcReplayWriteSeq(uint16_t sequenceCount)
|
||||
: TcBase(apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
|
||||
TcReplayWriteSeq(SpBaseParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||
*(this->localData.fields.buffer + commandDataLen) = NULL_TERMINATOR;
|
||||
this->setPacketDataLength(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
|
||||
std::memcpy(payloadStart, commandData, commandDataLen);
|
||||
*(payloadStart + commandDataLen) = NULL_TERMINATOR;
|
||||
spParams.setPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -643,17 +624,8 @@ class FlashWritePusCmd : public MPSoCReturnValuesIF {
|
||||
*/
|
||||
class TcModeReplay : public TcBase {
|
||||
public:
|
||||
TcModeReplay(uint16_t sequenceCount) : TcBase(apid::TC_MODE_REPLAY, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
TcModeReplay(SpBaseParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_MODE_REPLAY, sequenceCount) {}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -661,36 +633,27 @@ class TcModeReplay : public TcBase {
|
||||
*/
|
||||
class TcModeIdle : public TcBase {
|
||||
public:
|
||||
TcModeIdle(uint16_t sequenceCount) : TcBase(apid::TC_MODE_IDLE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
TcModeIdle(SpBaseParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_MODE_IDLE, sequenceCount) {}
|
||||
};
|
||||
|
||||
class TcCamcmdSend : public TcBase {
|
||||
public:
|
||||
TcCamcmdSend(uint16_t sequenceCount) : TcBase(apid::TC_CAM_CMD_SEND, sequenceCount) {}
|
||||
TcCamcmdSend(SpBaseParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_CAM_CMD_SEND, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
if (commandDataLen > MAX_DATA_LENGTH) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
uint16_t dataLen = static_cast<uint16_t>(commandDataLen + sizeof(CARRIAGE_RETURN));
|
||||
size_t size = sizeof(dataLen);
|
||||
SerializeAdapter::serialize(&dataLen, this->getPacketData(), &size, sizeof(dataLen),
|
||||
SerializeAdapter::serialize(&dataLen, payloadStart, &size, sizeof(dataLen),
|
||||
SerializeIF::Endianness::BIG);
|
||||
std::memcpy(this->getPacketData() + sizeof(dataLen), commandData, commandDataLen);
|
||||
*(this->getPacketData() + sizeof(dataLen) + commandDataLen) = CARRIAGE_RETURN;
|
||||
uint16_t trueLength = sizeof(dataLen) + commandDataLen + sizeof(CARRIAGE_RETURN) + CRC_SIZE;
|
||||
this->setPacketDataLength(trueLength - 1);
|
||||
std::memcpy(payloadStart + sizeof(dataLen), commandData, commandDataLen);
|
||||
*(payloadStart + sizeof(dataLen) + commandDataLen) = CARRIAGE_RETURN;
|
||||
spParams.setPayloadLen(sizeof(dataLen) + commandDataLen + sizeof(CARRIAGE_RETURN));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user