diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 72f2355f..29656c59 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -247,6 +247,10 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device result = prepareTcReplayWriteSequence(commandData, commandDataLen); break; } + case (mpsoc::TC_GET_HK_REPORT): { + result = prepareTcGetHkReport(); + break; + } case (mpsoc::TC_MODE_REPLAY): { result = prepareTcModeReplay(); break; @@ -304,6 +308,7 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { this->insertInCommandMap(mpsoc::TC_MODE_REPLAY); this->insertInCommandMap(mpsoc::TC_MODE_IDLE); this->insertInCommandMap(mpsoc::TC_CAM_CMD_SEND); + this->insertInCommandMap(mpsoc::TC_GET_HK_REPORT); this->insertInCommandMap(mpsoc::RELEASE_UART_TX); this->insertInCommandMap(mpsoc::SET_UART_TX_TRISTATE); this->insertInCommandMap(mpsoc::TC_CAM_TAKE_PIC); @@ -313,6 +318,7 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { 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); + this->insertInReplyMap(mpsoc::TM_GET_HK_REPORT, 2, nullptr, 0); this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, mpsoc::SP_MAX_SIZE); } @@ -346,9 +352,15 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain break; case (mpsoc::apid::TM_CAM_CMD_RPT): *foundLen = spacePacket.getFullPacketLen(); - tmCamCmdRpt.rememberSpacePacketSize = *foundLen; + foundPacketLen = *foundLen; *foundId = mpsoc::TM_CAM_CMD_RPT; break; + case (mpsoc::apid::TM_HK_GET_REPORT): { + *foundLen = spacePacket.getFullPacketLen(); + foundPacketLen = *foundLen; + *foundId = mpsoc::TM_GET_HK_REPORT; + break; + } case (mpsoc::apid::EXE_SUCCESS): *foundLen = mpsoc::SIZE_EXE_REPORT; *foundId = mpsoc::EXE_REPORT; @@ -386,6 +398,10 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const result = handleMemoryReadReport(packet); break; } + case (mpsoc::TM_GET_HK_REPORT): { + result = handleGetHkReport(packet); + break; + } case (mpsoc::TM_CAM_CMD_RPT): { result = handleCamCmdRpt(packet); break; @@ -512,6 +528,17 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() { return returnvalue::OK; } +ReturnValue_t PlocMPSoCHandler::prepareTcGetHkReport() { + ReturnValue_t result = returnvalue::OK; + mpsoc::TcGetHkReport tcDownlinkPwrOff(spParams, sequenceCount); + result = tcDownlinkPwrOff.buildPacket(); + if (result != returnvalue::OK) { + return result; + } + finishTcPrep(tcDownlinkPwrOff.getFullPacketLen()); + return returnvalue::OK; +} + ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; @@ -724,17 +751,25 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { return result; } +ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) { + ReturnValue_t result = verifyPacket(data, foundPacketLen); + if (result != returnvalue::OK) { + return result; + } + SpacePacketReader packetReader(data, foundPacketLen); + return returnvalue::OK; +} + ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) { ReturnValue_t result = returnvalue::OK; - result = verifyPacket(data, tmCamCmdRpt.rememberSpacePacketSize); + ReturnValue_t result = verifyPacket(data, foundPacketLen); if (result == MPSoCReturnValuesIF::CRC_FAILURE) { sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl; } - SpacePacketReader packetReader(data, tmCamCmdRpt.rememberSpacePacketSize); + SpacePacketReader packetReader(data, foundPacketLen); const uint8_t* dataFieldPtr = data + mpsoc::SPACE_PACKET_HEADER_SIZE + sizeof(uint16_t); - std::string camCmdRptMsg( - reinterpret_cast(dataFieldPtr), - tmCamCmdRpt.rememberSpacePacketSize - mpsoc::SPACE_PACKET_HEADER_SIZE - sizeof(uint16_t) - 3); + std::string camCmdRptMsg(reinterpret_cast(dataFieldPtr), + foundPacketLen - mpsoc::SPACE_PACKET_HEADER_SIZE - sizeof(uint16_t) - 3); #if OBSW_DEBUG_PLOC_MPSOC == 1 uint8_t ackValue = *(packetReader.getFullData() + packetReader.getFullPacketLen() - 2); sif::info << "PlocMPSoCHandler: CamCmdRpt message: " << camCmdRptMsg << std::endl; diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index 10e6bd5d..e11f05eb 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -138,17 +138,12 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { TmMemReadReport tmMemReadReport; - struct TmCamCmdRpt { - size_t rememberSpacePacketSize = 0; - }; - - TmCamCmdRpt tmCamCmdRpt; - struct TelemetryBuffer { uint16_t length = 0; uint8_t buffer[mpsoc::SP_MAX_SIZE]; }; + size_t foundPacketLen = 0; TelemetryBuffer tmBuffer; enum class PowerState { OFF, BOOTING, SHUTDOWN, ON }; @@ -167,6 +162,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { ReturnValue_t prepareTcReplayStop(); ReturnValue_t prepareTcDownlinkPwrOn(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcDownlinkPwrOff(); + ReturnValue_t prepareTcGetHkReport(); ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcModeIdle(); @@ -213,6 +209,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { */ ReturnValue_t handleMemoryReadReport(const uint8_t* data); + ReturnValue_t handleGetHkReport(const uint8_t* data); ReturnValue_t handleCamCmdRpt(const uint8_t* data); /** diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 975dad32..e6acf4bf 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -37,6 +37,8 @@ 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; +static const DeviceCommandId_t TC_GET_HK_REPORT = 26; +static const DeviceCommandId_t TM_GET_HK_REPORT = 27; // Will reset the sequence count of the OBSW static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50; @@ -45,6 +47,7 @@ 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; static const uint16_t SIZE_TM_CAM_CMD_RPT = 18; +static constexpr size_t SIZE_TM_HK_REPORT = 369; /** * SpacePacket apids of PLOC telecommands and telemetry. @@ -65,6 +68,8 @@ 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 constexpr uint16_t TC_HK_GET_REPORT = 0x123; +static constexpr uint16_t TM_HK_GET_REPORT = 0x408; 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; @@ -561,6 +566,15 @@ class TcDownlinkPwrOn : public TcBase { } }; +/** + * @brief Class to build replay stop space packet. + */ +class TcGetHkReport : public TcBase { + public: + TcGetHkReport(ploc::SpTcParams params, uint16_t sequenceCount) + : TcBase(params, apid::TC_HK_GET_REPORT, sequenceCount) {} +}; + /** * @brief Class to build replay stop space packet. */