kenning west alder

This commit is contained in:
Robin Müller 2023-05-16 13:34:06 +02:00
parent 468fa01650
commit 4ba9ebf58f
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 65 additions and 122 deletions

View File

@ -562,11 +562,11 @@ ReturnValue_t PlocMpsocHandler::prepareTcMemWrite(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcMemWrite tcMemWrite(spParams, sequenceCount);
result = tcMemWrite.buildPacket(commandData, commandDataLen);
result = tcMemWrite.setPayload(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcMemWrite.getFullPacketLen());
finishTcPrep(tcMemWrite);
return returnvalue::OK;
}
@ -574,11 +574,11 @@ ReturnValue_t PlocMpsocHandler::prepareTcMemRead(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcMemRead tcMemRead(spParams, sequenceCount);
result = tcMemRead.buildPacket(commandData, commandDataLen);
result = tcMemRead.setPayload(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcMemRead.getFullPacketLen());
finishTcPrep(tcMemRead);
tmMemReadReport.rememberRequestedSize = tcMemRead.getMemLen() * 4 + TmMemReadReport::FIX_SIZE;
return returnvalue::OK;
}
@ -590,12 +590,12 @@ ReturnValue_t PlocMpsocHandler::prepareTcFlashDelete(const uint8_t* commandData,
}
ReturnValue_t result = returnvalue::OK;
mpsoc::TcFlashDelete tcFlashDelete(spParams, sequenceCount);
result = tcFlashDelete.buildPacket(
std::string(reinterpret_cast<const char*>(commandData), commandDataLen));
std::string filename = std::string(reinterpret_cast<const char*>(commandData), commandDataLen);
result = tcFlashDelete.setPayload(filename);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcFlashDelete.getFullPacketLen());
finishTcPrep(tcFlashDelete);
return returnvalue::OK;
}
@ -603,22 +603,17 @@ ReturnValue_t PlocMpsocHandler::prepareTcReplayStart(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcReplayStart tcReplayStart(spParams, sequenceCount);
result = tcReplayStart.buildPacket(commandData, commandDataLen);
result = tcReplayStart.setPayload(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcReplayStart.getFullPacketLen());
finishTcPrep(tcReplayStart);
return returnvalue::OK;
}
ReturnValue_t PlocMpsocHandler::prepareTcReplayStop() {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcReplayStop tcReplayStop(spParams, sequenceCount);
result = tcReplayStop.buildPacket();
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcReplayStop.getFullPacketLen());
finishTcPrep(tcReplayStop);
return returnvalue::OK;
}
@ -626,78 +621,49 @@ ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOn(const uint8_t* commandDat
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(spParams, sequenceCount);
result = tcDownlinkPwrOn.buildPacket(commandData, commandDataLen);
result = tcDownlinkPwrOn.setPayload(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcDownlinkPwrOn.getFullPacketLen());
finishTcPrep(tcDownlinkPwrOn);
return returnvalue::OK;
}
ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOff() {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(spParams, sequenceCount);
result = tcDownlinkPwrOff.buildPacket();
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcDownlinkPwrOff.getFullPacketLen());
finishTcPrep(tcDownlinkPwrOff);
return returnvalue::OK;
}
ReturnValue_t PlocMpsocHandler::prepareTcGetHkReport() {
mpsoc::TcGetHkReport tcGetHkReport(spParams, sequenceCount);
ReturnValue_t result = tcGetHkReport.buildPacket();
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcGetHkReport.getFullPacketLen());
finishTcPrep(tcGetHkReport);
return returnvalue::OK;
}
ReturnValue_t PlocMpsocHandler::prepareTcReplayWriteSequence(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcReplayWriteSeq tcReplayWriteSeq(spParams, sequenceCount);
result = tcReplayWriteSeq.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcReplayWriteSeq.getFullPacketLen());
finishTcPrep(tcReplayWriteSeq);
return returnvalue::OK;
}
ReturnValue_t PlocMpsocHandler::prepareTcModeReplay() {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcModeReplay tcModeReplay(spParams, sequenceCount);
result = tcModeReplay.buildPacket();
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcModeReplay.getFullPacketLen());
finishTcPrep(tcModeReplay);
return returnvalue::OK;
}
ReturnValue_t PlocMpsocHandler::prepareTcModeIdle() {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcModeIdle tcModeIdle(spParams, sequenceCount);
result = tcModeIdle.buildPacket();
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcModeIdle.getFullPacketLen());
finishTcPrep(tcModeIdle);
return returnvalue::OK;
}
ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcCamcmdSend tcCamCmdSend(spParams, sequenceCount);
result = tcCamCmdSend.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcCamCmdSend.getFullPacketLen());
finishTcPrep(tcCamCmdSend);
nextReplyId = mpsoc::TM_CAM_CMD_RPT;
return returnvalue::OK;
}
@ -705,62 +671,59 @@ ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData,
ReturnValue_t PlocMpsocHandler::prepareTcCamTakePic(const uint8_t* commandData,
size_t commandDataLen) {
mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount);
ReturnValue_t result = tcCamTakePic.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcCamTakePic.getFullPacketLen());
finishTcPrep(tcCamTakePic);
return returnvalue::OK;
}
ReturnValue_t PlocMpsocHandler::prepareTcSimplexSendFile(const uint8_t* commandData,
size_t commandDataLen) {
mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount);
ReturnValue_t result = tcSimplexSendFile.buildPacket(commandData, commandDataLen);
ReturnValue_t result = tcSimplexSendFile.setPayload(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcSimplexSendFile.getFullPacketLen());
finishTcPrep(tcSimplexSendFile);
return returnvalue::OK;
}
ReturnValue_t PlocMpsocHandler::prepareTcGetDirContent(const uint8_t* commandData,
size_t commandDataLen) {
mpsoc::TcGetDirContent tcGetDirContent(spParams, sequenceCount);
ReturnValue_t result = tcGetDirContent.buildPacket(commandData, commandDataLen);
ReturnValue_t result = tcGetDirContent.setPayload(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcGetDirContent.getFullPacketLen());
finishTcPrep(tcGetDirContent);
return returnvalue::OK;
}
ReturnValue_t PlocMpsocHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData,
size_t commandDataLen) {
mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount);
ReturnValue_t result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen);
ReturnValue_t result = tcDownlinkDataModulate.setPayload(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcDownlinkDataModulate.getFullPacketLen());
finishTcPrep(tcDownlinkDataModulate);
return returnvalue::OK;
}
ReturnValue_t PlocMpsocHandler::prepareTcModeSnapshot() {
mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount);
ReturnValue_t result = tcModeSnapshot.buildPacket();
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcModeSnapshot.getFullPacketLen());
finishTcPrep(tcModeSnapshot);
return returnvalue::OK;
}
void PlocMpsocHandler::finishTcPrep(size_t packetLen) {
ReturnValue_t PlocMpsocHandler::finishTcPrep(mpsoc::TcBase& tcBase) {
nextReplyId = mpsoc::ACK_REPORT;
ReturnValue_t result = tcBase.finishPacket();
if (result != returnvalue::OK) {
return result;
}
rawPacket = commandBuffer;
rawPacketLen = packetLen;
rawPacketLen = tcBase.getFullPacketLen();
sequenceCount++;
return returnvalue::OK;
}
ReturnValue_t PlocMpsocHandler::verifyPacket(const uint8_t* start, size_t foundLen) {

View File

@ -214,7 +214,7 @@ class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF {
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);
ReturnValue_t finishTcPrep(mpsoc::TcBase& tcBase);
/**
* @brief This function checks the crc of the received PLOC reply.

View File

@ -207,7 +207,13 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
}
(*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) {
std::filesystem::remove(flashReadAndWrite.obcFile, e);
flashfclose();
@ -235,7 +241,11 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode)
spParams.buf = commandBuffer;
(*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) {
return result;
}

View File

@ -239,47 +239,23 @@ class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF {
*/
TcBase(ploc::SpTcParams params, uint16_t apid, uint16_t sequenceCount)
: ploc::SpTcBase(params, apid, 0, sequenceCount) {
payloadStart = spParams.buf + ccsds::HEADER_LEN;
spParams.setFullPayloadLen(INIT_LENGTH);
}
ReturnValue_t buildPacket() { return buildPacket(nullptr, 0); }
/**
* @brief Function to initialize the space packet
*
* @param commandData Pointer to command specific data
* @param commandDataLen Length of command data
*
* @brief Function to finsh and write the space packet. It is expected that the user has
* set the payload fields in the child class*
* @return returnvalue::OK if packet creation was successful, otherwise error return value
*/
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 != returnvalue::OK) {
return res;
}
}
ReturnValue_t finishPacket() {
updateSpFields();
res = checkSizeAndSerializeHeader();
ReturnValue_t res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
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; }
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
result = lengthCheck(commandDataLen);
if (result != returnvalue::OK) {
@ -344,8 +319,7 @@ class TcMemWrite : public TcBase {
TcMemWrite(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
result = lengthCheck(commandDataLen);
if (result != returnvalue::OK) {
@ -392,7 +366,7 @@ class FlashFopen : public TcBase {
FlashFopen(ploc::SpTcParams params, uint16_t 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;
size_t nameSize = filename.size();
spParams.setFullPayloadLen(256 + sizeof(uint8_t) + CRC_SIZE);
@ -404,8 +378,7 @@ class FlashFopen : public TcBase {
payloadStart[nameSize] = NULL_TERMINATOR;
payloadStart[255] = NULL_TERMINATOR;
payloadStart[256] = static_cast<uint8_t>(accessMode);
updateSpFields();
return calcAndSetCrc();
return returnvalue::OK;
}
private:
@ -465,7 +438,7 @@ class TcFlashRead : public TcBase {
TcFlashRead(ploc::SpTcParams params, uint16_t 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) {
sif::error << "TcFlashRead: Read length " << readLen << " too large" << std::endl;
return returnvalue::FAILED;
@ -505,7 +478,7 @@ class TcFlashDelete : public TcBase {
TcFlashDelete(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_FLASHDELETE, sequenceCount) {}
ReturnValue_t buildPacket(std::string filename) {
ReturnValue_t setPayload(std::string filename) {
size_t nameSize = filename.size();
spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE);
auto res = checkPayloadLen();
@ -544,8 +517,7 @@ class TcReplayStart : public TcBase {
TcReplayStart(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_REPLAY_START, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
spParams.setFullPayloadLen(commandDataLen + CRC_SIZE);
result = lengthCheck(commandDataLen);
@ -593,8 +565,7 @@ class TcDownlinkPwrOn : public TcBase {
TcDownlinkPwrOn(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
result = lengthCheck(commandDataLen);
if (result != returnvalue::OK) {
@ -667,7 +638,7 @@ class TcGetDirContent : public TcBase {
TcGetDirContent(ploc::SpTcParams params, uint16_t 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;
// Yeah it needs to be 256.. even if the path is shorter.
spParams.setFullPayloadLen(256 + CRC_SIZE);
@ -700,8 +671,7 @@ class TcReplayWriteSeq : public TcBase {
TcReplayWriteSeq(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
spParams.setFullPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE);
result = lengthCheck(commandDataLen);
@ -828,7 +798,7 @@ class TcCamTakePic : public TcBase {
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 {
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
if (commandDataLen > MAX_DATA_LENGTH) {
return INVALID_LENGTH;
}
@ -857,7 +827,7 @@ class TcSimplexSendFile : public TcBase {
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 {
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
if (commandDataLen > MAX_DATA_LENGTH) {
return INVALID_LENGTH;
}
@ -882,7 +852,7 @@ class TcDownlinkDataModulate : public TcBase {
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 {
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
if (commandDataLen > MAX_DATA_LENGTH) {
return INVALID_LENGTH;
}
@ -901,7 +871,7 @@ class TcCamcmdSend : public TcBase {
: TcBase(params, apid::TC_CAM_CMD_SEND, sequenceCount) {}
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) {
return INVALID_LENGTH;
}