From 0bc7ddf38ecc055bdf0d8e28f6adcdd910030f1b Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 13 Feb 2023 13:28:13 +0100 Subject: [PATCH 1/8] Added the following MPSoC commands: * TcCamTakePic * TcSimplexSendFile * TcDownlinkDataModulate Pending: Test commands with MPSoC --- .../devicedefinitions/PlocMPSoCDefinitions.h | 84 ++++++++++++++++++- linux/devices/ploc/PlocMPSoCHandler.cpp | 48 +++++++++++ linux/devices/ploc/PlocMPSoCHandler.h | 3 + 3 files changed, 134 insertions(+), 1 deletion(-) diff --git a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h index 9cb609bf..1b9ea6b9 100644 --- a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -31,6 +31,9 @@ static const DeviceCommandId_t TC_MODE_IDLE = 18; static const DeviceCommandId_t TM_CAM_CMD_RPT = 19; static const DeviceCommandId_t SET_UART_TX_TRISTATE = 20; 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; // Will reset the sequence count of the OBSW static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50; @@ -50,14 +53,18 @@ static const uint16_t TC_REPLAY_WRITE_SEQUENCE = 0x112; static const uint16_t TC_DOWNLINK_PWR_ON = 0x113; static const uint16_t TC_MEM_WRITE = 0x114; 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_FLASHFOPEN = 0x119; static const uint16_t TC_FLASHFCLOSE = 0x11A; 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_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_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 ACK_SUCCESS = 0x400; static const uint16_t ACK_FAILURE = 0x401; @@ -646,6 +653,81 @@ class TcModeIdle : public TcBase { : TcBase(params, apid::TC_MODE_IDLE, 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(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); + std::memcpy(payloadStart, commandData, commandDataLen); + return returnvalue::OK; + } + + private: + static const size_t MAX_DATA_LENGTH = 286; + static const size_t PARAMETER_SIZE = 35; +}; + +/** + * @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(commandData)); + if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) { + return FILENAME_TOO_LONG; + } + spParams.setFullPayloadLen(commandDataLen); + 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); + std::memcpy(payloadStart, commandData, commandDataLen); + return returnvalue::OK; + } + + private: + static const size_t MAX_DATA_LENGTH = 11; +}; + class TcCamcmdSend : public TcBase { public: TcCamcmdSend(ploc::SpTcParams params, uint16_t sequenceCount) diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index b1914111..8218990e 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -257,6 +257,18 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device result = prepareTcCamCmdSend(commandData, commandDataLen); 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; + } default: sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" << std::endl; @@ -537,6 +549,42 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData, 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; +} + void PlocMPSoCHandler::finishTcPrep(size_t packetLen) { nextReplyId = mpsoc::ACK_REPORT; rawPacket = commandBuffer; diff --git a/linux/devices/ploc/PlocMPSoCHandler.h b/linux/devices/ploc/PlocMPSoCHandler.h index 99a12515..ddd5b548 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.h +++ b/linux/devices/ploc/PlocMPSoCHandler.h @@ -169,6 +169,9 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen); 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); void finishTcPrep(size_t packetLen); /** From 58f29e16c54193cf3ea0460dd375ba68bfce39dd Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 14 Feb 2023 14:00:53 +0100 Subject: [PATCH 2/8] mode snapshot command --- .../devices/devicedefinitions/PlocMPSoCDefinitions.h | 10 ++++++++++ linux/devices/ploc/PlocMPSoCHandler.cpp | 11 +++++++++++ linux/devices/ploc/PlocMPSoCHandler.h | 1 + tmtc | 2 +- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h index 1b9ea6b9..1896eb5d 100644 --- a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -34,6 +34,7 @@ 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 static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50; @@ -653,6 +654,15 @@ class TcModeIdle : public TcBase { : 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 */ diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index 8218990e..07153878 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -585,6 +585,17 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* com 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) { nextReplyId = mpsoc::ACK_REPORT; rawPacket = commandBuffer; diff --git a/linux/devices/ploc/PlocMPSoCHandler.h b/linux/devices/ploc/PlocMPSoCHandler.h index ddd5b548..f14fbe9d 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.h +++ b/linux/devices/ploc/PlocMPSoCHandler.h @@ -172,6 +172,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { 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); /** diff --git a/tmtc b/tmtc index 9b7471e9..8d036bcd 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 9b7471e9097edd410995ba0c76125b626440d9be +Subproject commit 8d036bcd4fed1211ad5b15ddae7b42e61e22fcfd From 90b4b7c0f4ca1097082daabeda6c6bdbbb109966 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 28 Feb 2023 09:13:41 +0100 Subject: [PATCH 3/8] bugfixes in mpsoc commands --- .../devicedefinitions/PlocMPSoCDefinitions.h | 2 +- linux/devices/ploc/PlocMPSoCHandler.cpp | 29 +++++++++++++++++++ tmtc | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h index 1896eb5d..fef8015d 100644 --- a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -689,7 +689,7 @@ class TcCamTakePic : public TcBase { private: static const size_t MAX_DATA_LENGTH = 286; - static const size_t PARAMETER_SIZE = 35; + static const size_t PARAMETER_SIZE = 28; }; /** diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index 07153878..7bb076e0 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -1,5 +1,7 @@ #include "PlocMPSoCHandler.h" +#include + #include "OBSWConfig.h" #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/globalfunctions/CRC.h" @@ -269,6 +271,10 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device result = prepareTcDownlinkDataModulate(commandData, commandDataLen); break; } + case (mpsoc::TC_MODE_SNAPSHOT): { + result = prepareTcModeSnapshot(); + break; + } default: sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" << std::endl; @@ -300,6 +306,10 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { this->insertInCommandMap(mpsoc::TC_CAM_CMD_SEND); this->insertInCommandMap(mpsoc::RELEASE_UART_TX); 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::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT); this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT); @@ -753,6 +763,10 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator case mpsoc::TC_REPLAY_WRITE_SEQUENCE: case mpsoc::TC_MODE_REPLAY: 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; break; case mpsoc::TC_MEM_READ: { @@ -976,6 +990,18 @@ void PlocMPSoCHandler::disableAllReplies() { /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ switch (commandId) { 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; case TC_MEM_READ: { iter = deviceReplyMap.find(TM_MEMORY_READ_REPORT); @@ -1144,6 +1170,9 @@ std::string PlocMPSoCHandler::getStatusString(uint16_t status) { break; } default: + std::stringstream ss; + ss << "0x" << std::hex << status; + return ss.str(); break; } return ""; diff --git a/tmtc b/tmtc index 9720fcdd..56630b05 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 9720fcddecb04b228dc5eb0d064f15a12ef8daca +Subproject commit 56630b05c2d49651823892876c80d0885b25b9b4 From 809626b6e366fe0f53e44e00e7c35d302ab5b9df Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 28 Feb 2023 18:12:22 +0100 Subject: [PATCH 4/8] * fixed invalid overwriting of downlink power on command * overwriting of delay cycles for cam take pic command * extended parsing of verification status codes --- .../devicedefinitions/PlocMPSoCDefinitions.h | 2 ++ linux/devices/ploc/PlocMPSoCHandler.cpp | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h index fef8015d..babed275 100644 --- a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -115,8 +115,10 @@ static const size_t MAX_DATA_SIZE = 1016; static const uint16_t TC_WRITE_SEQ_EXECUTION_DELAY = 80; // 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_CAM_TAKE_PIC_EXECUTION_DELAY = 20; namespace status_code { +static const uint16_t DEFAULT_ERROR_CODE = 0x1; static const uint16_t UNKNOWN_APID = 0x5DD; static const uint16_t INCORRECT_LENGTH = 0x5DE; static const uint16_t INCORRECT_CRC = 0x5DF; diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index 7bb076e0..7f22b14d 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -827,7 +827,13 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator case mpsoc::TC_DOWNLINK_PWR_ON: { DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT); // - iter->second.delayCycles = mpsoc::TC_DOWNLINK_PWR_ON; + iter->second.delayCycles = mpsoc::TC_DOWNLINK_PWR_ON_EXECUTION_DELAY; + 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; } default: @@ -1133,6 +1139,10 @@ std::string PlocMPSoCHandler::getStatusString(uint16_t status) { return "Flash file already closed"; break; } + case (mpsoc::status_code::FLASH_FILE_OPEN_FAILED): { + return "Flash file open failed"; + break; + } case (mpsoc::status_code::FLASH_FILE_NOT_OPEN): { return "Flash file not open"; break; @@ -1169,6 +1179,10 @@ std::string PlocMPSoCHandler::getStatusString(uint16_t status) { return "Flash uncorrectable mismatch"; break; } + case (mpsoc::status_code::DEFAULT_ERROR_CODE): { + return "Default error code"; + break; + } default: std::stringstream ss; ss << "0x" << std::hex << status; From 6004233c67117843e0b916716fd6b59b542d4060 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 28 Feb 2023 19:56:42 +0100 Subject: [PATCH 5/8] bugfixes in some mpsoc TCs --- linux/devices/devicedefinitions/PlocMPSoCDefinitions.h | 7 ++++--- linux/devices/ploc/PlocMPSoCHandler.cpp | 7 +++++-- mission/devices/devicedefinitions/SpBase.h | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h index babed275..7895adf9 100644 --- a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -116,6 +116,7 @@ static const uint16_t TC_WRITE_SEQ_EXECUTION_DELAY = 80; // 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_CAM_TAKE_PIC_EXECUTION_DELAY = 20; +static const uint16_t TC_SIMPLEX_SEND_FILE_DELAY = 80; namespace status_code { static const uint16_t DEFAULT_ERROR_CODE = 0x1; @@ -684,7 +685,7 @@ class TcCamTakePic : public TcBase { if (commandDataLen - (fileName.size() + sizeof(NULL_TERMINATOR)) != PARAMETER_SIZE) { return INVALID_LENGTH; } - spParams.setFullPayloadLen(commandDataLen); + spParams.setFullPayloadLen(commandDataLen + CRC_SIZE); std::memcpy(payloadStart, commandData, commandDataLen); return returnvalue::OK; } @@ -710,7 +711,7 @@ class TcSimplexSendFile : public TcBase { if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) { return FILENAME_TOO_LONG; } - spParams.setFullPayloadLen(commandDataLen); + spParams.setFullPayloadLen(commandDataLen + CRC_SIZE); std::memcpy(payloadStart, commandData, commandDataLen); return returnvalue::OK; } @@ -731,7 +732,7 @@ class TcDownlinkDataModulate : public TcBase { if (commandDataLen > MAX_DATA_LENGTH) { return INVALID_LENGTH; } - spParams.setFullPayloadLen(commandDataLen); + spParams.setFullPayloadLen(commandDataLen + CRC_SIZE); std::memcpy(payloadStart, commandData, commandDataLen); return returnvalue::OK; } diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index 7f22b14d..f756bff9 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -826,16 +826,19 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator } case mpsoc::TC_DOWNLINK_PWR_ON: { DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT); - // iter->second.delayCycles = mpsoc::TC_DOWNLINK_PWR_ON_EXECUTION_DELAY; 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; + } default: break; } diff --git a/mission/devices/devicedefinitions/SpBase.h b/mission/devices/devicedefinitions/SpBase.h index 11d67a59..8678cf9d 100644 --- a/mission/devices/devicedefinitions/SpBase.h +++ b/mission/devices/devicedefinitions/SpBase.h @@ -14,6 +14,7 @@ struct SpTcParams { SpTcParams(SpacePacketCreator& creator, uint8_t* buf, size_t 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_; } SpacePacketCreator& creator; From b14038e29c3f8b165b2325140b28703ae1676a3a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Mar 2023 11:04:49 +0100 Subject: [PATCH 6/8] re-point fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 9a8d775e..4d6f6e6b 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9a8d775eb1a8788ad844215bf2a42d9f707767c0 +Subproject commit 4d6f6e6b23b5c0486dad6be8abba7681114a05fe From ace01e2742303a6f6c6cfa5d47c226f1ce20177b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Mar 2023 11:05:21 +0100 Subject: [PATCH 7/8] afmt --- .../devicedefinitions/PlocMPSoCDefinitions.h | 72 +++++++++---------- linux/devices/ploc/PlocMPSoCHandler.cpp | 18 ++--- mission/controller/acs/ActuatorCmd.cpp | 2 +- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h index 7895adf9..ef769eef 100644 --- a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -675,24 +675,24 @@ class TcCamTakePic : public TcBase { : 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(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; + if (commandDataLen > MAX_DATA_LENGTH) { + return INVALID_LENGTH; } + std::string fileName(reinterpret_cast(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; + private: + static const size_t MAX_DATA_LENGTH = 286; + static const size_t PARAMETER_SIZE = 28; }; /** @@ -704,20 +704,20 @@ class TcSimplexSendFile : public TcBase { : 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(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; + if (commandDataLen > MAX_DATA_LENGTH) { + return INVALID_LENGTH; } + std::string fileName(reinterpret_cast(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; + private: + static const size_t MAX_DATA_LENGTH = 256; }; /** @@ -729,16 +729,16 @@ class TcDownlinkDataModulate : public TcBase { : 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; + 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; + private: + static const size_t MAX_DATA_LENGTH = 11; }; class TcCamcmdSend : public TcBase { diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index f756bff9..5b53e089 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -260,20 +260,20 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device break; } case (mpsoc::TC_CAM_TAKE_PIC): { - result = prepareTcCamTakePic(commandData, commandDataLen); + result = prepareTcCamTakePic(commandData, commandDataLen); break; } case (mpsoc::TC_SIMPLEX_SEND_FILE): { - result = prepareTcSimplexSendFile(commandData, commandDataLen); + result = prepareTcSimplexSendFile(commandData, commandDataLen); break; } case (mpsoc::TC_DOWNLINK_DATA_MODULATE): { - result = prepareTcDownlinkDataModulate(commandData, commandDataLen); + result = prepareTcDownlinkDataModulate(commandData, commandDataLen); break; } case (mpsoc::TC_MODE_SNAPSHOT): { - result = prepareTcModeSnapshot(); - break; + result = prepareTcModeSnapshot(); + break; } default: sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" @@ -572,7 +572,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData, } ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandData, - size_t commandDataLen) { + size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount); result = tcSimplexSendFile.buildPacket(commandData, commandDataLen); @@ -1187,9 +1187,9 @@ std::string PlocMPSoCHandler::getStatusString(uint16_t status) { break; } default: - std::stringstream ss; - ss << "0x" << std::hex << status; - return ss.str(); + std::stringstream ss; + ss << "0x" << std::hex << status; + return ss.str(); break; } return ""; diff --git a/mission/controller/acs/ActuatorCmd.cpp b/mission/controller/acs/ActuatorCmd.cpp index 457cacce..d2fe2d65 100644 --- a/mission/controller/acs/ActuatorCmd.cpp +++ b/mission/controller/acs/ActuatorCmd.cpp @@ -49,7 +49,7 @@ void ActuatorCmd::cmdSpeedToRws(int32_t speedRw0, int32_t speedRw1, int32_t spee } else if (rwCmdSpeed[i] < -maxRwSpeed) { rwCmdSpeed[i] = -maxRwSpeed; } - } + } } void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentActuator, From 4a386ae64198c55832342190c12b5eb25f974db3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 13:08:22 +0100 Subject: [PATCH 8/8] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index e862df4d..f21ee37a 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit e862df4d06a502b059315bc6254a3b513686b52e +Subproject commit f21ee37a01379907ca72932264e5236a6c30f8a1