2021-07-13 08:32:14 +02:00
|
|
|
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
|
|
|
|
#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
#include "OBSWConfig.h"
|
|
|
|
#include "MPSoCReturnValuesIF.h"
|
2021-04-11 12:04:13 +02:00
|
|
|
#include <fsfw/tmtcpacket/SpacePacket.h>
|
|
|
|
#include <fsfw/globalfunctions/CRC.h>
|
2021-04-15 13:17:15 +02:00
|
|
|
#include <fsfw/serialize/SerializeAdapter.h>
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-01-05 11:26:01 +01:00
|
|
|
namespace mpsoc {
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-01-05 11:26:01 +01:00
|
|
|
static const DeviceCommandId_t NONE = 0;
|
|
|
|
static const DeviceCommandId_t TC_MEM_WRITE = 1;
|
|
|
|
static const DeviceCommandId_t TC_MEM_READ = 2;
|
|
|
|
static const DeviceCommandId_t ACK_REPORT = 3;
|
|
|
|
static const DeviceCommandId_t EXE_REPORT = 5;
|
|
|
|
static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 6;
|
|
|
|
static const DeviceCommandId_t TC_FLASHFOPEN = 7;
|
2022-01-06 10:12:08 +01:00
|
|
|
static const DeviceCommandId_t TC_FLASHFCLOSE = 8;
|
2022-01-06 18:05:21 +01:00
|
|
|
static const DeviceCommandId_t TC_FLASHWRITE = 9;
|
2022-03-21 08:35:28 +01:00
|
|
|
static const DeviceCommandId_t TC_FLASHDELETE = 10;
|
|
|
|
static const DeviceCommandId_t TC_REPLAY_START = 11;
|
|
|
|
static const DeviceCommandId_t TC_REPLAY_STOP = 12;
|
|
|
|
static const DeviceCommandId_t TC_REPLAY_WRITE_SEQUENCE = 13;
|
|
|
|
static const DeviceCommandId_t TC_DOWNLINK_PWR_ON = 14;
|
|
|
|
static const DeviceCommandId_t TC_DOWNLINK_PWR_OFF = 15;
|
2022-03-24 17:39:50 +01:00
|
|
|
static const DeviceCommandId_t TC_MODE_REPLAY = 16;
|
2022-01-03 08:01:55 +01:00
|
|
|
|
2022-03-25 09:08:01 +01:00
|
|
|
// Will reset the sequence count of the OBSW
|
|
|
|
static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50;
|
|
|
|
|
2022-01-03 08:01:55 +01:00
|
|
|
static const uint16_t SIZE_ACK_REPORT = 14;
|
|
|
|
static const uint16_t SIZE_EXE_REPORT = 14;
|
|
|
|
static const uint16_t SIZE_TM_MEM_READ_REPORT = 18;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SpacePacket apids of PLOC telecommands and telemetry.
|
|
|
|
*/
|
2022-01-05 11:26:01 +01:00
|
|
|
namespace apid {
|
2022-03-21 08:35:28 +01:00
|
|
|
static const uint16_t TC_REPLAY_START = 0x110;
|
|
|
|
static const uint16_t TC_REPLAY_STOP = 0x111;
|
|
|
|
static const uint16_t TC_REPLAY_WRITE_SEQUENCE = 0x112;
|
|
|
|
static const uint16_t TC_DOWNLINK_PWR_ON = 0x113;
|
2022-01-05 11:26:01 +01:00
|
|
|
static const uint16_t TC_MEM_WRITE = 0x114;
|
|
|
|
static const uint16_t TC_MEM_READ = 0x115;
|
2022-01-06 18:05:21 +01:00
|
|
|
static const uint16_t TC_FLASHWRITE = 0x117;
|
2022-01-05 11:26:01 +01:00
|
|
|
static const uint16_t TC_FLASHFOPEN = 0x119;
|
2022-01-06 10:12:08 +01:00
|
|
|
static const uint16_t TC_FLASHFCLOSE = 0x11A;
|
2022-03-21 08:35:28 +01:00
|
|
|
static const uint16_t TC_FLASHDELETE = 0x11C;
|
2022-03-24 17:39:50 +01:00
|
|
|
static const uint16_t TC_MODE_REPLAY = 0x11F;
|
2022-03-21 16:21:51 +01:00
|
|
|
static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124;
|
2022-01-05 11:26:01 +01:00
|
|
|
static const uint16_t TM_MEMORY_READ_REPORT = 0x404;
|
|
|
|
static const uint16_t ACK_SUCCESS = 0x400;
|
|
|
|
static const uint16_t ACK_FAILURE = 0x401;
|
|
|
|
static const uint16_t EXE_SUCCESS = 0x402;
|
|
|
|
static const uint16_t EXE_FAILURE = 0x403;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Offset from first byte in space packet to first byte of data field */
|
2022-01-03 08:01:55 +01:00
|
|
|
static const uint8_t DATA_FIELD_OFFSET = 6;
|
2022-01-11 17:58:59 +01:00
|
|
|
static const size_t MEM_READ_RPT_LEN_OFFSET = 10;
|
2022-01-03 08:01:55 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The size of payload data which will be forwarded to the requesting object. e.g. PUS Service
|
|
|
|
* 8.
|
|
|
|
*/
|
2022-01-11 17:58:59 +01:00
|
|
|
static const uint8_t SIZE_MEM_READ_RPT_FIX = 6;
|
2022-01-03 08:01:55 +01:00
|
|
|
|
2022-01-05 11:26:01 +01:00
|
|
|
static const size_t MAX_FILENAME_SIZE = 256;
|
|
|
|
|
2022-01-03 08:01:55 +01:00
|
|
|
/**
|
|
|
|
* PLOC space packet length for fixed size packets. This is the size of the whole packet data
|
|
|
|
* field. For the length field in the space packet this size will be substracted by one.
|
|
|
|
*/
|
|
|
|
static const uint16_t LENGTH_TC_MEM_WRITE = 12;
|
|
|
|
static const uint16_t LENGTH_TC_MEM_READ = 8;
|
|
|
|
|
2022-01-11 17:58:59 +01:00
|
|
|
static const size_t MAX_REPLY_SIZE = SpacePacket::PACKET_MAX_SIZE * 3;
|
2022-01-06 18:05:21 +01:00
|
|
|
static const size_t MAX_COMMAND_SIZE = SpacePacket::PACKET_MAX_SIZE;
|
|
|
|
static const size_t MAX_DATA_SIZE = 1016;
|
2022-01-03 08:01:55 +01:00
|
|
|
|
2022-01-05 11:26:01 +01:00
|
|
|
/**
|
2022-03-21 16:21:51 +01:00
|
|
|
* The replay write sequence command has a maximum delay for the execution report which amounts to
|
|
|
|
* 30 seconds (60 cycles * 0.5 seconds).
|
|
|
|
*/
|
|
|
|
static const uint16_t TC_WRITE_SEQ_EXECUTION_DELAY = 60;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Abstract base class for TC space packet of MPSoC.
|
2022-01-05 11:26:01 +01:00
|
|
|
*/
|
2022-03-22 11:35:44 +01:00
|
|
|
class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
|
2022-01-05 11:26:01 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
// Initial length field of space packet. Will always be updated when packet is created.
|
|
|
|
static const uint16_t INIT_LENGTH = 1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Constructor
|
|
|
|
*
|
|
|
|
* @param sequenceCount Sequence count of space packet which will be incremented with each
|
2022-03-16 09:01:36 +01:00
|
|
|
* sent and received packets.
|
2022-01-05 11:26:01 +01:00
|
|
|
*/
|
|
|
|
TcBase(uint16_t apid, uint16_t sequenceCount) :
|
|
|
|
SpacePacket(INIT_LENGTH, true, apid, sequenceCount) {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-03-16 12:36:05 +01:00
|
|
|
* @brief Function to initialize the space packet
|
2022-01-05 11:26:01 +01:00
|
|
|
*
|
|
|
|
* @param commandData Pointer to command specific data
|
|
|
|
* @param commandDataLen Length of command data
|
|
|
|
*
|
|
|
|
* @return RETURN_OK if packet creation was successful, otherwise error return value
|
|
|
|
*/
|
2022-03-16 12:36:05 +01:00
|
|
|
virtual ReturnValue_t createPacket(const uint8_t* commandData, size_t commandDataLen) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-01-05 11:26:01 +01:00
|
|
|
result = initPacket(commandData, commandDataLen);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::HasReturnvaluesIF::RETURN_OK) {
|
2022-01-05 11:26:01 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
result = addCrc();
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::HasReturnvaluesIF::RETURN_OK) {
|
2022-01-05 11:26:01 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* @brief Must be overwritten by the child class to define the command specific parameters
|
|
|
|
*
|
|
|
|
* @param commandData Pointer to received command data
|
|
|
|
* @param commandDataLen Length of received command data
|
|
|
|
*/
|
2022-03-16 12:36:05 +01:00
|
|
|
virtual ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-03-16 12:36:05 +01:00
|
|
|
}
|
2022-01-05 11:26:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Calculates and adds the CRC
|
|
|
|
*/
|
|
|
|
ReturnValue_t addCrc() {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-01-05 11:26:01 +01:00
|
|
|
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);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-01-05 11:26:01 +01:00
|
|
|
sif::debug << "TcBase::addCrc: Failed to serialize crc field" << std::endl;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-01-06 18:05:21 +01:00
|
|
|
/**
|
|
|
|
* @brief Class for handling tm replies of the PLOC MPSoC.
|
|
|
|
*/
|
2022-03-22 11:35:44 +01:00
|
|
|
class TmPacket : public SpacePacket, public MPSoCReturnValuesIF {
|
2022-01-06 18:05:21 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Constructor creates idle packet and sets length field to maximum allowed size.
|
|
|
|
*/
|
|
|
|
TmPacket() : SpacePacket(PACKET_MAX_SIZE) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t checkCrc() {
|
2022-01-10 16:18:18 +01:00
|
|
|
uint8_t* crcPtr = this->getPacketData() + this->getPacketDataLength() - 1;
|
2022-01-06 18:05:21 +01:00
|
|
|
uint16_t receivedCrc = *(crcPtr) << 8 | *(crcPtr + 1);
|
|
|
|
uint16_t recalculatedCrc = CRC::crc16ccitt(this->localData.byteStream, this->getFullSize());
|
2022-01-10 16:18:18 +01:00
|
|
|
if (recalculatedCrc != receivedCrc) {
|
2022-01-06 18:05:21 +01:00
|
|
|
return CRC_FAILURE;
|
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-01-06 18:05:21 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-01-03 08:01:55 +01:00
|
|
|
/**
|
|
|
|
* @brief This class helps to build the memory read command for the PLOC.
|
|
|
|
*/
|
2022-01-06 10:12:08 +01:00
|
|
|
class TcMemRead: public TcBase {
|
2022-01-03 08:01:55 +01:00
|
|
|
public:
|
2021-04-11 12:04:13 +02:00
|
|
|
|
|
|
|
/**
|
2022-01-03 08:01:55 +01:00
|
|
|
* @brief Constructor
|
2021-04-11 12:04:13 +02:00
|
|
|
*/
|
2022-01-06 10:12:08 +01:00
|
|
|
TcMemRead(uint16_t sequenceCount) :
|
|
|
|
TcBase(apid::TC_MEM_READ, sequenceCount) {
|
|
|
|
this->setPacketDataLength(PACKET_LENGTH);
|
|
|
|
}
|
|
|
|
|
2022-01-11 17:58:59 +01:00
|
|
|
uint16_t getMemLen() const {
|
|
|
|
return memLen;
|
|
|
|
}
|
|
|
|
|
2022-01-06 10:12:08 +01:00
|
|
|
protected:
|
|
|
|
|
|
|
|
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-01-06 10:12:08 +01:00
|
|
|
result = lengthCheck(commandDataLen);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-01-06 10:12:08 +01:00
|
|
|
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);
|
2022-01-11 17:58:59 +01:00
|
|
|
size_t size = sizeof(memLen);
|
|
|
|
const uint8_t* memLenPtr = commandData + MEM_ADDRESS_SIZE;
|
|
|
|
result = SerializeAdapter::deSerialize(&memLen, &memLenPtr, &size,
|
|
|
|
SerializeIF::Endianness::BIG);
|
2022-03-22 11:35:44 +01:00
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
2022-01-11 17:58:59 +01:00
|
|
|
return result;
|
|
|
|
}
|
2022-01-06 10:12:08 +01:00
|
|
|
return result;
|
2022-01-03 08:01:55 +01:00
|
|
|
}
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-01-03 08:01:55 +01:00
|
|
|
private:
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-01-06 10:12:08 +01:00
|
|
|
static const size_t COMMAND_LENGTH = 6;
|
|
|
|
static const size_t MEM_ADDRESS_SIZE = 4;
|
|
|
|
static const size_t MEM_LEN_SIZE = 2;
|
|
|
|
static const uint16_t PACKET_LENGTH = 7;
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-01-11 17:58:59 +01:00
|
|
|
uint16_t memLen = 0;
|
|
|
|
|
2022-01-06 10:12:08 +01:00
|
|
|
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
|
|
|
if (commandDataLen != COMMAND_LENGTH){
|
|
|
|
return INVALID_LENGTH;
|
2022-01-03 08:01:55 +01:00
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-01-03 08:01:55 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2022-01-06 10:12:08 +01:00
|
|
|
* @brief This class helps to generate the space packet to write data to a memory address within
|
2022-01-03 08:01:55 +01:00
|
|
|
* the PLOC.
|
|
|
|
*/
|
2022-01-06 10:12:08 +01:00
|
|
|
class TcMemWrite: public TcBase {
|
2022-01-03 08:01:55 +01:00
|
|
|
public:
|
2021-04-11 12:04:13 +02:00
|
|
|
/**
|
2022-01-03 08:01:55 +01:00
|
|
|
* @brief Constructor
|
2021-04-11 12:04:13 +02:00
|
|
|
*/
|
2022-01-06 10:12:08 +01:00
|
|
|
TcMemWrite(uint16_t sequenceCount) : TcBase(apid::TC_MEM_WRITE, sequenceCount) {
|
2021-04-26 11:28:19 +02:00
|
|
|
}
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-01-06 10:12:08 +01:00
|
|
|
protected:
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-01-06 10:12:08 +01:00
|
|
|
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-01-06 10:12:08 +01:00
|
|
|
result = lengthCheck(commandDataLen);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-01-06 10:12:08 +01:00
|
|
|
return result;
|
|
|
|
}
|
2022-01-11 12:56:02 +01:00
|
|
|
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
|
|
|
uint16_t memLen = *(commandData + MEM_ADDRESS_SIZE) << 8
|
|
|
|
| *(commandData + MEM_ADDRESS_SIZE + 1);
|
|
|
|
this->setPacketDataLength(memLen * 4 + FIX_LENGTH - 1);
|
2022-01-06 10:12:08 +01:00
|
|
|
return result;
|
|
|
|
}
|
2022-01-05 11:26:01 +01:00
|
|
|
|
2022-01-06 10:12:08 +01:00
|
|
|
private:
|
2022-01-03 08:01:55 +01:00
|
|
|
|
2022-01-11 12:56:02 +01:00
|
|
|
// Min length consists of 4 byte address, 2 byte mem length field, 4 byte data (1 word)
|
|
|
|
static const size_t MIN_COMMAND_DATA_LENGTH = 10;
|
2022-01-06 10:12:08 +01:00
|
|
|
static const size_t MEM_ADDRESS_SIZE = 4;
|
2022-01-11 12:56:02 +01:00
|
|
|
static const size_t FIX_LENGTH = 8;
|
2022-01-06 10:12:08 +01:00
|
|
|
|
|
|
|
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
2022-01-11 12:56:02 +01:00
|
|
|
if (commandDataLen < MIN_COMMAND_DATA_LENGTH) {
|
2022-03-17 19:51:00 +01:00
|
|
|
sif::warning << "TcMemWrite: Command has invalid length " << commandDataLen << std::endl;
|
|
|
|
return INVALID_LENGTH;
|
2022-01-06 10:12:08 +01:00
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-01-03 08:01:55 +01:00
|
|
|
}
|
2022-01-05 11:26:01 +01:00
|
|
|
};
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-01-05 11:26:01 +01:00
|
|
|
/**
|
2022-01-06 10:12:08 +01:00
|
|
|
* @brief Class to help creation of flash fopen command.
|
2022-01-05 11:26:01 +01:00
|
|
|
*/
|
|
|
|
class FlashFopen : public TcBase {
|
|
|
|
public:
|
2022-01-06 10:12:08 +01:00
|
|
|
|
2022-01-05 11:26:01 +01:00
|
|
|
FlashFopen(uint16_t sequenceCount) :
|
|
|
|
TcBase(apid::TC_FLASHFOPEN, sequenceCount) {
|
|
|
|
}
|
|
|
|
|
2022-03-16 12:36:05 +01:00
|
|
|
static const char APPEND = 'a';
|
|
|
|
static const char WRITE = 'w';
|
|
|
|
static const char READ = 'r';
|
|
|
|
|
|
|
|
ReturnValue_t createPacket(std::string filename, char accessMode) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-03-16 12:36:05 +01:00
|
|
|
size_t nameSize = filename.size();
|
|
|
|
std::memcpy(this->getPacketData(), filename.c_str(),
|
|
|
|
nameSize);
|
2022-03-23 05:28:24 +01:00
|
|
|
std::memcpy(this->getPacketData() + nameSize + 1, &accessMode,
|
2022-03-16 12:36:05 +01:00
|
|
|
sizeof(accessMode));
|
2022-03-22 11:35:44 +01:00
|
|
|
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
|
2022-03-16 12:36:05 +01:00
|
|
|
result = addCrc();
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-03-16 12:36:05 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return result;
|
2022-01-05 11:26:01 +01:00
|
|
|
}
|
2022-01-03 08:01:55 +01:00
|
|
|
};
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-01-06 10:12:08 +01:00
|
|
|
/**
|
|
|
|
* @brief Class to help creation of flash fclose command.
|
|
|
|
*/
|
2022-03-16 12:36:05 +01:00
|
|
|
class FlashFclose: public TcBase {
|
2022-01-06 10:12:08 +01:00
|
|
|
public:
|
|
|
|
|
2022-03-16 12:36:05 +01:00
|
|
|
FlashFclose(uint16_t sequenceCount) :
|
|
|
|
TcBase(apid::TC_FLASHFCLOSE, sequenceCount) {
|
2022-03-21 08:35:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t createPacket(std::string filename) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 08:35:28 +01:00
|
|
|
size_t nameSize = filename.size();
|
|
|
|
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
|
2022-03-22 11:35:44 +01:00
|
|
|
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
|
2022-03-21 08:35:28 +01:00
|
|
|
result = addCrc();
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-03-21 08:35:28 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-03-21 16:21:51 +01:00
|
|
|
/**
|
|
|
|
* @brief Class to build flash write space packet.
|
|
|
|
*/
|
|
|
|
class TcFlashWrite : public TcBase {
|
|
|
|
public:
|
|
|
|
|
|
|
|
TcFlashWrite(uint16_t sequenceCount) :
|
|
|
|
TcBase(apid::TC_FLASHWRITE, sequenceCount) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t createPacket(uint8_t* writeData, uint32_t writeLen) {
|
|
|
|
if (writeLen > MAX_DATA_SIZE) {
|
|
|
|
sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl;
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_FAILED;
|
2022-03-21 16:21:51 +01:00
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
std::memcpy(this->getPacketData(), &writeLen, sizeof(writeLen));
|
|
|
|
std::memcpy(this->getPacketData() + sizeof(writeLen), writeData, writeLen);
|
2022-03-21 16:21:51 +01:00
|
|
|
this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1));
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = addCrc();
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 16:21:51 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-03-21 08:35:28 +01:00
|
|
|
/**
|
2022-03-21 08:53:55 +01:00
|
|
|
* @brief Class to help creation of flash delete command.
|
2022-03-21 08:35:28 +01:00
|
|
|
*/
|
2022-03-21 08:53:55 +01:00
|
|
|
class TcFlashDelete: public TcBase {
|
2022-03-21 08:35:28 +01:00
|
|
|
public:
|
|
|
|
|
2022-03-21 08:53:55 +01:00
|
|
|
TcFlashDelete(uint16_t sequenceCount) :
|
2022-03-21 08:35:28 +01:00
|
|
|
TcBase(apid::TC_FLASHDELETE , sequenceCount) {
|
2022-03-16 12:36:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t createPacket(std::string filename) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-03-16 12:36:05 +01:00
|
|
|
size_t nameSize = filename.size();
|
|
|
|
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
|
2022-03-21 16:21:51 +01:00
|
|
|
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
|
2022-03-16 12:36:05 +01:00
|
|
|
result = addCrc();
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-03-16 12:36:05 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2022-01-06 10:12:08 +01:00
|
|
|
};
|
|
|
|
|
2022-01-06 18:05:21 +01:00
|
|
|
/**
|
2022-03-21 16:21:51 +01:00
|
|
|
* @brief Class to build replay stop space packet.
|
2022-01-06 18:05:21 +01:00
|
|
|
*/
|
2022-03-21 16:21:51 +01:00
|
|
|
class TcReplayStop : public TcBase {
|
2022-01-06 18:05:21 +01:00
|
|
|
public:
|
|
|
|
|
2022-03-21 16:21:51 +01:00
|
|
|
TcReplayStop(uint16_t sequenceCount) :
|
|
|
|
TcBase(apid::TC_REPLAY_STOP, sequenceCount) {
|
2022-01-06 18:05:21 +01:00
|
|
|
}
|
|
|
|
|
2022-03-21 16:21:51 +01:00
|
|
|
ReturnValue_t createPacket() {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 16:21:51 +01:00
|
|
|
result = addCrc();
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-03-21 16:21:51 +01:00
|
|
|
return result;
|
2022-03-16 12:36:05 +01:00
|
|
|
}
|
2022-03-21 16:21:51 +01:00
|
|
|
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-01-06 18:05:21 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-03-21 11:05:41 +01:00
|
|
|
/**
|
|
|
|
* @brief This class helps to build the replay start command.
|
|
|
|
*/
|
|
|
|
class TcReplayStart: public TcBase {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @brief Constructor
|
|
|
|
*/
|
|
|
|
TcReplayStart(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_START, sequenceCount) {
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 11:05:41 +01:00
|
|
|
result = lengthCheck(commandDataLen);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-03-21 11:05:41 +01:00
|
|
|
return result;
|
|
|
|
}
|
2022-03-21 16:21:51 +01:00
|
|
|
result = checkData(*commandData);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-03-21 11:05:41 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
|
|
|
this->setPacketDataLength(commandDataLen + CRC_SIZE - 1);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
static const size_t COMMAND_DATA_LENGTH = 1;
|
|
|
|
static const uint8_t REPEATING = 0;
|
|
|
|
static const uint8_t ONCE = 1;
|
|
|
|
|
|
|
|
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
|
|
|
if (commandDataLen != COMMAND_DATA_LENGTH) {
|
|
|
|
sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl;
|
|
|
|
return INVALID_LENGTH;
|
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 11:05:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t checkData(uint8_t replay) {
|
|
|
|
if (replay != REPEATING && replay != ONCE) {
|
|
|
|
sif::warning << "TcReplayStart::checkData: Invalid replay value" << std::endl;
|
|
|
|
return INVALID_PARAMETER;
|
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 11:05:41 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2022-03-21 16:21:51 +01:00
|
|
|
* @brief This class helps to build downlink power on command.
|
2022-03-21 11:05:41 +01:00
|
|
|
*/
|
2022-03-21 16:21:51 +01:00
|
|
|
class TcDownlinkPwrOn: public TcBase {
|
2022-03-21 11:05:41 +01:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @brief Constructor
|
|
|
|
*/
|
2022-03-21 16:21:51 +01:00
|
|
|
TcDownlinkPwrOn(uint16_t sequenceCount) : TcBase(apid::TC_DOWNLINK_PWR_ON, sequenceCount) {
|
2022-03-21 11:05:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 11:05:41 +01:00
|
|
|
result = lengthCheck(commandDataLen);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-03-21 11:05:41 +01:00
|
|
|
return result;
|
|
|
|
}
|
2022-03-21 16:21:51 +01:00
|
|
|
result = modeCheck(*commandData);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-03-21 16:21:51 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
result = laneRateCheck(*(commandData + 1));
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-03-21 16:21:51 +01:00
|
|
|
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);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::DWLPWRON_CMD;
|
|
|
|
|
|
|
|
//! [EXPORT] : [COMMENT] Received command has invalid JESD mode (valid modes are 0 - 5)
|
|
|
|
static const ReturnValue_t INVALID_MODE = MAKE_RETURN_CODE(0xE0);
|
|
|
|
//! [EXPORT] : [COMMENT] Received command has invalid lane rate (valid lane rate are 0 - 9)
|
|
|
|
static const ReturnValue_t INVALID_LANE_RATE = MAKE_RETURN_CODE(0xE1);
|
|
|
|
|
|
|
|
static const size_t COMMAND_DATA_LENGTH = 2;
|
|
|
|
static const uint8_t MAX_MODE = 5;
|
|
|
|
static const uint8_t MAX_LANE_RATE = 9;
|
|
|
|
static const uint16_t MAX_AMPLITUDE = 0;
|
|
|
|
|
|
|
|
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
|
|
|
if (commandDataLen != COMMAND_DATA_LENGTH) {
|
|
|
|
sif::warning << "TcDownlinkPwrOn: Command has invalid length " << commandDataLen << std::endl;
|
|
|
|
return INVALID_LENGTH;
|
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 16:21:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t modeCheck(uint8_t mode) {
|
|
|
|
if (mode > MAX_MODE) {
|
|
|
|
sif::warning << "TcDwonlinkPwrOn::modeCheck: Invalid JESD mode" << std::endl;
|
|
|
|
return INVALID_MODE;
|
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 16:21:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t laneRateCheck(uint8_t laneRate) {
|
|
|
|
if (laneRate > MAX_LANE_RATE) {
|
|
|
|
sif::warning << "TcReplayStart::laneRateCheck: Invalid lane rate" << std::endl;
|
|
|
|
return INVALID_LANE_RATE;
|
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 16:21:51 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Class to build replay stop space packet.
|
|
|
|
*/
|
|
|
|
class TcDownlinkPwrOff : public TcBase {
|
|
|
|
public:
|
|
|
|
|
|
|
|
TcDownlinkPwrOff(uint16_t sequenceCount) :
|
|
|
|
TcBase(apid::TC_DOWNLINK_PWR_OFF, sequenceCount) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t createPacket() {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 16:21:51 +01:00
|
|
|
result = addCrc();
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-03-21 16:21:51 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 16:21:51 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This class helps to build the replay start command.
|
|
|
|
*/
|
|
|
|
class TcReplayWriteSeq: public TcBase {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @brief Constructor
|
|
|
|
*/
|
|
|
|
TcReplayWriteSeq(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 16:21:51 +01:00
|
|
|
result = lengthCheck(commandDataLen);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-03-21 11:05:41 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
|
|
|
this->setPacketDataLength(commandDataLen + CRC_SIZE - 1);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-03-21 16:21:51 +01:00
|
|
|
private:
|
|
|
|
|
|
|
|
static const size_t USE_DECODING_LENGTH = 1;
|
|
|
|
|
|
|
|
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
|
|
|
if (commandDataLen > USE_DECODING_LENGTH + MAX_FILENAME_SIZE) {
|
|
|
|
sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen << std::endl;
|
|
|
|
return INVALID_LENGTH;
|
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-03-21 16:21:51 +01:00
|
|
|
}
|
2022-03-21 11:05:41 +01:00
|
|
|
};
|
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
class FlashWritePusCmd : public MPSoCReturnValuesIF {
|
|
|
|
public:
|
|
|
|
FlashWritePusCmd(){};
|
|
|
|
|
|
|
|
ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) {
|
|
|
|
if (commandDataLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE + MAX_FILENAME_SIZE)) {
|
|
|
|
return INVALID_LENGTH;
|
|
|
|
}
|
|
|
|
obcFile = std::string(reinterpret_cast<const char*>(commandData));
|
|
|
|
if (obcFile.size() > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE)) {
|
|
|
|
return FILENAME_TOO_LONG;
|
|
|
|
}
|
2022-03-23 05:28:24 +01:00
|
|
|
mpsocFile = std::string(
|
|
|
|
reinterpret_cast<const char*>(commandData + obcFile.size() + SIZE_NULL_TERMINATOR));
|
2022-03-22 11:35:44 +01:00
|
|
|
if (mpsocFile.size() > MAX_FILENAME_SIZE) {
|
|
|
|
return MPSOC_FILENAME_TOO_LONG;
|
|
|
|
}
|
2022-03-23 05:28:24 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2022-03-22 11:35:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string getObcFile() {
|
|
|
|
return obcFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getMPSoCFile() {
|
|
|
|
return mpsocFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2022-03-23 05:28:24 +01:00
|
|
|
static const size_t SIZE_NULL_TERMINATOR = 1;
|
2022-03-22 11:35:44 +01:00
|
|
|
std::string obcFile = "";
|
|
|
|
std::string mpsocFile = "";
|
|
|
|
};
|
2022-03-24 17:39:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Class to build replay stop space packet.
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-04-11 12:04:13 +02:00
|
|
|
}
|
|
|
|
|
2022-03-24 17:39:50 +01:00
|
|
|
|
|
|
|
|
2021-07-13 08:32:14 +02:00
|
|
|
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */
|