Merge pull request 'PLOC commands' (#462) from meier/ploc-commands into develop
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

Reviewed-on: #462
This commit is contained in:
Robin Müller 2023-03-14 13:08:45 +01:00
commit b43e1ef4e9
6 changed files with 210 additions and 5 deletions

View File

@ -31,6 +31,10 @@ static const DeviceCommandId_t TC_MODE_IDLE = 18;
static const DeviceCommandId_t TM_CAM_CMD_RPT = 19; static const DeviceCommandId_t TM_CAM_CMD_RPT = 19;
static const DeviceCommandId_t SET_UART_TX_TRISTATE = 20; static const DeviceCommandId_t SET_UART_TX_TRISTATE = 20;
static const DeviceCommandId_t RELEASE_UART_TX = 21; static const DeviceCommandId_t RELEASE_UART_TX = 21;
static const DeviceCommandId_t TC_CAM_TAKE_PIC = 22;
static const DeviceCommandId_t TC_SIMPLEX_SEND_FILE = 23;
static const DeviceCommandId_t TC_DOWNLINK_DATA_MODULATE = 24;
static const DeviceCommandId_t TC_MODE_SNAPSHOT = 25;
// Will reset the sequence count of the OBSW // Will reset the sequence count of the OBSW
static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50; static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50;
@ -50,14 +54,18 @@ static const uint16_t TC_REPLAY_WRITE_SEQUENCE = 0x112;
static const uint16_t TC_DOWNLINK_PWR_ON = 0x113; static const uint16_t TC_DOWNLINK_PWR_ON = 0x113;
static const uint16_t TC_MEM_WRITE = 0x114; static const uint16_t TC_MEM_WRITE = 0x114;
static const uint16_t TC_MEM_READ = 0x115; static const uint16_t TC_MEM_READ = 0x115;
static const uint16_t TC_CAM_TAKE_PIC = 0x116;
static const uint16_t TC_FLASHWRITE = 0x117; static const uint16_t TC_FLASHWRITE = 0x117;
static const uint16_t TC_FLASHFOPEN = 0x119; static const uint16_t TC_FLASHFOPEN = 0x119;
static const uint16_t TC_FLASHFCLOSE = 0x11A; static const uint16_t TC_FLASHFCLOSE = 0x11A;
static const uint16_t TC_FLASHDELETE = 0x11C; static const uint16_t TC_FLASHDELETE = 0x11C;
static const uint16_t TC_MODE_REPLAY = 0x11F;
static const uint16_t TC_MODE_IDLE = 0x11E; static const uint16_t TC_MODE_IDLE = 0x11E;
static const uint16_t TC_MODE_REPLAY = 0x11F;
static const uint16_t TC_MODE_SNAPSHOT = 0x120;
static const uint16_t TC_DOWNLINK_DATA_MODULATE = 0x121;
static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124; static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124;
static const uint16_t TC_CAM_CMD_SEND = 0x12C; static const uint16_t TC_CAM_CMD_SEND = 0x12C;
static const uint16_t TC_SIMPLEX_SEND_FILE = 0x130;
static const uint16_t TM_MEMORY_READ_REPORT = 0x404; static const uint16_t TM_MEMORY_READ_REPORT = 0x404;
static const uint16_t ACK_SUCCESS = 0x400; static const uint16_t ACK_SUCCESS = 0x400;
static const uint16_t ACK_FAILURE = 0x401; static const uint16_t ACK_FAILURE = 0x401;
@ -107,8 +115,11 @@ static const size_t MAX_DATA_SIZE = 1016;
static const uint16_t TC_WRITE_SEQ_EXECUTION_DELAY = 80; static const uint16_t TC_WRITE_SEQ_EXECUTION_DELAY = 80;
// Requires approx. 2 seconds for execution. 8 => 4 seconds // Requires approx. 2 seconds for execution. 8 => 4 seconds
static const uint16_t TC_DOWNLINK_PWR_ON_EXECUTION_DELAY = 8; static const uint16_t TC_DOWNLINK_PWR_ON_EXECUTION_DELAY = 8;
static const uint16_t TC_CAM_TAKE_PIC_EXECUTION_DELAY = 20;
static const uint16_t TC_SIMPLEX_SEND_FILE_DELAY = 80;
namespace status_code { namespace status_code {
static const uint16_t DEFAULT_ERROR_CODE = 0x1;
static const uint16_t UNKNOWN_APID = 0x5DD; static const uint16_t UNKNOWN_APID = 0x5DD;
static const uint16_t INCORRECT_LENGTH = 0x5DE; static const uint16_t INCORRECT_LENGTH = 0x5DE;
static const uint16_t INCORRECT_CRC = 0x5DF; static const uint16_t INCORRECT_CRC = 0x5DF;
@ -646,6 +657,90 @@ class TcModeIdle : public TcBase {
: TcBase(params, apid::TC_MODE_IDLE, sequenceCount) {} : TcBase(params, apid::TC_MODE_IDLE, sequenceCount) {}
}; };
/**
* @brief Class to build mode idle command
*/
class TcModeSnapshot : public TcBase {
public:
TcModeSnapshot(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MODE_SNAPSHOT, sequenceCount) {}
};
/**
* @brief Class to build camera take picture command
*/
class TcCamTakePic : public TcBase {
public:
TcCamTakePic(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_CAM_TAKE_PIC, sequenceCount) {}
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
if (commandDataLen > MAX_DATA_LENGTH) {
return INVALID_LENGTH;
}
std::string fileName(reinterpret_cast<const char*>(commandData));
if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) {
return FILENAME_TOO_LONG;
}
if (commandDataLen - (fileName.size() + sizeof(NULL_TERMINATOR)) != PARAMETER_SIZE) {
return INVALID_LENGTH;
}
spParams.setFullPayloadLen(commandDataLen + CRC_SIZE);
std::memcpy(payloadStart, commandData, commandDataLen);
return returnvalue::OK;
}
private:
static const size_t MAX_DATA_LENGTH = 286;
static const size_t PARAMETER_SIZE = 28;
};
/**
* @brief Class to build simplex send file command
*/
class TcSimplexSendFile : public TcBase {
public:
TcSimplexSendFile(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_SIMPLEX_SEND_FILE, sequenceCount) {}
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
if (commandDataLen > MAX_DATA_LENGTH) {
return INVALID_LENGTH;
}
std::string fileName(reinterpret_cast<const char*>(commandData));
if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) {
return FILENAME_TOO_LONG;
}
spParams.setFullPayloadLen(commandDataLen + CRC_SIZE);
std::memcpy(payloadStart, commandData, commandDataLen);
return returnvalue::OK;
}
private:
static const size_t MAX_DATA_LENGTH = 256;
};
/**
* @brief Class to build downlink data modulate command
*/
class TcDownlinkDataModulate : public TcBase {
public:
TcDownlinkDataModulate(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_DOWNLINK_DATA_MODULATE, sequenceCount) {}
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
if (commandDataLen > MAX_DATA_LENGTH) {
return INVALID_LENGTH;
}
spParams.setFullPayloadLen(commandDataLen + CRC_SIZE);
std::memcpy(payloadStart, commandData, commandDataLen);
return returnvalue::OK;
}
private:
static const size_t MAX_DATA_LENGTH = 11;
};
class TcCamcmdSend : public TcBase { class TcCamcmdSend : public TcBase {
public: public:
TcCamcmdSend(ploc::SpTcParams params, uint16_t sequenceCount) TcCamcmdSend(ploc::SpTcParams params, uint16_t sequenceCount)

View File

@ -1,5 +1,7 @@
#include "PlocMPSoCHandler.h" #include "PlocMPSoCHandler.h"
#include <sstream>
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/datapool/PoolReadGuard.h"
#include "fsfw/globalfunctions/CRC.h" #include "fsfw/globalfunctions/CRC.h"
@ -257,6 +259,22 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device
result = prepareTcCamCmdSend(commandData, commandDataLen); result = prepareTcCamCmdSend(commandData, commandDataLen);
break; break;
} }
case (mpsoc::TC_CAM_TAKE_PIC): {
result = prepareTcCamTakePic(commandData, commandDataLen);
break;
}
case (mpsoc::TC_SIMPLEX_SEND_FILE): {
result = prepareTcSimplexSendFile(commandData, commandDataLen);
break;
}
case (mpsoc::TC_DOWNLINK_DATA_MODULATE): {
result = prepareTcDownlinkDataModulate(commandData, commandDataLen);
break;
}
case (mpsoc::TC_MODE_SNAPSHOT): {
result = prepareTcModeSnapshot();
break;
}
default: default:
sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented"
<< std::endl; << std::endl;
@ -288,6 +306,10 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(mpsoc::TC_CAM_CMD_SEND); this->insertInCommandMap(mpsoc::TC_CAM_CMD_SEND);
this->insertInCommandMap(mpsoc::RELEASE_UART_TX); this->insertInCommandMap(mpsoc::RELEASE_UART_TX);
this->insertInCommandMap(mpsoc::SET_UART_TX_TRISTATE); this->insertInCommandMap(mpsoc::SET_UART_TX_TRISTATE);
this->insertInCommandMap(mpsoc::TC_CAM_TAKE_PIC);
this->insertInCommandMap(mpsoc::TC_SIMPLEX_SEND_FILE);
this->insertInCommandMap(mpsoc::TC_DOWNLINK_DATA_MODULATE);
this->insertInCommandMap(mpsoc::TC_MODE_SNAPSHOT);
this->insertInReplyMap(mpsoc::ACK_REPORT, 3, nullptr, mpsoc::SIZE_ACK_REPORT); this->insertInReplyMap(mpsoc::ACK_REPORT, 3, nullptr, mpsoc::SIZE_ACK_REPORT);
this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT); this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT);
this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT); this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT);
@ -537,6 +559,53 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData,
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount);
result = tcCamTakePic.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcCamTakePic.getFullPacketLen());
return returnvalue::OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount);
result = tcSimplexSendFile.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcSimplexSendFile.getFullPacketLen());
return returnvalue::OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount);
result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcDownlinkDataModulate.getFullPacketLen());
return returnvalue::OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcModeSnapshot() {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount);
result = tcModeSnapshot.buildPacket();
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcModeSnapshot.getFullPacketLen());
return returnvalue::OK;
}
void PlocMPSoCHandler::finishTcPrep(size_t packetLen) { void PlocMPSoCHandler::finishTcPrep(size_t packetLen) {
nextReplyId = mpsoc::ACK_REPORT; nextReplyId = mpsoc::ACK_REPORT;
rawPacket = commandBuffer; rawPacket = commandBuffer;
@ -694,6 +763,10 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
case mpsoc::TC_REPLAY_WRITE_SEQUENCE: case mpsoc::TC_REPLAY_WRITE_SEQUENCE:
case mpsoc::TC_MODE_REPLAY: case mpsoc::TC_MODE_REPLAY:
case mpsoc::TC_MODE_IDLE: case mpsoc::TC_MODE_IDLE:
case mpsoc::TC_CAM_TAKE_PIC:
case mpsoc::TC_SIMPLEX_SEND_FILE:
case mpsoc::TC_DOWNLINK_DATA_MODULATE:
case mpsoc::TC_MODE_SNAPSHOT:
enabledReplies = 2; enabledReplies = 2;
break; break;
case mpsoc::TC_MEM_READ: { case mpsoc::TC_MEM_READ: {
@ -753,8 +826,17 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
} }
case mpsoc::TC_DOWNLINK_PWR_ON: { case mpsoc::TC_DOWNLINK_PWR_ON: {
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT); DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
// iter->second.delayCycles = mpsoc::TC_DOWNLINK_PWR_ON_EXECUTION_DELAY;
iter->second.delayCycles = mpsoc::TC_DOWNLINK_PWR_ON; break;
}
case mpsoc::TC_CAM_TAKE_PIC: {
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
iter->second.delayCycles = mpsoc::TC_CAM_TAKE_PIC_EXECUTION_DELAY;
break;
}
case mpsoc::TC_SIMPLEX_SEND_FILE: {
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
iter->second.delayCycles = mpsoc::TC_SIMPLEX_SEND_FILE_DELAY;
break; break;
} }
default: default:
@ -917,6 +999,18 @@ void PlocMPSoCHandler::disableAllReplies() {
/* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */
switch (commandId) { switch (commandId) {
case TC_MEM_WRITE: case TC_MEM_WRITE:
case TC_FLASHDELETE:
case TC_REPLAY_START:
case TC_REPLAY_STOP:
case TC_DOWNLINK_PWR_ON:
case TC_DOWNLINK_PWR_OFF:
case TC_REPLAY_WRITE_SEQUENCE:
case TC_MODE_REPLAY:
case TC_MODE_IDLE:
case TC_CAM_TAKE_PIC:
case TC_SIMPLEX_SEND_FILE:
case TC_DOWNLINK_DATA_MODULATE:
case TC_MODE_SNAPSHOT:
break; break;
case TC_MEM_READ: { case TC_MEM_READ: {
iter = deviceReplyMap.find(TM_MEMORY_READ_REPORT); iter = deviceReplyMap.find(TM_MEMORY_READ_REPORT);
@ -1048,6 +1142,10 @@ std::string PlocMPSoCHandler::getStatusString(uint16_t status) {
return "Flash file already closed"; return "Flash file already closed";
break; break;
} }
case (mpsoc::status_code::FLASH_FILE_OPEN_FAILED): {
return "Flash file open failed";
break;
}
case (mpsoc::status_code::FLASH_FILE_NOT_OPEN): { case (mpsoc::status_code::FLASH_FILE_NOT_OPEN): {
return "Flash file not open"; return "Flash file not open";
break; break;
@ -1084,7 +1182,14 @@ std::string PlocMPSoCHandler::getStatusString(uint16_t status) {
return "Flash uncorrectable mismatch"; return "Flash uncorrectable mismatch";
break; break;
} }
case (mpsoc::status_code::DEFAULT_ERROR_CODE): {
return "Default error code";
break;
}
default: default:
std::stringstream ss;
ss << "0x" << std::hex << status;
return ss.str();
break; break;
} }
return ""; return "";

View File

@ -169,6 +169,10 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcModeIdle(); ReturnValue_t prepareTcModeIdle();
ReturnValue_t prepareTcCamTakePic(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcSimplexSendFile(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcDownlinkDataModulate(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcModeSnapshot();
void finishTcPrep(size_t packetLen); void finishTcPrep(size_t packetLen);
/** /**

View File

@ -14,6 +14,7 @@ struct SpTcParams {
SpTcParams(SpacePacketCreator& creator, uint8_t* buf, size_t maxSize) SpTcParams(SpacePacketCreator& creator, uint8_t* buf, size_t maxSize)
: creator(creator), buf(buf), maxSize(maxSize) {} : creator(creator), buf(buf), maxSize(maxSize) {}
// Set full payload length. Must also consider the two CRC bytes
void setFullPayloadLen(size_t fullPayloadLen_) { fullPayloadLen = fullPayloadLen_; } void setFullPayloadLen(size_t fullPayloadLen_) { fullPayloadLen = fullPayloadLen_; }
SpacePacketCreator& creator; SpacePacketCreator& creator;

2
tmtc

@ -1 +1 @@
Subproject commit d8367f7e62a47516d7772c129c18ee8f7b07703b Subproject commit f21ee37a01379907ca72932264e5236a6c30f8a1