kenning west alder
This commit is contained in:
parent
468fa01650
commit
4ba9ebf58f
@ -562,11 +562,11 @@ ReturnValue_t PlocMpsocHandler::prepareTcMemWrite(const uint8_t* commandData,
|
|||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
mpsoc::TcMemWrite tcMemWrite(spParams, sequenceCount);
|
mpsoc::TcMemWrite tcMemWrite(spParams, sequenceCount);
|
||||||
result = tcMemWrite.buildPacket(commandData, commandDataLen);
|
result = tcMemWrite.setPayload(commandData, commandDataLen);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
finishTcPrep(tcMemWrite.getFullPacketLen());
|
finishTcPrep(tcMemWrite);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,11 +574,11 @@ ReturnValue_t PlocMpsocHandler::prepareTcMemRead(const uint8_t* commandData,
|
|||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
mpsoc::TcMemRead tcMemRead(spParams, sequenceCount);
|
mpsoc::TcMemRead tcMemRead(spParams, sequenceCount);
|
||||||
result = tcMemRead.buildPacket(commandData, commandDataLen);
|
result = tcMemRead.setPayload(commandData, commandDataLen);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
finishTcPrep(tcMemRead.getFullPacketLen());
|
finishTcPrep(tcMemRead);
|
||||||
tmMemReadReport.rememberRequestedSize = tcMemRead.getMemLen() * 4 + TmMemReadReport::FIX_SIZE;
|
tmMemReadReport.rememberRequestedSize = tcMemRead.getMemLen() * 4 + TmMemReadReport::FIX_SIZE;
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
@ -590,12 +590,12 @@ ReturnValue_t PlocMpsocHandler::prepareTcFlashDelete(const uint8_t* commandData,
|
|||||||
}
|
}
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
mpsoc::TcFlashDelete tcFlashDelete(spParams, sequenceCount);
|
mpsoc::TcFlashDelete tcFlashDelete(spParams, sequenceCount);
|
||||||
result = tcFlashDelete.buildPacket(
|
std::string filename = std::string(reinterpret_cast<const char*>(commandData), commandDataLen);
|
||||||
std::string(reinterpret_cast<const char*>(commandData), commandDataLen));
|
result = tcFlashDelete.setPayload(filename);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
finishTcPrep(tcFlashDelete.getFullPacketLen());
|
finishTcPrep(tcFlashDelete);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,22 +603,17 @@ ReturnValue_t PlocMpsocHandler::prepareTcReplayStart(const uint8_t* commandData,
|
|||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
mpsoc::TcReplayStart tcReplayStart(spParams, sequenceCount);
|
mpsoc::TcReplayStart tcReplayStart(spParams, sequenceCount);
|
||||||
result = tcReplayStart.buildPacket(commandData, commandDataLen);
|
result = tcReplayStart.setPayload(commandData, commandDataLen);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
finishTcPrep(tcReplayStart.getFullPacketLen());
|
finishTcPrep(tcReplayStart);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::prepareTcReplayStop() {
|
ReturnValue_t PlocMpsocHandler::prepareTcReplayStop() {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
|
||||||
mpsoc::TcReplayStop tcReplayStop(spParams, sequenceCount);
|
mpsoc::TcReplayStop tcReplayStop(spParams, sequenceCount);
|
||||||
result = tcReplayStop.buildPacket();
|
finishTcPrep(tcReplayStop);
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
finishTcPrep(tcReplayStop.getFullPacketLen());
|
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,78 +621,49 @@ ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOn(const uint8_t* commandDat
|
|||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(spParams, sequenceCount);
|
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(spParams, sequenceCount);
|
||||||
result = tcDownlinkPwrOn.buildPacket(commandData, commandDataLen);
|
result = tcDownlinkPwrOn.setPayload(commandData, commandDataLen);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
finishTcPrep(tcDownlinkPwrOn.getFullPacketLen());
|
finishTcPrep(tcDownlinkPwrOn);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOff() {
|
ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOff() {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
|
||||||
mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(spParams, sequenceCount);
|
mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(spParams, sequenceCount);
|
||||||
result = tcDownlinkPwrOff.buildPacket();
|
finishTcPrep(tcDownlinkPwrOff);
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
finishTcPrep(tcDownlinkPwrOff.getFullPacketLen());
|
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::prepareTcGetHkReport() {
|
ReturnValue_t PlocMpsocHandler::prepareTcGetHkReport() {
|
||||||
mpsoc::TcGetHkReport tcGetHkReport(spParams, sequenceCount);
|
mpsoc::TcGetHkReport tcGetHkReport(spParams, sequenceCount);
|
||||||
ReturnValue_t result = tcGetHkReport.buildPacket();
|
finishTcPrep(tcGetHkReport);
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
finishTcPrep(tcGetHkReport.getFullPacketLen());
|
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::prepareTcReplayWriteSequence(const uint8_t* commandData,
|
ReturnValue_t PlocMpsocHandler::prepareTcReplayWriteSequence(const uint8_t* commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
|
||||||
mpsoc::TcReplayWriteSeq tcReplayWriteSeq(spParams, sequenceCount);
|
mpsoc::TcReplayWriteSeq tcReplayWriteSeq(spParams, sequenceCount);
|
||||||
result = tcReplayWriteSeq.buildPacket(commandData, commandDataLen);
|
finishTcPrep(tcReplayWriteSeq);
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
finishTcPrep(tcReplayWriteSeq.getFullPacketLen());
|
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::prepareTcModeReplay() {
|
ReturnValue_t PlocMpsocHandler::prepareTcModeReplay() {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
|
||||||
mpsoc::TcModeReplay tcModeReplay(spParams, sequenceCount);
|
mpsoc::TcModeReplay tcModeReplay(spParams, sequenceCount);
|
||||||
result = tcModeReplay.buildPacket();
|
finishTcPrep(tcModeReplay);
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
finishTcPrep(tcModeReplay.getFullPacketLen());
|
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::prepareTcModeIdle() {
|
ReturnValue_t PlocMpsocHandler::prepareTcModeIdle() {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
|
||||||
mpsoc::TcModeIdle tcModeIdle(spParams, sequenceCount);
|
mpsoc::TcModeIdle tcModeIdle(spParams, sequenceCount);
|
||||||
result = tcModeIdle.buildPacket();
|
finishTcPrep(tcModeIdle);
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
finishTcPrep(tcModeIdle.getFullPacketLen());
|
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData,
|
ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
|
||||||
mpsoc::TcCamcmdSend tcCamCmdSend(spParams, sequenceCount);
|
mpsoc::TcCamcmdSend tcCamCmdSend(spParams, sequenceCount);
|
||||||
result = tcCamCmdSend.buildPacket(commandData, commandDataLen);
|
finishTcPrep(tcCamCmdSend);
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
finishTcPrep(tcCamCmdSend.getFullPacketLen());
|
|
||||||
nextReplyId = mpsoc::TM_CAM_CMD_RPT;
|
nextReplyId = mpsoc::TM_CAM_CMD_RPT;
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
@ -705,62 +671,59 @@ ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData,
|
|||||||
ReturnValue_t PlocMpsocHandler::prepareTcCamTakePic(const uint8_t* commandData,
|
ReturnValue_t PlocMpsocHandler::prepareTcCamTakePic(const uint8_t* commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount);
|
mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount);
|
||||||
ReturnValue_t result = tcCamTakePic.buildPacket(commandData, commandDataLen);
|
finishTcPrep(tcCamTakePic);
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
finishTcPrep(tcCamTakePic.getFullPacketLen());
|
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::prepareTcSimplexSendFile(const uint8_t* commandData,
|
ReturnValue_t PlocMpsocHandler::prepareTcSimplexSendFile(const uint8_t* commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount);
|
mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount);
|
||||||
ReturnValue_t result = tcSimplexSendFile.buildPacket(commandData, commandDataLen);
|
ReturnValue_t result = tcSimplexSendFile.setPayload(commandData, commandDataLen);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
finishTcPrep(tcSimplexSendFile.getFullPacketLen());
|
finishTcPrep(tcSimplexSendFile);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::prepareTcGetDirContent(const uint8_t* commandData,
|
ReturnValue_t PlocMpsocHandler::prepareTcGetDirContent(const uint8_t* commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
mpsoc::TcGetDirContent tcGetDirContent(spParams, sequenceCount);
|
mpsoc::TcGetDirContent tcGetDirContent(spParams, sequenceCount);
|
||||||
ReturnValue_t result = tcGetDirContent.buildPacket(commandData, commandDataLen);
|
ReturnValue_t result = tcGetDirContent.setPayload(commandData, commandDataLen);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
finishTcPrep(tcGetDirContent.getFullPacketLen());
|
finishTcPrep(tcGetDirContent);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData,
|
ReturnValue_t PlocMpsocHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount);
|
mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount);
|
||||||
ReturnValue_t result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen);
|
ReturnValue_t result = tcDownlinkDataModulate.setPayload(commandData, commandDataLen);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
finishTcPrep(tcDownlinkDataModulate.getFullPacketLen());
|
finishTcPrep(tcDownlinkDataModulate);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::prepareTcModeSnapshot() {
|
ReturnValue_t PlocMpsocHandler::prepareTcModeSnapshot() {
|
||||||
mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount);
|
mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount);
|
||||||
ReturnValue_t result = tcModeSnapshot.buildPacket();
|
finishTcPrep(tcModeSnapshot);
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
finishTcPrep(tcModeSnapshot.getFullPacketLen());
|
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlocMpsocHandler::finishTcPrep(size_t packetLen) {
|
ReturnValue_t PlocMpsocHandler::finishTcPrep(mpsoc::TcBase& tcBase) {
|
||||||
nextReplyId = mpsoc::ACK_REPORT;
|
nextReplyId = mpsoc::ACK_REPORT;
|
||||||
|
ReturnValue_t result = tcBase.finishPacket();
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
rawPacket = commandBuffer;
|
rawPacket = commandBuffer;
|
||||||
rawPacketLen = packetLen;
|
rawPacketLen = tcBase.getFullPacketLen();
|
||||||
sequenceCount++;
|
sequenceCount++;
|
||||||
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
|
ReturnValue_t PlocMpsocHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
|
||||||
|
@ -214,7 +214,7 @@ class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF {
|
|||||||
ReturnValue_t prepareTcSimplexSendFile(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 prepareTcDownlinkDataModulate(const uint8_t* commandData, size_t commandDataLen);
|
||||||
ReturnValue_t prepareTcModeSnapshot();
|
ReturnValue_t prepareTcModeSnapshot();
|
||||||
void finishTcPrep(size_t packetLen);
|
ReturnValue_t finishTcPrep(mpsoc::TcBase& tcBase);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function checks the crc of the received PLOC reply.
|
* @brief This function checks the crc of the received PLOC reply.
|
||||||
|
@ -207,7 +207,13 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
|
|||||||
}
|
}
|
||||||
(*sequenceCount)++;
|
(*sequenceCount)++;
|
||||||
mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount);
|
mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount);
|
||||||
result = flashReadRequest.buildPacket(nextReadSize);
|
result = flashReadRequest.setPayload(nextReadSize);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||||
|
flashfclose();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = flashReadRequest.finishPacket();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||||
flashfclose();
|
flashfclose();
|
||||||
@ -235,7 +241,11 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode)
|
|||||||
spParams.buf = commandBuffer;
|
spParams.buf = commandBuffer;
|
||||||
(*sequenceCount)++;
|
(*sequenceCount)++;
|
||||||
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
|
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
|
||||||
ReturnValue_t result = flashFopen.createPacket(flashReadAndWrite.mpsocFile, mode);
|
ReturnValue_t result = flashFopen.setPayload(flashReadAndWrite.mpsocFile, mode);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = flashFopen.finishPacket();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -239,47 +239,23 @@ class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF {
|
|||||||
*/
|
*/
|
||||||
TcBase(ploc::SpTcParams params, uint16_t apid, uint16_t sequenceCount)
|
TcBase(ploc::SpTcParams params, uint16_t apid, uint16_t sequenceCount)
|
||||||
: ploc::SpTcBase(params, apid, 0, sequenceCount) {
|
: ploc::SpTcBase(params, apid, 0, sequenceCount) {
|
||||||
|
payloadStart = spParams.buf + ccsds::HEADER_LEN;
|
||||||
spParams.setFullPayloadLen(INIT_LENGTH);
|
spParams.setFullPayloadLen(INIT_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t buildPacket() { return buildPacket(nullptr, 0); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Function to initialize the space packet
|
* @brief Function to finsh and write the space packet. It is expected that the user has
|
||||||
*
|
* set the payload fields in the child class*
|
||||||
* @param commandData Pointer to command specific data
|
|
||||||
* @param commandDataLen Length of command data
|
|
||||||
*
|
|
||||||
* @return returnvalue::OK if packet creation was successful, otherwise error return value
|
* @return returnvalue::OK if packet creation was successful, otherwise error return value
|
||||||
*/
|
*/
|
||||||
ReturnValue_t buildPacket(const uint8_t* commandData, size_t commandDataLen) {
|
ReturnValue_t finishPacket() {
|
||||||
payloadStart = spParams.buf + ccsds::HEADER_LEN;
|
|
||||||
ReturnValue_t res;
|
|
||||||
if (commandData != nullptr and commandDataLen > 0) {
|
|
||||||
res = initPacket(commandData, commandDataLen);
|
|
||||||
if (res != returnvalue::OK) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateSpFields();
|
updateSpFields();
|
||||||
res = checkSizeAndSerializeHeader();
|
ReturnValue_t res = checkSizeAndSerializeHeader();
|
||||||
if (res != returnvalue::OK) {
|
if (res != returnvalue::OK) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
return calcAndSetCrc();
|
return calcAndSetCrc();
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
virtual ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
|
||||||
return returnvalue::OK;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -297,8 +273,7 @@ class TcMemRead : public TcBase {
|
|||||||
|
|
||||||
uint16_t getMemLen() const { return memLen; }
|
uint16_t getMemLen() const { return memLen; }
|
||||||
|
|
||||||
protected:
|
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
result = lengthCheck(commandDataLen);
|
result = lengthCheck(commandDataLen);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
@ -344,8 +319,7 @@ class TcMemWrite : public TcBase {
|
|||||||
TcMemWrite(ploc::SpTcParams params, uint16_t sequenceCount)
|
TcMemWrite(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||||
: TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {}
|
: TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {}
|
||||||
|
|
||||||
protected:
|
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
result = lengthCheck(commandDataLen);
|
result = lengthCheck(commandDataLen);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
@ -392,7 +366,7 @@ class FlashFopen : public TcBase {
|
|||||||
FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount)
|
FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||||
: TcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
|
: TcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
|
||||||
|
|
||||||
ReturnValue_t createPacket(std::string filename, FileAccessMode mode) {
|
ReturnValue_t setPayload(std::string filename, FileAccessMode mode) {
|
||||||
accessMode = mode;
|
accessMode = mode;
|
||||||
size_t nameSize = filename.size();
|
size_t nameSize = filename.size();
|
||||||
spParams.setFullPayloadLen(256 + sizeof(uint8_t) + CRC_SIZE);
|
spParams.setFullPayloadLen(256 + sizeof(uint8_t) + CRC_SIZE);
|
||||||
@ -404,8 +378,7 @@ class FlashFopen : public TcBase {
|
|||||||
payloadStart[nameSize] = NULL_TERMINATOR;
|
payloadStart[nameSize] = NULL_TERMINATOR;
|
||||||
payloadStart[255] = NULL_TERMINATOR;
|
payloadStart[255] = NULL_TERMINATOR;
|
||||||
payloadStart[256] = static_cast<uint8_t>(accessMode);
|
payloadStart[256] = static_cast<uint8_t>(accessMode);
|
||||||
updateSpFields();
|
return returnvalue::OK;
|
||||||
return calcAndSetCrc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -465,7 +438,7 @@ class TcFlashRead : public TcBase {
|
|||||||
TcFlashRead(ploc::SpTcParams params, uint16_t sequenceCount)
|
TcFlashRead(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||||
: TcBase(params, apid::TC_FLASHWRITE, sequenceCount) {}
|
: TcBase(params, apid::TC_FLASHWRITE, sequenceCount) {}
|
||||||
|
|
||||||
ReturnValue_t buildPacket(uint32_t readLen) {
|
ReturnValue_t setPayload(uint32_t readLen) {
|
||||||
if (readLen > MAX_FLASH_READ_DATA_SIZE) {
|
if (readLen > MAX_FLASH_READ_DATA_SIZE) {
|
||||||
sif::error << "TcFlashRead: Read length " << readLen << " too large" << std::endl;
|
sif::error << "TcFlashRead: Read length " << readLen << " too large" << std::endl;
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
@ -505,7 +478,7 @@ class TcFlashDelete : public TcBase {
|
|||||||
TcFlashDelete(ploc::SpTcParams params, uint16_t sequenceCount)
|
TcFlashDelete(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||||
: TcBase(params, apid::TC_FLASHDELETE, sequenceCount) {}
|
: TcBase(params, apid::TC_FLASHDELETE, sequenceCount) {}
|
||||||
|
|
||||||
ReturnValue_t buildPacket(std::string filename) {
|
ReturnValue_t setPayload(std::string filename) {
|
||||||
size_t nameSize = filename.size();
|
size_t nameSize = filename.size();
|
||||||
spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
||||||
auto res = checkPayloadLen();
|
auto res = checkPayloadLen();
|
||||||
@ -544,8 +517,7 @@ class TcReplayStart : public TcBase {
|
|||||||
TcReplayStart(ploc::SpTcParams params, uint16_t sequenceCount)
|
TcReplayStart(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||||
: TcBase(params, apid::TC_REPLAY_START, sequenceCount) {}
|
: TcBase(params, apid::TC_REPLAY_START, sequenceCount) {}
|
||||||
|
|
||||||
protected:
|
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
spParams.setFullPayloadLen(commandDataLen + CRC_SIZE);
|
spParams.setFullPayloadLen(commandDataLen + CRC_SIZE);
|
||||||
result = lengthCheck(commandDataLen);
|
result = lengthCheck(commandDataLen);
|
||||||
@ -593,8 +565,7 @@ class TcDownlinkPwrOn : public TcBase {
|
|||||||
TcDownlinkPwrOn(ploc::SpTcParams params, uint16_t sequenceCount)
|
TcDownlinkPwrOn(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||||
: TcBase(params, apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
|
: TcBase(params, apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
|
||||||
|
|
||||||
protected:
|
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
result = lengthCheck(commandDataLen);
|
result = lengthCheck(commandDataLen);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
@ -667,7 +638,7 @@ class TcGetDirContent : public TcBase {
|
|||||||
TcGetDirContent(ploc::SpTcParams params, uint16_t sequenceCount)
|
TcGetDirContent(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||||
: TcBase(params, apid::TC_FLASH_GET_DIRECTORY_CONTENT, sequenceCount) {}
|
: TcBase(params, apid::TC_FLASH_GET_DIRECTORY_CONTENT, sequenceCount) {}
|
||||||
|
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
// Yeah it needs to be 256.. even if the path is shorter.
|
// Yeah it needs to be 256.. even if the path is shorter.
|
||||||
spParams.setFullPayloadLen(256 + CRC_SIZE);
|
spParams.setFullPayloadLen(256 + CRC_SIZE);
|
||||||
@ -700,8 +671,7 @@ class TcReplayWriteSeq : public TcBase {
|
|||||||
TcReplayWriteSeq(ploc::SpTcParams params, uint16_t sequenceCount)
|
TcReplayWriteSeq(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||||
: TcBase(params, apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
|
: TcBase(params, apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
|
||||||
|
|
||||||
protected:
|
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
spParams.setFullPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
spParams.setFullPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
||||||
result = lengthCheck(commandDataLen);
|
result = lengthCheck(commandDataLen);
|
||||||
@ -828,7 +798,7 @@ class TcCamTakePic : public TcBase {
|
|||||||
TcCamTakePic(ploc::SpTcParams params, uint16_t sequenceCount)
|
TcCamTakePic(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||||
: TcBase(params, apid::TC_CAM_TAKE_PIC, sequenceCount) {}
|
: TcBase(params, apid::TC_CAM_TAKE_PIC, sequenceCount) {}
|
||||||
|
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
if (commandDataLen > MAX_DATA_LENGTH) {
|
if (commandDataLen > MAX_DATA_LENGTH) {
|
||||||
return INVALID_LENGTH;
|
return INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
@ -857,7 +827,7 @@ class TcSimplexSendFile : public TcBase {
|
|||||||
TcSimplexSendFile(ploc::SpTcParams params, uint16_t sequenceCount)
|
TcSimplexSendFile(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||||
: TcBase(params, apid::TC_SIMPLEX_SEND_FILE, sequenceCount) {}
|
: TcBase(params, apid::TC_SIMPLEX_SEND_FILE, sequenceCount) {}
|
||||||
|
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
if (commandDataLen > MAX_DATA_LENGTH) {
|
if (commandDataLen > MAX_DATA_LENGTH) {
|
||||||
return INVALID_LENGTH;
|
return INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
@ -882,7 +852,7 @@ class TcDownlinkDataModulate : public TcBase {
|
|||||||
TcDownlinkDataModulate(ploc::SpTcParams params, uint16_t sequenceCount)
|
TcDownlinkDataModulate(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||||
: TcBase(params, apid::TC_DOWNLINK_DATA_MODULATE, sequenceCount) {}
|
: TcBase(params, apid::TC_DOWNLINK_DATA_MODULATE, sequenceCount) {}
|
||||||
|
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
if (commandDataLen > MAX_DATA_LENGTH) {
|
if (commandDataLen > MAX_DATA_LENGTH) {
|
||||||
return INVALID_LENGTH;
|
return INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
@ -901,7 +871,7 @@ class TcCamcmdSend : public TcBase {
|
|||||||
: TcBase(params, apid::TC_CAM_CMD_SEND, sequenceCount) {}
|
: TcBase(params, apid::TC_CAM_CMD_SEND, sequenceCount) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
if (commandDataLen > MAX_DATA_LENGTH) {
|
if (commandDataLen > MAX_DATA_LENGTH) {
|
||||||
return INVALID_LENGTH;
|
return INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user