diff --git a/linux/payload/FreshSupvHandler.cpp b/linux/payload/FreshSupvHandler.cpp index f414bec6..640c5535 100644 --- a/linux/payload/FreshSupvHandler.cpp +++ b/linux/payload/FreshSupvHandler.cpp @@ -8,7 +8,9 @@ #include "eive/definitions.h" #include "eive/objects.h" +#include "fsfw/action.h" #include "fsfw/globalfunctions/arrayprinter.h" +#include "fsfw/ipc/CommandMessage.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManagerIF.h" @@ -78,6 +80,7 @@ void FreshSupvHandler::performDeviceOperation(uint8_t opCode) { buildActiveCmdKey(Apid::HK, static_cast(tc::HkId::GET_REPORT))); if (cmdIter == activeActionCmds.end() or not cmdIter->second.isPending) { spParams.buf = commandBuffer.data(); + commandedByCached = MessageQueueIF::NO_QUEUE; sendEmptyCmd(supv::GET_HK_REPORT, Apid::HK, static_cast(tc::HkId::GET_REPORT), true); } @@ -200,7 +203,7 @@ ReturnValue_t FreshSupvHandler::executeAction(ActionId_t actionId, MessageQueueI using namespace supv; // The SUPV does not have any action commands where there is no communication with the device // involved. - if(mode != MODE_ON and mode != MODE_NORMAL) { + if (mode != MODE_ON and mode != MODE_NORMAL) { return HasModesIF::INVALID_MODE; } ReturnValue_t result; @@ -392,6 +395,9 @@ ReturnValue_t FreshSupvHandler::executeAction(ActionId_t actionId, MessageQueueI result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; break; } + if (result == returnvalue::OK) { + this->commandedByCached = commandedBy; + } return result; } @@ -538,9 +544,6 @@ void FreshSupvHandler::handleTransitionToOff() { ReturnValue_t FreshSupvHandler::sendCommand(DeviceCommandId_t commandId, TcBase& tc, bool replyExpected, uint32_t cmdCountdownMs) { - if (interCmdCd.isBusy()) { - TaskFactory::delayTask(interCmdCd.getRemainingMillis()); - } if (supv::DEBUG_PLOC_SUPV) { if (not(supv::REDUCE_NORMAL_MODE_PRINTOUT and mode == MODE_NORMAL and commandId == supv::GET_HK_REPORT)) { @@ -555,6 +558,7 @@ ReturnValue_t FreshSupvHandler::sendCommand(DeviceCommandId_t commandId, TcBase& if (activeCmdIter == activeActionCmds.end()) { info.isPending = true; info.replyPacketExpected = replyExpected; + info.commandedBy = commandedByCached; activeActionCmds.emplace(buildActiveCmdKey(tc.getModuleApid(), tc.getServiceId()), info); } else { if (activeCmdIter->second.isPending) { @@ -562,6 +566,7 @@ ReturnValue_t FreshSupvHandler::sendCommand(DeviceCommandId_t commandId, TcBase& } activeCmdIter->second.isPending = true; activeCmdIter->second.commandId = commandId; + activeCmdIter->second.commandedBy = commandedByCached; activeCmdIter->second.ackRecv = false; activeCmdIter->second.ackExeRecv = false; activeCmdIter->second.replyPacketExpected = replyExpected; @@ -571,7 +576,6 @@ ReturnValue_t FreshSupvHandler::sendCommand(DeviceCommandId_t commandId, TcBase& } ReturnValue_t result = uartManager->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen()); - interCmdCd.resetTimer(); return result; } @@ -1099,10 +1103,10 @@ void FreshSupvHandler::handleEvent(EventMessage* eventMessage) { event == PlocSupvUartManager::SUPV_CONTINUE_UPDATE_SUCCESSFUL || event == PlocSupvUartManager::SUPV_MEM_CHECK_FAIL || event == PlocSupvUartManager::SUPV_MEM_CHECK_OK) { - // Wait for a short period for the uart state machine to adjust - // TaskFactory::delayTask(5); if (not isCommandAlreadyActive(supv::SHUTDOWN_MPSOC)) { - result = this->executeAction(supv::SHUTDOWN_MPSOC, MessageQueueIF::NO_QUEUE, nullptr, 0); + CommandMessage actionMsg; + ActionMessage::setCommand(&actionMsg, supv::SHUTDOWN_MPSOC, store_address_t::invalid()); + result = messageQueue->sendMessage(getCommandQueue(), &actionMsg); if (result != returnvalue::OK) { triggerEvent(supv::SUPV_MPSOC_SHUTDOWN_BUILD_FAILED); sif::warning << "PlocSupervisorHandler::handleEvent: Failed to build MPSoC shutdown " diff --git a/linux/payload/FreshSupvHandler.h b/linux/payload/FreshSupvHandler.h index 07756d41..f938a771 100644 --- a/linux/payload/FreshSupvHandler.h +++ b/linux/payload/FreshSupvHandler.h @@ -14,7 +14,7 @@ using supv::TcBase; -static constexpr bool DEBUG_PLOC_SUPV = false; +static constexpr bool DEBUG_PLOC_SUPV = true; static constexpr bool REDUCE_NORMAL_MODE_PRINTOUT = true; class FreshSupvHandler : public FreshDeviceHandlerBase { @@ -101,7 +101,7 @@ class FreshSupvHandler : public FreshDeviceHandlerBase { Countdown switchTimeout = Countdown(2000); // Vorago nees some time to boot properly Countdown bootTimeout = Countdown(supv::BOOT_TIMEOUT_MS); - Countdown interCmdCd = Countdown(supv::INTER_COMMAND_DELAY); + // Countdown interCmdCd = Countdown(supv::INTER_COMMAND_DELAY); PoolEntry adcRawEntry = PoolEntry(16); PoolEntry adcEngEntry = PoolEntry(16); @@ -136,6 +136,7 @@ class FreshSupvHandler : public FreshDeviceHandlerBase { std::array commandBuffer{}; SpacePacketCreator creator; supv::TcParams spParams = supv::TcParams(creator); + DeviceCommandId_t commandedByCached = MessageQueueIF::NO_QUEUE; ReturnValue_t parseTmPackets();