From 5634f152934324ccd76dbc046e922700ca933109 Mon Sep 17 00:00:00 2001 From: Markus Koller Date: Thu, 13 Jan 2022 14:14:33 +0100 Subject: [PATCH 01/17] fix ack size --- bsp_q7s/core/ObjectFactory.cpp | 6 ++++++ mission/devices/SyrlinksHkHandler.h | 6 +++--- mission/devices/devicedefinitions/SyrlinksDefinitions.h | 2 +- tmtc | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 1c5bb2df..760e2a4a 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -154,8 +154,14 @@ void ObjectFactory::produce(void* args) { #if OBSW_ADD_PLOC_MPSOC == 1 UartCookie* plocMpsocCookie = new UartCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, +<<<<<<< Updated upstream PLOC_MPSOC::MAX_REPLY_SIZE); new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie); +======= + mpsoc::MAX_REPLY_SIZE); + PlocMPSoCHandler* plocMpsocHandler = new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie); + plocMpsocHandler->setStartUpImmediately(); +>>>>>>> Stashed changes #endif /* OBSW_ADD_PLOC_MPSOC == 1 */ #if OBSW_ADD_PLOC_SUPERVISOR == 1 diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index c194fd18..f30fb5bb 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -61,10 +61,10 @@ private: std::string resetCommand = ""; std::string readRxStatusRegCommand = ""; - std::string setTxModeStandby = ""; + std::string setTxModeStandby = ""; /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ - std::string setTxModeModulation = ""; - std::string setTxModeCw = ""; + std::string setTxModeModulation = ""; + std::string setTxModeCw = ""; std::string readTxStatus = ""; std::string readTxWaveform = ""; std::string readTxAgcValueHighByte = ""; diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index 7aa75b99..43ce16f2 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -21,7 +21,7 @@ namespace SYRLINKS { static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; /** Size of a simple transmission success response */ - static const uint8_t ACK_SIZE = 11; + static const uint8_t ACK_SIZE = 12; static const uint8_t SIZE_CRC_AND_TERMINATION = 5; /** The size of the header with the message identifier and the payload size field */ static const uint8_t MESSAGE_HEADER_SIZE = 5; diff --git a/tmtc b/tmtc index 734dc5ae..5816f05c 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 734dc5aef88d9fef4ad59817b6ea315db954205c +Subproject commit 5816f05ccf8971f3cf2dd1d603dd3f5a33f6f504 From c20acfc9c8c916c81cc845d5d0a9dcfa4cdfbe07 Mon Sep 17 00:00:00 2001 From: Markus Koller Date: Thu, 13 Jan 2022 16:32:30 +0100 Subject: [PATCH 02/17] crc fixes --- mission/devices/SyrlinksHkHandler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index f30fb5bb..bf8a489a 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -61,9 +61,9 @@ private: std::string resetCommand = ""; std::string readRxStatusRegCommand = ""; - std::string setTxModeStandby = ""; + std::string setTxModeStandby = ""; /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ - std::string setTxModeModulation = ""; + std::string setTxModeModulation = ""; std::string setTxModeCw = ""; std::string readTxStatus = ""; std::string readTxWaveform = ""; From 25c3f39c8221dadb9b9dd7dae60a4685fb1c99a9 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 29 Mar 2022 07:58:22 +0200 Subject: [PATCH 03/17] star tracker switch --- linux/devices/startracker/StarTrackerHandler.cpp | 7 +++++++ linux/devices/startracker/StarTrackerHandler.h | 4 ++++ tmtc | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/linux/devices/startracker/StarTrackerHandler.cpp b/linux/devices/startracker/StarTrackerHandler.cpp index d06b73f1..86bbc0dc 100644 --- a/linux/devices/startracker/StarTrackerHandler.cpp +++ b/linux/devices/startracker/StarTrackerHandler.cpp @@ -1223,6 +1223,13 @@ ReturnValue_t StarTrackerHandler::doSendReadHook() { return RETURN_OK; } +ReturnValue_t StarTrackerHandler::getSwitches(const uint8_t** switches, + uint8_t* numberOfSwitches) { + *numberOfSwitches = 1; + *switches = &powerSwitch; + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::checkMode(ActionId_t actionId) { switch (actionId) { case startracker::UPLOAD_IMAGE: diff --git a/linux/devices/startracker/StarTrackerHandler.h b/linux/devices/startracker/StarTrackerHandler.h index 4bc0f5a5..781eff02 100644 --- a/linux/devices/startracker/StarTrackerHandler.h +++ b/linux/devices/startracker/StarTrackerHandler.h @@ -12,6 +12,7 @@ #include "fsfw/timemanager/Countdown.h" #include "linux/devices/devicedefinitions/StarTrackerDefinitions.h" #include "thirdparty/arcsec_star_tracker/common/SLIP.h" +#include "devices/powerSwitcherList.h" /** * @brief This is the device handler for the star tracker from arcsec. @@ -75,6 +76,7 @@ class StarTrackerHandler : public DeviceHandlerBase { */ virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; virtual ReturnValue_t doSendReadHook() override; + ReturnValue_t getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) override; virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; private: @@ -268,6 +270,8 @@ class StarTrackerHandler : public DeviceHandlerBase { bool strHelperExecuting = false; + const power::Switch_t powerSwitch = pcduSwitches::PDU1_CH2_STAR_TRACKER_5V; + /** * @brief Handles internal state */ diff --git a/tmtc b/tmtc index 6db0a2cb..ed85e170 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6db0a2cb791909a69506ed56df5518c277ece275 +Subproject commit ed85e1706f818ec652285b57a31b113f60128f70 From 2dca9d598da4a129e0670f74bde36865a469c27c Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 30 Mar 2022 09:19:30 +0200 Subject: [PATCH 04/17] mpsoc startup command --- bsp_q7s/core/ObjectFactory.cpp | 20 +- .../devicedefinitions/MPSoCReturnValuesIF.h | 2 + .../PlocSupervisorDefinitions.h | 2 +- linux/devices/ploc/PlocMPSoCHandler.cpp | 112 ++- linux/devices/ploc/PlocMPSoCHandler.h | 39 +- linux/devices/ploc/PlocMemoryDumper.cpp | 12 +- linux/devices/ploc/PlocSupervisorHandler.cpp | 643 +++++++++--------- linux/devices/ploc/PlocSupervisorHandler.h | 16 +- linux/devices/ploc/PlocUpdater.cpp | 61 +- linux/devices/ploc/PlocUpdater.h | 6 +- .../startracker/StarTrackerHandler.cpp | 11 +- .../devices/startracker/StarTrackerHandler.h | 10 +- mission/devices/SyrlinksHkHandler.cpp | 35 +- mission/devices/SyrlinksHkHandler.h | 16 +- 14 files changed, 571 insertions(+), 414 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 7d99dbee..064cdd71 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -190,9 +190,8 @@ void ObjectFactory::produce(void* args) { uart::STAR_TRACKER_BAUD, startracker::MAX_FRAME_SIZE * 2 + 2); starTrackerCookie->setNoFixedSizeReply(); StrHelper* strHelper = new StrHelper(objects::STR_HELPER); - StarTrackerHandler* starTrackerHandler = new StarTrackerHandler( - objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie, strHelper); - starTrackerHandler->setStartUpImmediately(); + new StarTrackerHandler(objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie, strHelper, + pcduSwitches::PDU1_CH2_STAR_TRACKER_5V); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ @@ -797,7 +796,8 @@ void ObjectFactory::createSyrlinksComponents() { uart::SYRLINKS_BAUD, SYRLINKS::MAX_REPLY_SIZE); syrlinksUartCookie->setParityEven(); - new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie); + new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie, + pcduSwitches::PDU1_CH1_SYRLINKS_12V); } void ObjectFactory::createRtdComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher) { @@ -925,10 +925,9 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF) { UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE); mpsocCookie->setNoFixedSizeReply(); auto plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER); - auto plocMPSoC = - new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie, - plocMpsocHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF)); - plocMPSoC->setStartUpImmediately(); + new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie, + plocMpsocHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF), + objects::PLOC_SUPERVISOR_HANDLER); #endif /* OBSW_ADD_PLOC_MPSOC == 1 */ #if OBSW_ADD_PLOC_SUPERVISOR == 1 @@ -940,10 +939,11 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF) { gpioComIF->addGpios(supvGpioCookie); auto supervisorCookie = new UartCookie( objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL, - uart::PLOC_SUPERVISOR_BAUD, PLOC_SPV::MAX_PACKET_SIZE * 20); + uart::PLOC_SUPERVISOR_BAUD, supv::MAX_PACKET_SIZE * 20); supervisorCookie->setNoFixedSizeReply(); new PlocSupervisorHandler(objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, - supervisorCookie, Gpio(gpioIds::ENABLE_SUPV_UART, gpioComIF)); + supervisorCookie, Gpio(gpioIds::ENABLE_SUPV_UART, gpioComIF), + pcduSwitches::PDU1_CH6_PLOC_12V); #endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */ static_cast(consumer); } diff --git a/linux/devices/devicedefinitions/MPSoCReturnValuesIF.h b/linux/devices/devicedefinitions/MPSoCReturnValuesIF.h index 141c55aa..ac695ad8 100644 --- a/linux/devices/devicedefinitions/MPSoCReturnValuesIF.h +++ b/linux/devices/devicedefinitions/MPSoCReturnValuesIF.h @@ -25,6 +25,8 @@ class MPSoCReturnValuesIF { static const ReturnValue_t MPSOC_FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA7); //! [EXPORT] : [COMMENT] Command has invalid parameter static const ReturnValue_t INVALID_PARAMETER = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Received command has file string with invalid length + static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA9); }; #endif /* MPSOC_RETURN_VALUES_IF_H_ */ diff --git a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h index 3fc21441..96e72f86 100644 --- a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -8,7 +8,7 @@ #include #include -namespace PLOC_SPV { +namespace supv { /** Command IDs */ static const DeviceCommandId_t NONE = 0; diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index acdfbbca..06c72bae 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -1,4 +1,5 @@ #include "PlocMPSoCHandler.h" +#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h" #include "OBSWConfig.h" #include "fsfw/datapool/PoolReadGuard.h" @@ -6,14 +7,18 @@ PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper, - Gpio uartIsolatorSwitch) + Gpio uartIsolatorSwitch, object_id_t supervisorHandler) : DeviceHandlerBase(objectId, uartComIFid, comCookie), plocMPSoCHelper(plocMPSoCHelper), - uartIsolatorSwitch(uartIsolatorSwitch) { + uartIsolatorSwitch(uartIsolatorSwitch), + supervisorHandler(supervisorHandler), + commandActionHelper(this) { if (comCookie == nullptr) { sif::error << "PlocMPSoCHandler: Invalid communication cookie" << std::endl; } eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); + commandActionHelperQueue = + QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); } PlocMPSoCHandler::~PlocMPSoCHandler() {} @@ -60,6 +65,10 @@ ReturnValue_t PlocMPSoCHandler::initialize() { } plocMPSoCHelper->setComCookie(comCookie); plocMPSoCHelper->setSequenceCount(&sequenceCount); + result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } return result; } @@ -77,6 +86,14 @@ void PlocMPSoCHandler::performOperationHook() { break; } } + CommandMessage message; + for (ReturnValue_t result = commandActionHelperQueue->receiveMessage(&event); result == RETURN_OK; + result = commandActionHelperQueue->receiveMessage(&event)) { + result = commandActionHelper.handleReply(&message); + if (result == RETURN_OK) { + continue; + } + } } ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, @@ -116,17 +133,34 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI } void PlocMPSoCHandler::doStartUp() { -#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); -#else - setMode(_MODE_TO_ON); -#endif - uartIsolatorSwitch.pullHigh(); + switch(powerState) { + case PowerState::OFF: + commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC); + powerState = PowerState::BOOTING; + break; + case PowerState::ON: + setMode(_MODE_TO_ON); + uartIsolatorSwitch.pullHigh(); + break; + default: + break; + } } void PlocMPSoCHandler::doShutDown() { - uartIsolatorSwitch.pullLow(); - setMode(_MODE_POWER_DOWN); + switch(powerState) { + case PowerState::ON: + uartIsolatorSwitch.pullLow(); + commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC); + powerState = PowerState::SHUTDOWN; + break; + case PowerState::OFF: + setMode(_MODE_POWER_DOWN); + break; + default: + sif::debug << "PlocMPSoCHandler::doShutDown: This should never happen" << std::endl; + break; + } } ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { @@ -331,7 +365,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData, ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData, size_t commandDataLen) { if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) { - return NAME_TOO_LONG; + return MPSoCReturnValuesIF::NAME_TOO_LONG; } ReturnValue_t result = RETURN_OK; sequenceCount++; @@ -670,6 +704,45 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { return replyLen; } +MessageQueueIF* PlocMPSoCHandler::getCommandQueuePtr() { + return commandActionHelperQueue; +} + +void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { + return; +} + +void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step, + ReturnValue_t returnCode) { + handleActionCommandFailure(actionId); +} + +void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { + return; +} + +void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) { + switch(actionId) { + case supv::START_MPSOC: { + powerState = PowerState::ON; + break; + } + case supv::SHUTDOWN_MPSOC: { + powerState = PowerState::OFF; + break; + default: + sif::debug + << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action reply" + << std::endl; + break; + } + } +} + +void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { + handleActionCommandFailure(actionId); +} + void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { ReturnValue_t result = RETURN_OK; @@ -764,3 +837,20 @@ void PlocMPSoCHandler::printStatus(const uint8_t* data) { uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) { return *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1); } + +void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) { + switch (actionId) { + case supv::START_MPSOC: + powerState = PowerState::ON; + break; + case supv::SHUTDOWN_MPSOC: + triggerEvent(MPSOC_SHUTDOWN_FAILED); + // TODO: Setting state to on or off here? + powerState = PowerState::OFF; + break; + default: + sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Received unexpected action reply" + << std::endl; + break; + } +} diff --git a/linux/devices/ploc/PlocMPSoCHandler.h b/linux/devices/ploc/PlocMPSoCHandler.h index 3b323109..6e8ed1e5 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.h +++ b/linux/devices/ploc/PlocMPSoCHandler.h @@ -4,6 +4,8 @@ #include #include "PlocMPSoCHelper.h" +#include "fsfw/action/CommandActionHelper.h" +#include "fsfw/action/CommandsActionsIF.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/tmtcservices/SourceSequenceCounter.h" @@ -26,15 +28,33 @@ * * @author J. Meier */ -class PlocMPSoCHandler : public DeviceHandlerBase { +class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { public: + /** + * @brief Constructor + * + * @param ojectId Object ID of the MPSoC handler + * @param uartcomIFid Object ID of the UART communication interface + * @param comCookie UART communication cookie + * @param plocMPSoCHelper Pointer to MPSoC helper object + * @param uartIsolatorSwitch Gpio object representing the GPIO connected to the UART isolator + * module in the programmable logic + * @param supervisorHandler Object ID of the supervisor handler + */ PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, - PlocMPSoCHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch); + PlocMPSoCHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch, + object_id_t supervisorHandler); virtual ~PlocMPSoCHandler(); virtual ReturnValue_t initialize() override; ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) override; void performOperationHook() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; protected: void doStartUp() override; @@ -74,15 +94,16 @@ class PlocMPSoCHandler : public DeviceHandlerBase { //! [EXPORT] : [COMMENT] Packet sequence count in received space packet does not match expected //! count P1: Expected sequence count P2: Received sequence count static const Event MPSOC_HANDLER_SEQ_CNT_MISMATCH = MAKE_EVENT(5, severity::LOW); - - //! [EXPORT] : [COMMENT] Received command has file string with invalid length - static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xD0); + //! [EXPORT] : [COMMENT] Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and + //! thus also to shutdown the supervisor. + static const Event MPSOC_SHUTDOWN_FAILED = MAKE_EVENT(6, severity::HIGH); static const uint16_t APID_MASK = 0x7FF; static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; static const uint8_t STATUS_OFFSET = 10; MessageQueueIF* eventQueue = nullptr; + MessageQueueIF* commandActionHelperQueue = nullptr; SourceSequenceCounter sequenceCount; @@ -99,6 +120,8 @@ class PlocMPSoCHandler : public DeviceHandlerBase { PlocMPSoCHelper* plocMPSoCHelper = nullptr; Gpio uartIsolatorSwitch; + object_id_t supervisorHandler = 0; + CommandActionHelper commandActionHelper; // Used to block incoming commands when MPSoC helper class is currently executing a command bool plocMPSoCHelperExecuting = false; @@ -111,6 +134,10 @@ class PlocMPSoCHandler : public DeviceHandlerBase { TmMemReadReport tmMemReadReport; + enum class PowerState { OFF, BOOTING, SHUTDOWN, ON }; + + PowerState powerState = PowerState::OFF; + /** * @brief Handles events received from the PLOC MPSoC helper */ @@ -212,6 +239,8 @@ class PlocMPSoCHandler : public DeviceHandlerBase { ReturnValue_t prepareTcModeReplay(); uint16_t getStatus(const uint8_t* data); + + void handleActionCommandFailure(ActionId_t actionId); }; #endif /* BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ */ diff --git a/linux/devices/ploc/PlocMemoryDumper.cpp b/linux/devices/ploc/PlocMemoryDumper.cpp index 1d5dce85..a73a2606 100644 --- a/linux/devices/ploc/PlocMemoryDumper.cpp +++ b/linux/devices/ploc/PlocMemoryDumper.cpp @@ -105,10 +105,10 @@ void PlocMemoryDumper::doStateMachine() { case State::IDLE: break; case State::COMMAND_FIRST_MRAM_DUMP: - commandNextMramDump(PLOC_SPV::FIRST_MRAM_DUMP); + commandNextMramDump(supv::FIRST_MRAM_DUMP); break; case State::COMMAND_CONSECUTIVE_MRAM_DUMP: - commandNextMramDump(PLOC_SPV::CONSECUTIVE_MRAM_DUMP); + commandNextMramDump(supv::CONSECUTIVE_MRAM_DUMP); break; case State::EXECUTING_MRAM_DUMP: break; @@ -127,8 +127,8 @@ void PlocMemoryDumper::dataReceived(ActionId_t actionId, const uint8_t* data, ui void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) { switch (pendingCommand) { - case (PLOC_SPV::FIRST_MRAM_DUMP): - case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + case (supv::FIRST_MRAM_DUMP): + case (supv::CONSECUTIVE_MRAM_DUMP): if (mram.endAddress == mram.startAddress) { triggerEvent(MRAM_DUMP_FINISHED); state = State::IDLE; @@ -146,8 +146,8 @@ void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) { void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { switch (pendingCommand) { - case (PLOC_SPV::FIRST_MRAM_DUMP): - case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + case (supv::FIRST_MRAM_DUMP): + case (supv::CONSECUTIVE_MRAM_DUMP): triggerEvent(MRAM_DUMP_FAILED, mram.lastStartAddress); break; default: diff --git a/linux/devices/ploc/PlocSupervisorHandler.cpp b/linux/devices/ploc/PlocSupervisorHandler.cpp index 838e090d..078475c9 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.cpp +++ b/linux/devices/ploc/PlocSupervisorHandler.cpp @@ -12,12 +12,14 @@ #include "OBSWConfig.h" PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, - CookieIF* comCookie, Gpio uartIsolatorSwitch) + CookieIF* comCookie, Gpio uartIsolatorSwitch, + power::Switch_t powerSwitch) : DeviceHandlerBase(objectId, uartComIFid, comCookie), uartIsolatorSwitch(uartIsolatorSwitch), hkset(this), bootStatusReport(this), - latchupStatusReport(this) { + latchupStatusReport(this), + powerSwitch(powerSwitch) { if (comCookie == NULL) { sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl; } @@ -65,196 +67,196 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d size_t commandDataLen) { ReturnValue_t result = RETURN_FAILED; switch (deviceCommand) { - case (PLOC_SPV::GET_HK_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_HK_REPORT); + case (supv::GET_HK_REPORT): { + prepareEmptyCmd(supv::APID_GET_HK_REPORT); result = RETURN_OK; break; } - case (PLOC_SPV::RESTART_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_RESTART_MPSOC); + case (supv::RESTART_MPSOC): { + prepareEmptyCmd(supv::APID_RESTART_MPSOC); result = RETURN_OK; break; } - case (PLOC_SPV::START_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_START_MPSOC); + case (supv::START_MPSOC): { + prepareEmptyCmd(supv::APID_START_MPSOC); result = RETURN_OK; break; } - case (PLOC_SPV::SHUTDOWN_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_SHUTWOWN_MPSOC); + case (supv::SHUTDOWN_MPSOC): { + prepareEmptyCmd(supv::APID_SHUTWOWN_MPSOC); result = RETURN_OK; break; } - case (PLOC_SPV::SEL_MPSOC_BOOT_IMAGE): { + case (supv::SEL_MPSOC_BOOT_IMAGE): { prepareSelBootImageCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::RESET_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC); + case (supv::RESET_MPSOC): { + prepareEmptyCmd(supv::APID_RESET_MPSOC); result = RETURN_OK; break; } - case (PLOC_SPV::SET_TIME_REF): { + case (supv::SET_TIME_REF): { result = prepareSetTimeRefCmd(); break; } - case (PLOC_SPV::SET_BOOT_TIMEOUT): { + case (supv::SET_BOOT_TIMEOUT): { prepareSetBootTimeoutCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::SET_MAX_RESTART_TRIES): { + case (supv::SET_MAX_RESTART_TRIES): { prepareRestartTriesCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): { + case (supv::DISABLE_PERIOIC_HK_TRANSMISSION): { prepareDisableHk(); result = RETURN_OK; break; } - case (PLOC_SPV::GET_BOOT_STATUS_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_BOOT_STATUS_RPT); + case (supv::GET_BOOT_STATUS_REPORT): { + prepareEmptyCmd(supv::APID_GET_BOOT_STATUS_RPT); result = RETURN_OK; break; } - case (PLOC_SPV::WATCHDOGS_ENABLE): { + case (supv::WATCHDOGS_ENABLE): { prepareWatchdogsEnableCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT): { + case (supv::WATCHDOGS_CONFIG_TIMEOUT): { result = prepareWatchdogsConfigTimeoutCmd(commandData); break; } - case (PLOC_SPV::ENABLE_LATCHUP_ALERT): { + case (supv::ENABLE_LATCHUP_ALERT): { result = prepareLatchupConfigCmd(commandData, deviceCommand); break; } - case (PLOC_SPV::DISABLE_LATCHUP_ALERT): { + case (supv::DISABLE_LATCHUP_ALERT): { result = prepareLatchupConfigCmd(commandData, deviceCommand); break; } - case (PLOC_SPV::AUTO_CALIBRATE_ALERT): { + case (supv::AUTO_CALIBRATE_ALERT): { result = prepareAutoCalibrateAlertCmd(commandData); break; } - case (PLOC_SPV::SET_ALERT_LIMIT): { + case (supv::SET_ALERT_LIMIT): { result = prepareSetAlertLimitCmd(commandData); break; } - case (PLOC_SPV::SET_ALERT_IRQ_FILTER): { + case (supv::SET_ALERT_IRQ_FILTER): { result = prepareSetAlertIrqFilterCmd(commandData); break; } - case (PLOC_SPV::SET_ADC_SWEEP_PERIOD): { + case (supv::SET_ADC_SWEEP_PERIOD): { result = prepareSetAdcSweetPeriodCmd(commandData); break; } - case (PLOC_SPV::SET_ADC_ENABLED_CHANNELS): { + case (supv::SET_ADC_ENABLED_CHANNELS): { prepareSetAdcEnabledChannelsCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE): { + case (supv::SET_ADC_WINDOW_AND_STRIDE): { prepareSetAdcWindowAndStrideCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::SET_ADC_THRESHOLD): { + case (supv::SET_ADC_THRESHOLD): { prepareSetAdcThresholdCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::GET_LATCHUP_STATUS_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_LATCHUP_STATUS_REPORT); + case (supv::GET_LATCHUP_STATUS_REPORT): { + prepareEmptyCmd(supv::APID_GET_LATCHUP_STATUS_REPORT); result = RETURN_OK; break; } - case (PLOC_SPV::COPY_ADC_DATA_TO_MRAM): { - prepareEmptyCmd(PLOC_SPV::APID_COPY_ADC_DATA_TO_MRAM); + case (supv::COPY_ADC_DATA_TO_MRAM): { + prepareEmptyCmd(supv::APID_COPY_ADC_DATA_TO_MRAM); result = RETURN_OK; break; } - case (PLOC_SPV::ENABLE_NVMS): { + case (supv::ENABLE_NVMS): { prepareEnableNvmsCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::SELECT_NVM): { + case (supv::SELECT_NVM): { prepareSelectNvmCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::RUN_AUTO_EM_TESTS): { + case (supv::RUN_AUTO_EM_TESTS): { result = prepareRunAutoEmTest(commandData); break; } - case (PLOC_SPV::WIPE_MRAM): { + case (supv::WIPE_MRAM): { result = prepareWipeMramCmd(commandData); break; } - case (PLOC_SPV::FIRST_MRAM_DUMP): - case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + case (supv::FIRST_MRAM_DUMP): + case (supv::CONSECUTIVE_MRAM_DUMP): result = prepareDumpMramCmd(commandData); break; - case (PLOC_SPV::PRINT_CPU_STATS): { + case (supv::PRINT_CPU_STATS): { preparePrintCpuStatsCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::SET_DBG_VERBOSITY): { + case (supv::SET_DBG_VERBOSITY): { prepareSetDbgVerbosityCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::CAN_LOOPBACK_TEST): { - prepareEmptyCmd(PLOC_SPV::APID_CAN_LOOPBACK_TEST); + case (supv::CAN_LOOPBACK_TEST): { + prepareEmptyCmd(supv::APID_CAN_LOOPBACK_TEST); result = RETURN_OK; break; } - case (PLOC_SPV::SET_GPIO): { + case (supv::SET_GPIO): { prepareSetGpioCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::READ_GPIO): { + case (supv::READ_GPIO): { prepareReadGpioCmd(commandData); result = RETURN_OK; break; } - case (PLOC_SPV::RESTART_SUPERVISOR): { - prepareEmptyCmd(PLOC_SPV::APID_RESTART_SUPERVISOR); + case (supv::RESTART_SUPERVISOR): { + prepareEmptyCmd(supv::APID_RESTART_SUPERVISOR); result = RETURN_OK; break; } - case (PLOC_SPV::FACTORY_RESET_CLEAR_ALL): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CLEAR_ALL); + case (supv::FACTORY_RESET_CLEAR_ALL): { + supv::FactoryReset packet(supv::FactoryReset::Op::CLEAR_ALL); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); result = RETURN_OK; break; } - case (PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::MIRROR_ENTRIES); + case (supv::FACTORY_RESET_CLEAR_MIRROR): { + supv::FactoryReset packet(supv::FactoryReset::Op::MIRROR_ENTRIES); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); result = RETURN_OK; break; } - case (PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CIRCULAR_ENTRIES); + case (supv::FACTORY_RESET_CLEAR_CIRCULAR): { + supv::FactoryReset packet(supv::FactoryReset::Op::CIRCULAR_ENTRIES); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); result = RETURN_OK; break; } - case (PLOC_SPV::UPDATE_AVAILABLE): - case (PLOC_SPV::UPDATE_IMAGE_DATA): - case (PLOC_SPV::UPDATE_VERIFY): + case (supv::UPDATE_AVAILABLE): + case (supv::UPDATE_IMAGE_DATA): + case (supv::UPDATE_VERIFY): // Simply forward data from PLOC Updater to supervisor std::memcpy(commandBuffer, commandData, commandDataLen); rawPacket = commandBuffer; rawPacketLen = commandDataLen; - nextReplyId = PLOC_SPV::ACK_REPORT; + nextReplyId = supv::ACK_REPORT; result = RETURN_OK; break; default: @@ -275,64 +277,64 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d } void PlocSupervisorHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(PLOC_SPV::GET_HK_REPORT); - this->insertInCommandMap(PLOC_SPV::RESTART_MPSOC); - this->insertInCommandMap(PLOC_SPV::START_MPSOC); - this->insertInCommandMap(PLOC_SPV::SHUTDOWN_MPSOC); - this->insertInCommandMap(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE); - this->insertInCommandMap(PLOC_SPV::SET_BOOT_TIMEOUT); - this->insertInCommandMap(PLOC_SPV::SET_MAX_RESTART_TRIES); - this->insertInCommandMap(PLOC_SPV::RESET_MPSOC); - this->insertInCommandMap(PLOC_SPV::SET_TIME_REF); - this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION); - this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT); - this->insertInCommandMap(PLOC_SPV::UPDATE_AVAILABLE); - this->insertInCommandMap(PLOC_SPV::UPDATE_VERIFY); - this->insertInCommandMap(PLOC_SPV::UPDATE_IMAGE_DATA); - this->insertInCommandMap(PLOC_SPV::WATCHDOGS_ENABLE); - this->insertInCommandMap(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT); - this->insertInCommandMap(PLOC_SPV::ENABLE_LATCHUP_ALERT); - this->insertInCommandMap(PLOC_SPV::DISABLE_LATCHUP_ALERT); - this->insertInCommandMap(PLOC_SPV::AUTO_CALIBRATE_ALERT); - this->insertInCommandMap(PLOC_SPV::SET_ALERT_LIMIT); - this->insertInCommandMap(PLOC_SPV::SET_ALERT_IRQ_FILTER); - this->insertInCommandMap(PLOC_SPV::SET_ADC_SWEEP_PERIOD); - this->insertInCommandMap(PLOC_SPV::SET_ADC_ENABLED_CHANNELS); - this->insertInCommandMap(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE); - this->insertInCommandMap(PLOC_SPV::SET_ADC_THRESHOLD); - this->insertInCommandMap(PLOC_SPV::GET_LATCHUP_STATUS_REPORT); - this->insertInCommandMap(PLOC_SPV::COPY_ADC_DATA_TO_MRAM); - this->insertInCommandMap(PLOC_SPV::ENABLE_NVMS); - this->insertInCommandMap(PLOC_SPV::SELECT_NVM); - this->insertInCommandMap(PLOC_SPV::RUN_AUTO_EM_TESTS); - this->insertInCommandMap(PLOC_SPV::WIPE_MRAM); - this->insertInCommandMap(PLOC_SPV::PRINT_CPU_STATS); - this->insertInCommandMap(PLOC_SPV::SET_DBG_VERBOSITY); - this->insertInCommandMap(PLOC_SPV::SET_GPIO); - this->insertInCommandMap(PLOC_SPV::READ_GPIO); - this->insertInCommandMap(PLOC_SPV::RESTART_SUPERVISOR); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_ALL); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR); - this->insertInCommandMap(PLOC_SPV::CAN_LOOPBACK_TEST); - this->insertInCommandAndReplyMap(PLOC_SPV::FIRST_MRAM_DUMP, 3); - this->insertInCommandAndReplyMap(PLOC_SPV::CONSECUTIVE_MRAM_DUMP, 3); - this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT); - this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT); - this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT); - this->insertInReplyMap(PLOC_SPV::BOOT_STATUS_REPORT, 3, &bootStatusReport, - PLOC_SPV::SIZE_BOOT_STATUS_REPORT); - this->insertInReplyMap(PLOC_SPV::LATCHUP_REPORT, 3, &latchupStatusReport, - PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); + this->insertInCommandMap(supv::GET_HK_REPORT); + this->insertInCommandMap(supv::RESTART_MPSOC); + this->insertInCommandMap(supv::START_MPSOC); + this->insertInCommandMap(supv::SHUTDOWN_MPSOC); + this->insertInCommandMap(supv::SEL_MPSOC_BOOT_IMAGE); + this->insertInCommandMap(supv::SET_BOOT_TIMEOUT); + this->insertInCommandMap(supv::SET_MAX_RESTART_TRIES); + this->insertInCommandMap(supv::RESET_MPSOC); + this->insertInCommandMap(supv::SET_TIME_REF); + this->insertInCommandMap(supv::DISABLE_PERIOIC_HK_TRANSMISSION); + this->insertInCommandMap(supv::GET_BOOT_STATUS_REPORT); + this->insertInCommandMap(supv::UPDATE_AVAILABLE); + this->insertInCommandMap(supv::UPDATE_VERIFY); + this->insertInCommandMap(supv::UPDATE_IMAGE_DATA); + this->insertInCommandMap(supv::WATCHDOGS_ENABLE); + this->insertInCommandMap(supv::WATCHDOGS_CONFIG_TIMEOUT); + this->insertInCommandMap(supv::ENABLE_LATCHUP_ALERT); + this->insertInCommandMap(supv::DISABLE_LATCHUP_ALERT); + this->insertInCommandMap(supv::AUTO_CALIBRATE_ALERT); + this->insertInCommandMap(supv::SET_ALERT_LIMIT); + this->insertInCommandMap(supv::SET_ALERT_IRQ_FILTER); + this->insertInCommandMap(supv::SET_ADC_SWEEP_PERIOD); + this->insertInCommandMap(supv::SET_ADC_ENABLED_CHANNELS); + this->insertInCommandMap(supv::SET_ADC_WINDOW_AND_STRIDE); + this->insertInCommandMap(supv::SET_ADC_THRESHOLD); + this->insertInCommandMap(supv::GET_LATCHUP_STATUS_REPORT); + this->insertInCommandMap(supv::COPY_ADC_DATA_TO_MRAM); + this->insertInCommandMap(supv::ENABLE_NVMS); + this->insertInCommandMap(supv::SELECT_NVM); + this->insertInCommandMap(supv::RUN_AUTO_EM_TESTS); + this->insertInCommandMap(supv::WIPE_MRAM); + this->insertInCommandMap(supv::PRINT_CPU_STATS); + this->insertInCommandMap(supv::SET_DBG_VERBOSITY); + this->insertInCommandMap(supv::SET_GPIO); + this->insertInCommandMap(supv::READ_GPIO); + this->insertInCommandMap(supv::RESTART_SUPERVISOR); + this->insertInCommandMap(supv::FACTORY_RESET_CLEAR_ALL); + this->insertInCommandMap(supv::FACTORY_RESET_CLEAR_MIRROR); + this->insertInCommandMap(supv::FACTORY_RESET_CLEAR_CIRCULAR); + this->insertInCommandMap(supv::CAN_LOOPBACK_TEST); + this->insertInCommandAndReplyMap(supv::FIRST_MRAM_DUMP, 3); + this->insertInCommandAndReplyMap(supv::CONSECUTIVE_MRAM_DUMP, 3); + this->insertInReplyMap(supv::ACK_REPORT, 3, nullptr, supv::SIZE_ACK_REPORT); + this->insertInReplyMap(supv::EXE_REPORT, 3, nullptr, supv::SIZE_EXE_REPORT); + this->insertInReplyMap(supv::HK_REPORT, 3, &hkset, supv::SIZE_HK_REPORT); + this->insertInReplyMap(supv::BOOT_STATUS_REPORT, 3, &bootStatusReport, + supv::SIZE_BOOT_STATUS_REPORT); + this->insertInReplyMap(supv::LATCHUP_REPORT, 3, &latchupStatusReport, + supv::SIZE_LATCHUP_STATUS_REPORT); } ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { - if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP) { - *foundId = PLOC_SPV::FIRST_MRAM_DUMP; + if (nextReplyId == supv::FIRST_MRAM_DUMP) { + *foundId = supv::FIRST_MRAM_DUMP; return parseMramPackets(start, remainingSize, foundLen); - } else if (nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { - *foundId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; + } else if (nextReplyId == supv::CONSECUTIVE_MRAM_DUMP) { + *foundId = supv::CONSECUTIVE_MRAM_DUMP; return parseMramPackets(start, remainingSize, foundLen); } @@ -341,33 +343,33 @@ ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t r uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; switch (apid) { - case (PLOC_SPV::APID_ACK_SUCCESS): - *foundLen = PLOC_SPV::SIZE_ACK_REPORT; - *foundId = PLOC_SPV::ACK_REPORT; + case (supv::APID_ACK_SUCCESS): + *foundLen = supv::SIZE_ACK_REPORT; + *foundId = supv::ACK_REPORT; break; - case (PLOC_SPV::APID_ACK_FAILURE): - *foundLen = PLOC_SPV::SIZE_ACK_REPORT; - *foundId = PLOC_SPV::ACK_REPORT; + case (supv::APID_ACK_FAILURE): + *foundLen = supv::SIZE_ACK_REPORT; + *foundId = supv::ACK_REPORT; break; - case (PLOC_SPV::APID_HK_REPORT): - *foundLen = PLOC_SPV::SIZE_HK_REPORT; - *foundId = PLOC_SPV::HK_REPORT; + case (supv::APID_HK_REPORT): + *foundLen = supv::SIZE_HK_REPORT; + *foundId = supv::HK_REPORT; break; - case (PLOC_SPV::APID_BOOT_STATUS_REPORT): - *foundLen = PLOC_SPV::SIZE_BOOT_STATUS_REPORT; - *foundId = PLOC_SPV::BOOT_STATUS_REPORT; + case (supv::APID_BOOT_STATUS_REPORT): + *foundLen = supv::SIZE_BOOT_STATUS_REPORT; + *foundId = supv::BOOT_STATUS_REPORT; break; - case (PLOC_SPV::APID_LATCHUP_STATUS_REPORT): - *foundLen = PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT; - *foundId = PLOC_SPV::LATCHUP_REPORT; + case (supv::APID_LATCHUP_STATUS_REPORT): + *foundLen = supv::SIZE_LATCHUP_STATUS_REPORT; + *foundId = supv::LATCHUP_REPORT; break; - case (PLOC_SPV::APID_EXE_SUCCESS): - *foundLen = PLOC_SPV::SIZE_EXE_REPORT; - *foundId = PLOC_SPV::EXE_REPORT; + case (supv::APID_EXE_SUCCESS): + *foundLen = supv::SIZE_EXE_REPORT; + *foundId = supv::EXE_REPORT; break; - case (PLOC_SPV::APID_EXE_FAILURE): - *foundLen = PLOC_SPV::SIZE_EXE_REPORT; - *foundId = PLOC_SPV::EXE_REPORT; + case (supv::APID_EXE_FAILURE): + *foundLen = supv::SIZE_EXE_REPORT; + *foundId = supv::EXE_REPORT; break; default: { sif::debug << "PlocSupervisorHandler::scanForReply: Reply has invalid apid" << std::endl; @@ -381,6 +383,9 @@ ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t r ReturnValue_t PlocSupervisorHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) { + if (powerSwitch == power::NO_SWITCH) { + return DeviceHandlerBase::NO_SWITCH; + } *numberOfSwitches = 1; *switches = &powerSwitch; return RETURN_OK; @@ -391,27 +396,27 @@ ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id, ReturnValue_t result = RETURN_OK; switch (id) { - case PLOC_SPV::ACK_REPORT: { + case supv::ACK_REPORT: { result = handleAckReport(packet); break; } - case (PLOC_SPV::HK_REPORT): { + case (supv::HK_REPORT): { result = handleHkReport(packet); break; } - case (PLOC_SPV::BOOT_STATUS_REPORT): { + case (supv::BOOT_STATUS_REPORT): { result = handleBootStatusReport(packet); break; } - case (PLOC_SPV::LATCHUP_REPORT): { + case (supv::LATCHUP_REPORT): { result = handleLatchupStatusReport(packet); break; } - case (PLOC_SPV::FIRST_MRAM_DUMP): - case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + case (supv::FIRST_MRAM_DUMP): + case (supv::CONSECUTIVE_MRAM_DUMP): result = handleMramDumpPacket(id); break; - case (PLOC_SPV::EXE_REPORT): { + case (supv::EXE_REPORT): { result = handleExecutionReport(packet); break; } @@ -431,44 +436,44 @@ uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t mod ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(PLOC_SPV::NUM_TMS, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::TEMP_PS, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::TEMP_PL, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::SOC_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::NVM0_1_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::NVM3_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::MISSION_IO_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::FMC_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::NUM_TCS, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::UPTIME, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::CPULOAD, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::AVAILABLEHEAP, new PoolEntry({0})); + localDataPoolMap.emplace(supv::NUM_TMS, new PoolEntry({0})); + localDataPoolMap.emplace(supv::TEMP_PS, new PoolEntry({0})); + localDataPoolMap.emplace(supv::TEMP_PL, new PoolEntry({0})); + localDataPoolMap.emplace(supv::SOC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(supv::NVM0_1_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(supv::NVM3_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(supv::MISSION_IO_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(supv::FMC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(supv::NUM_TCS, new PoolEntry({0})); + localDataPoolMap.emplace(supv::UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(supv::CPULOAD, new PoolEntry({0})); + localDataPoolMap.emplace(supv::AVAILABLEHEAP, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::BOOT_SIGNAL, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::RESET_COUNTER, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::BOOT_AFTER_MS, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::BOOT_TIMEOUT_MS, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::ACTIVE_NVM, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::BP0_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::BP1_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::BP2_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(supv::BOOT_SIGNAL, new PoolEntry({0})); + localDataPoolMap.emplace(supv::RESET_COUNTER, new PoolEntry({0})); + localDataPoolMap.emplace(supv::BOOT_AFTER_MS, new PoolEntry({0})); + localDataPoolMap.emplace(supv::BOOT_TIMEOUT_MS, new PoolEntry({0})); + localDataPoolMap.emplace(supv::ACTIVE_NVM, new PoolEntry({0})); + localDataPoolMap.emplace(supv::BP0_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(supv::BP1_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(supv::BP2_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_ID, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::CNT0, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::CNT1, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::CNT2, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::CNT3, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::CNT4, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::CNT5, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::CNT6, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_SEC, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MIN, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_HOUR, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_DAY, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MON, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_YEAR, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MSEC, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_IS_SET, new PoolEntry({0})); + localDataPoolMap.emplace(supv::LATCHUP_ID, new PoolEntry({0})); + localDataPoolMap.emplace(supv::CNT0, new PoolEntry({0})); + localDataPoolMap.emplace(supv::CNT1, new PoolEntry({0})); + localDataPoolMap.emplace(supv::CNT2, new PoolEntry({0})); + localDataPoolMap.emplace(supv::CNT3, new PoolEntry({0})); + localDataPoolMap.emplace(supv::CNT4, new PoolEntry({0})); + localDataPoolMap.emplace(supv::CNT5, new PoolEntry({0})); + localDataPoolMap.emplace(supv::CNT6, new PoolEntry({0})); + localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_SEC, new PoolEntry({0})); + localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_MIN, new PoolEntry({0})); + localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_HOUR, new PoolEntry({0})); + localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_DAY, new PoolEntry({0})); + localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_MON, new PoolEntry({0})); + localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_YEAR, new PoolEntry({0})); + localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_MSEC, new PoolEntry({0})); + localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_IS_SET, new PoolEntry({0})); return HasReturnvaluesIF::RETURN_OK; } @@ -482,94 +487,94 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite uint8_t enabledReplies = 0; switch (command->first) { - case PLOC_SPV::GET_HK_REPORT: { + case supv::GET_HK_REPORT: { enabledReplies = 3; result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::HK_REPORT); + supv::HK_REPORT); if (result != RETURN_OK) { sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::HK_REPORT << " not in replyMap" << std::endl; + << supv::HK_REPORT << " not in replyMap" << std::endl; } break; } - case PLOC_SPV::GET_BOOT_STATUS_REPORT: { + case supv::GET_BOOT_STATUS_REPORT: { enabledReplies = 3; result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::BOOT_STATUS_REPORT); + supv::BOOT_STATUS_REPORT); if (result != RETURN_OK) { sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::BOOT_STATUS_REPORT << " not in replyMap" << std::endl; + << supv::BOOT_STATUS_REPORT << " not in replyMap" << std::endl; } break; } - case PLOC_SPV::GET_LATCHUP_STATUS_REPORT: { + case supv::GET_LATCHUP_STATUS_REPORT: { enabledReplies = 3; result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::LATCHUP_REPORT); + supv::LATCHUP_REPORT); if (result != RETURN_OK) { sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::LATCHUP_REPORT << " not in replyMap" << std::endl; + << supv::LATCHUP_REPORT << " not in replyMap" << std::endl; } break; } - case PLOC_SPV::FIRST_MRAM_DUMP: { + case supv::FIRST_MRAM_DUMP: { enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::FIRST_MRAM_DUMP); + supv::FIRST_MRAM_DUMP); if (result != RETURN_OK) { sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::FIRST_MRAM_DUMP << " not in replyMap" << std::endl; + << supv::FIRST_MRAM_DUMP << " not in replyMap" << std::endl; } break; } - case PLOC_SPV::CONSECUTIVE_MRAM_DUMP: { + case supv::CONSECUTIVE_MRAM_DUMP: { enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::CONSECUTIVE_MRAM_DUMP); + supv::CONSECUTIVE_MRAM_DUMP); if (result != RETURN_OK) { sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl; + << supv::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl; } break; } - case PLOC_SPV::RESTART_MPSOC: - case PLOC_SPV::START_MPSOC: - case PLOC_SPV::SHUTDOWN_MPSOC: - case PLOC_SPV::SEL_MPSOC_BOOT_IMAGE: - case PLOC_SPV::SET_BOOT_TIMEOUT: - case PLOC_SPV::SET_MAX_RESTART_TRIES: - case PLOC_SPV::RESET_MPSOC: - case PLOC_SPV::SET_TIME_REF: - case PLOC_SPV::UPDATE_AVAILABLE: - case PLOC_SPV::UPDATE_IMAGE_DATA: - case PLOC_SPV::UPDATE_VERIFY: - case PLOC_SPV::WATCHDOGS_ENABLE: - case PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT: - case PLOC_SPV::ENABLE_LATCHUP_ALERT: - case PLOC_SPV::DISABLE_LATCHUP_ALERT: - case PLOC_SPV::AUTO_CALIBRATE_ALERT: - case PLOC_SPV::SET_ALERT_LIMIT: - case PLOC_SPV::SET_ALERT_IRQ_FILTER: - case PLOC_SPV::SET_ADC_SWEEP_PERIOD: - case PLOC_SPV::SET_ADC_ENABLED_CHANNELS: - case PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE: - case PLOC_SPV::SET_ADC_THRESHOLD: - case PLOC_SPV::COPY_ADC_DATA_TO_MRAM: - case PLOC_SPV::ENABLE_NVMS: - case PLOC_SPV::SELECT_NVM: - case PLOC_SPV::RUN_AUTO_EM_TESTS: - case PLOC_SPV::WIPE_MRAM: - case PLOC_SPV::SET_DBG_VERBOSITY: - case PLOC_SPV::CAN_LOOPBACK_TEST: - case PLOC_SPV::PRINT_CPU_STATS: - case PLOC_SPV::SET_GPIO: - case PLOC_SPV::READ_GPIO: - case PLOC_SPV::RESTART_SUPERVISOR: - case PLOC_SPV::FACTORY_RESET_CLEAR_ALL: - case PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR: - case PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR: - case PLOC_SPV::REQUEST_LOGGING_DATA: - case PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION: + case supv::RESTART_MPSOC: + case supv::START_MPSOC: + case supv::SHUTDOWN_MPSOC: + case supv::SEL_MPSOC_BOOT_IMAGE: + case supv::SET_BOOT_TIMEOUT: + case supv::SET_MAX_RESTART_TRIES: + case supv::RESET_MPSOC: + case supv::SET_TIME_REF: + case supv::UPDATE_AVAILABLE: + case supv::UPDATE_IMAGE_DATA: + case supv::UPDATE_VERIFY: + case supv::WATCHDOGS_ENABLE: + case supv::WATCHDOGS_CONFIG_TIMEOUT: + case supv::ENABLE_LATCHUP_ALERT: + case supv::DISABLE_LATCHUP_ALERT: + case supv::AUTO_CALIBRATE_ALERT: + case supv::SET_ALERT_LIMIT: + case supv::SET_ALERT_IRQ_FILTER: + case supv::SET_ADC_SWEEP_PERIOD: + case supv::SET_ADC_ENABLED_CHANNELS: + case supv::SET_ADC_WINDOW_AND_STRIDE: + case supv::SET_ADC_THRESHOLD: + case supv::COPY_ADC_DATA_TO_MRAM: + case supv::ENABLE_NVMS: + case supv::SELECT_NVM: + case supv::RUN_AUTO_EM_TESTS: + case supv::WIPE_MRAM: + case supv::SET_DBG_VERBOSITY: + case supv::CAN_LOOPBACK_TEST: + case supv::PRINT_CPU_STATS: + case supv::SET_GPIO: + case supv::READ_GPIO: + case supv::RESTART_SUPERVISOR: + case supv::FACTORY_RESET_CLEAR_ALL: + case supv::FACTORY_RESET_CLEAR_MIRROR: + case supv::FACTORY_RESET_CLEAR_CIRCULAR: + case supv::REQUEST_LOGGING_DATA: + case supv::DISABLE_PERIOIC_HK_TRANSMISSION: enabledReplies = 2; break; default: @@ -582,17 +587,17 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite * replies will be enabled here. */ result = - DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, PLOC_SPV::ACK_REPORT); + DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::ACK_REPORT); if (result != RETURN_OK) { sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::ACK_REPORT << " not in replyMap" << std::endl; + << supv::ACK_REPORT << " not in replyMap" << std::endl; } result = - DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, PLOC_SPV::EXE_REPORT); + DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::EXE_REPORT); if (result != RETURN_OK) { sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::EXE_REPORT << " not in replyMap" << std::endl; + << supv::EXE_REPORT << " not in replyMap" << std::endl; } return RETURN_OK; @@ -610,13 +615,13 @@ ReturnValue_t PlocSupervisorHandler::verifyPacket(const uint8_t* start, size_t f ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) { ReturnValue_t result = RETURN_OK; - result = verifyPacket(data, PLOC_SPV::SIZE_ACK_REPORT); + result = verifyPacket(data, supv::SIZE_ACK_REPORT); if (result == CRC_FAILURE) { sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl; - nextReplyId = PLOC_SPV::NONE; - replyRawReplyIfnotWiretapped(data, PLOC_SPV::SIZE_ACK_REPORT); + nextReplyId = supv::NONE; + replyRawReplyIfnotWiretapped(data, supv::SIZE_ACK_REPORT); triggerEvent(SUPV_CRC_FAILURE_EVENT); - sendFailureReport(PLOC_SPV::ACK_REPORT, CRC_FAILURE); + sendFailureReport(supv::ACK_REPORT, CRC_FAILURE); disableAllReplies(); return RETURN_OK; } @@ -624,7 +629,7 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) { uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; switch (apid) { - case PLOC_SPV::APID_ACK_FAILURE: { + case supv::APID_ACK_FAILURE: { // TODO: Interpretation of status field in acknowledgment report sif::debug << "PlocSupervisorHandler::handleAckReport: Received Ack failure report" << std::endl; @@ -632,13 +637,13 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) { if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { triggerEvent(SUPV_ACK_FAILURE, commandId); } - sendFailureReport(PLOC_SPV::ACK_REPORT, RECEIVED_ACK_FAILURE); + sendFailureReport(supv::ACK_REPORT, RECEIVED_ACK_FAILURE); disableAllReplies(); - nextReplyId = PLOC_SPV::NONE; + nextReplyId = supv::NONE; result = IGNORE_REPLY_DATA; break; } - case PLOC_SPV::APID_ACK_SUCCESS: { + case supv::APID_ACK_SUCCESS: { setNextReplyId(); break; } @@ -656,20 +661,20 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) { ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data) { ReturnValue_t result = RETURN_OK; - result = verifyPacket(data, PLOC_SPV::SIZE_EXE_REPORT); + result = verifyPacket(data, supv::SIZE_EXE_REPORT); if (result == CRC_FAILURE) { sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl; - nextReplyId = PLOC_SPV::NONE; + nextReplyId = supv::NONE; return result; } uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; switch (apid) { - case (PLOC_SPV::APID_EXE_SUCCESS): { + case (supv::APID_EXE_SUCCESS): { break; } - case (PLOC_SPV::APID_EXE_FAILURE): { + case (supv::APID_EXE_FAILURE): { // TODO: Interpretation of status field in execution report sif::error << "PlocSupervisorHandler::handleExecutionReport: Received execution failure report" @@ -681,7 +686,7 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data) sif::debug << "PlocSupervisorHandler::handleExecutionReport: Unknown command id" << std::endl; } - sendFailureReport(PLOC_SPV::EXE_REPORT, RECEIVED_EXE_FAILURE); + sendFailureReport(supv::EXE_REPORT, RECEIVED_EXE_FAILURE); disableExeReportReply(); result = IGNORE_REPLY_DATA; break; @@ -693,7 +698,7 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data) } } - nextReplyId = PLOC_SPV::NONE; + nextReplyId = supv::NONE; return result; } @@ -701,13 +706,13 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data) ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) { ReturnValue_t result = RETURN_OK; - result = verifyPacket(data, PLOC_SPV::SIZE_HK_REPORT); + result = verifyPacket(data, supv::SIZE_HK_REPORT); if (result == CRC_FAILURE) { sif::error << "PlocSupervisorHandler::handleHkReport: Hk report has invalid crc" << std::endl; } - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + uint16_t offset = supv::DATA_FIELD_OFFSET; hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | *(data + offset + 3); offset += 4; @@ -744,7 +749,7 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) { hkset.fmcState = *(data + offset); offset += 1; - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = supv::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl; @@ -774,7 +779,7 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) { ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) { ReturnValue_t result = RETURN_OK; - result = verifyPacket(data, PLOC_SPV::SIZE_BOOT_STATUS_REPORT); + result = verifyPacket(data, supv::SIZE_BOOT_STATUS_REPORT); if (result == CRC_FAILURE) { sif::error << "PlocSupervisorHandler::handleBootStatusReport: Boot status report has invalid" @@ -783,7 +788,7 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) return result; } - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + uint16_t offset = supv::DATA_FIELD_OFFSET; bootStatusReport.bootSignal = *(data + offset); offset += 1; bootStatusReport.resetCounter = *(data + offset); @@ -802,7 +807,7 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) offset += 1; bootStatusReport.bp2State = *(data + offset); - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = supv::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " @@ -829,7 +834,7 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* data) { ReturnValue_t result = RETURN_OK; - result = verifyPacket(data, PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); + result = verifyPacket(data, supv::SIZE_LATCHUP_STATUS_REPORT); if (result == CRC_FAILURE) { sif::error << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup status report has " @@ -837,7 +842,7 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da return result; } - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + uint16_t offset = supv::DATA_FIELD_OFFSET; latchupStatusReport.id = *(data + offset); offset += 1; latchupStatusReport.cnt0 = *(data + offset) << 8 | *(data + offset + 1); @@ -879,7 +884,7 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da *(data + offset + 2) << 8 | *(data + offset + 3); offset += 4; - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = supv::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup ID: " @@ -921,24 +926,24 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da void PlocSupervisorHandler::setNextReplyId() { switch (getPendingCommand()) { - case PLOC_SPV::GET_HK_REPORT: - nextReplyId = PLOC_SPV::HK_REPORT; + case supv::GET_HK_REPORT: + nextReplyId = supv::HK_REPORT; break; - case PLOC_SPV::GET_BOOT_STATUS_REPORT: - nextReplyId = PLOC_SPV::BOOT_STATUS_REPORT; + case supv::GET_BOOT_STATUS_REPORT: + nextReplyId = supv::BOOT_STATUS_REPORT; break; - case PLOC_SPV::GET_LATCHUP_STATUS_REPORT: - nextReplyId = PLOC_SPV::LATCHUP_REPORT; + case supv::GET_LATCHUP_STATUS_REPORT: + nextReplyId = supv::LATCHUP_REPORT; break; - case PLOC_SPV::FIRST_MRAM_DUMP: - nextReplyId = PLOC_SPV::FIRST_MRAM_DUMP; + case supv::FIRST_MRAM_DUMP: + nextReplyId = supv::FIRST_MRAM_DUMP; break; - case PLOC_SPV::CONSECUTIVE_MRAM_DUMP: - nextReplyId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; + case supv::CONSECUTIVE_MRAM_DUMP: + nextReplyId = supv::CONSECUTIVE_MRAM_DUMP; break; default: /* If no telemetry is expected the next reply is always the execution report */ - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = supv::EXE_REPORT; break; } } @@ -946,17 +951,17 @@ void PlocSupervisorHandler::setNextReplyId() { size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId) { size_t replyLen = 0; - if (nextReplyId == PLOC_SPV::NONE) { + if (nextReplyId == supv::NONE) { return replyLen; } - if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP || nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { + if (nextReplyId == supv::FIRST_MRAM_DUMP || nextReplyId == supv::CONSECUTIVE_MRAM_DUMP) { /** * Try to read 20 MRAM packets. If reply is larger, the packets will be read with the * next doSendRead call. The command will be as long active as the packet with the sequence * count indicating the last packet has not been received. */ - replyLen = PLOC_SPV::MAX_PACKET_SIZE * 20; + replyLen = supv::MAX_PACKET_SIZE * 20; return replyLen; } @@ -1002,12 +1007,12 @@ void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, } void PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid) { - PLOC_SPV::EmptyPacket packet(apid); + supv::EmptyPacket packet(apid); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t* commandData) { - PLOC_SPV::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2), + supv::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2), *(commandData + 3)); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } @@ -1020,26 +1025,26 @@ ReturnValue_t PlocSupervisorHandler::prepareSetTimeRefCmd() { << std::endl; return GET_TIME_FAILURE; } - PLOC_SPV::SetTimeRef packet(&time); + supv::SetTimeRef packet(&time); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); return RETURN_OK; } void PlocSupervisorHandler::prepareDisableHk() { - PLOC_SPV::DisablePeriodicHkTransmission packet; + supv::DisablePeriodicHkTransmission packet; packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t* commandData) { uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | *(commandData + 3); - PLOC_SPV::SetBootTimeout packet(timeout); + supv::SetBootTimeout packet(timeout); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t* commandData) { uint8_t restartTries = *(commandData); - PLOC_SPV::SetRestartTries packet(restartTries); + supv::SetRestartTries packet(restartTries); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } @@ -1050,7 +1055,7 @@ void PlocSupervisorHandler::prepareWatchdogsEnableCmd(const uint8_t* commandData uint8_t watchdogPl = *(commandData + offset); offset += 1; uint8_t watchdogInt = *(commandData + offset); - PLOC_SPV::WatchdogsEnable packet(watchdogPs, watchdogPl, watchdogInt); + supv::WatchdogsEnable packet(watchdogPs, watchdogPl, watchdogInt); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } @@ -1066,7 +1071,7 @@ ReturnValue_t PlocSupervisorHandler::prepareWatchdogsConfigTimeoutCmd(const uint if (timeout < 1000 || timeout > 360000) { return INVALID_WATCHDOG_TIMEOUT; } - PLOC_SPV::WatchdogsConfigTimeout packet(watchdog, timeout); + supv::WatchdogsConfigTimeout packet(watchdog, timeout); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); return RETURN_OK; } @@ -1079,13 +1084,13 @@ ReturnValue_t PlocSupervisorHandler::prepareLatchupConfigCmd(const uint8_t* comm return INVALID_LATCHUP_ID; } switch (deviceCommand) { - case (PLOC_SPV::ENABLE_LATCHUP_ALERT): { - PLOC_SPV::LatchupAlert packet(true, latchupId); + case (supv::ENABLE_LATCHUP_ALERT): { + supv::LatchupAlert packet(true, latchupId); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); break; } - case (PLOC_SPV::DISABLE_LATCHUP_ALERT): { - PLOC_SPV::LatchupAlert packet(false, latchupId); + case (supv::DISABLE_LATCHUP_ALERT): { + supv::LatchupAlert packet(false, latchupId); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); break; } @@ -1108,7 +1113,7 @@ ReturnValue_t PlocSupervisorHandler::prepareAutoCalibrateAlertCmd(const uint8_t* if (latchupId > 6) { return INVALID_LATCHUP_ID; } - PLOC_SPV::AutoCalibrateAlert packet(latchupId, mg); + supv::AutoCalibrateAlert packet(latchupId, mg); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); return RETURN_OK; } @@ -1120,7 +1125,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAlertIrqFilterCmd(const uint8_t* if (latchupId > 6) { return INVALID_LATCHUP_ID; } - PLOC_SPV::SetAlertIrqFilter packet(latchupId, tp, div); + supv::SetAlertIrqFilter packet(latchupId, tp, div); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); return RETURN_OK; } @@ -1134,7 +1139,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAlertLimitCmd(const uint8_t* comm if (latchupId > 6) { return INVALID_LATCHUP_ID; } - PLOC_SPV::SetAlertlimit packet(latchupId, dutycycle); + supv::SetAlertlimit packet(latchupId, dutycycle); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); return RETURN_OK; } @@ -1145,14 +1150,14 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAdcSweetPeriodCmd(const uint8_t* if (sweepPeriod < 21) { return SWEEP_PERIOD_TOO_SMALL; } - PLOC_SPV::SetAdcSweepPeriod packet(sweepPeriod); + supv::SetAdcSweepPeriod packet(sweepPeriod); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); return RETURN_OK; } void PlocSupervisorHandler::prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData) { uint16_t ch = *(commandData) << 8 | *(commandData + 1); - PLOC_SPV::SetAdcEnabledChannels packet(ch); + supv::SetAdcEnabledChannels packet(ch); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } @@ -1161,27 +1166,27 @@ void PlocSupervisorHandler::prepareSetAdcWindowAndStrideCmd(const uint8_t* comma uint16_t windowSize = *(commandData + offset) << 8 | *(commandData + offset + 1); offset += 2; uint16_t stridingStepSize = *(commandData + offset) << 8 | *(commandData + offset + 1); - PLOC_SPV::SetAdcWindowAndStride packet(windowSize, stridingStepSize); + supv::SetAdcWindowAndStride packet(windowSize, stridingStepSize); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetAdcThresholdCmd(const uint8_t* commandData) { uint32_t threshold = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | *(commandData + 3); - PLOC_SPV::SetAdcThreshold packet(threshold); + supv::SetAdcThreshold packet(threshold); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareEnableNvmsCmd(const uint8_t* commandData) { uint8_t n01 = *commandData; uint8_t n3 = *(commandData + 1); - PLOC_SPV::EnableNvms packet(n01, n3); + supv::EnableNvms packet(n01, n3); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSelectNvmCmd(const uint8_t* commandData) { uint8_t mem = *commandData; - PLOC_SPV::SelectNvm packet(mem); + supv::SelectNvm packet(mem); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } @@ -1190,7 +1195,7 @@ ReturnValue_t PlocSupervisorHandler::prepareRunAutoEmTest(const uint8_t* command if (test != 1 && test != 2) { return INVALID_TEST_PARAM; } - PLOC_SPV::RunAutoEmTests packet(test); + supv::RunAutoEmTests packet(test); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); return RETURN_OK; } @@ -1204,7 +1209,7 @@ ReturnValue_t PlocSupervisorHandler::prepareWipeMramCmd(const uint8_t* commandDa if ((stop - start) <= 0) { return INVALID_MRAM_ADDRESSES; } - PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::WIPE); + supv::MramCmd packet(start, stop, supv::MramCmd::MramAction::WIPE); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); return RETURN_OK; } @@ -1215,13 +1220,13 @@ ReturnValue_t PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandDa size_t size = sizeof(start) + sizeof(stop); SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); - PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::DUMP); + supv::MramCmd packet(start, stop, supv::MramCmd::MramAction::DUMP); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); if ((stop - start) <= 0) { return INVALID_MRAM_ADDRESSES; } - expectedMramDumpPackets = (stop - start) / PLOC_SPV::MAX_DATA_CAPACITY; - if ((stop - start) % PLOC_SPV::MAX_DATA_CAPACITY) { + expectedMramDumpPackets = (stop - start) / supv::MAX_DATA_CAPACITY; + if ((stop - start) % supv::MAX_DATA_CAPACITY) { expectedMramDumpPackets++; } receivedMramDumpPackets = 0; @@ -1230,13 +1235,13 @@ ReturnValue_t PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandDa void PlocSupervisorHandler::preparePrintCpuStatsCmd(const uint8_t* commandData) { uint8_t en = *commandData; - PLOC_SPV::PrintCpuStats packet(en); + supv::PrintCpuStats packet(en); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetDbgVerbosityCmd(const uint8_t* commandData) { uint8_t vb = *commandData; - PLOC_SPV::SetDbgVerbosity packet(vb); + supv::SetDbgVerbosity packet(vb); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } @@ -1244,14 +1249,14 @@ void PlocSupervisorHandler::prepareSetGpioCmd(const uint8_t* commandData) { uint8_t port = *commandData; uint8_t pin = *(commandData + 1); uint8_t val = *(commandData + 2); - PLOC_SPV::SetGpio packet(port, pin, val); + supv::SetGpio packet(port, pin, val); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareReadGpioCmd(const uint8_t* commandData) { uint8_t port = *commandData; uint8_t pin = *(commandData + 1); - PLOC_SPV::ReadGpio packet(port, pin); + supv::ReadGpio packet(port, pin); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } @@ -1259,14 +1264,14 @@ void PlocSupervisorHandler::packetToOutBuffer(uint8_t* packetData, size_t fullSi memcpy(commandBuffer, packetData, fullSize); rawPacket = commandBuffer; rawPacketLen = fullSize; - nextReplyId = PLOC_SPV::ACK_REPORT; + nextReplyId = supv::ACK_REPORT; } void PlocSupervisorHandler::disableAllReplies() { DeviceReplyMap::iterator iter; /* Disable ack reply */ - iter = deviceReplyMap.find(PLOC_SPV::ACK_REPORT); + iter = deviceReplyMap.find(supv::ACK_REPORT); DeviceReplyInfo* info = &(iter->second); info->delayCycles = 0; info->command = deviceCommandMap.end(); @@ -1275,8 +1280,8 @@ void PlocSupervisorHandler::disableAllReplies() { /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ switch (commandId) { - case PLOC_SPV::GET_HK_REPORT: { - iter = deviceReplyMap.find(PLOC_SPV::GET_HK_REPORT); + case supv::GET_HK_REPORT: { + iter = deviceReplyMap.find(supv::GET_HK_REPORT); info = &(iter->second); info->delayCycles = 0; info->command = deviceCommandMap.end(); @@ -1314,7 +1319,7 @@ void PlocSupervisorHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnV } void PlocSupervisorHandler::disableExeReportReply() { - DeviceReplyIter iter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); + DeviceReplyIter iter = deviceReplyMap.find(supv::EXE_REPORT); DeviceReplyInfo* info = &(iter->second); info->delayCycles = 0; info->command = deviceCommandMap.end(); @@ -1332,17 +1337,17 @@ ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t* packet, siz std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1); bufferTop += 1; *foundLen += 1; - if (bufferTop >= PLOC_SPV::SPACE_PACKET_HEADER_LENGTH) { + if (bufferTop >= supv::SPACE_PACKET_HEADER_LENGTH) { packetLen = readSpacePacketLength(spacePacketBuffer); } - if (bufferTop == PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) { + if (bufferTop == supv::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) { packetInBuffer = true; bufferTop = 0; return checkMramPacketApid(); } - if (bufferTop == PLOC_SPV::MAX_PACKET_SIZE) { + if (bufferTop == supv::MAX_PACKET_SIZE) { *foundLen = remainingSize; disableAllReplies(); bufferTop = 0; @@ -1359,19 +1364,19 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket(DeviceCommandId_t id) // Prepare packet for downlink if (packetInBuffer) { uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); - result = verifyPacket(spacePacketBuffer, PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1); + result = verifyPacket(spacePacketBuffer, supv::SPACE_PACKET_HEADER_LENGTH + packetLen + 1); if (result != RETURN_OK) { sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl; return result; } handleMramDumpFile(id); if (downlinkMramDump == true) { - handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, id); + handleDeviceTM(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, id); } packetInBuffer = false; receivedMramDumpPackets++; if (expectedMramDumpPackets == receivedMramDumpPackets) { - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = supv::EXE_REPORT; } increaseExpectedMramReplies(id); return RETURN_OK; @@ -1381,7 +1386,7 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket(DeviceCommandId_t id) void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) { DeviceReplyMap::iterator mramDumpIter = deviceReplyMap.find(id); - DeviceReplyMap::iterator exeReportIter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); + DeviceReplyMap::iterator exeReportIter = deviceReplyMap.find(supv::EXE_REPORT); if (mramDumpIter == deviceReplyMap.end()) { sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Dump MRAM reply not " << "in reply map" << std::endl; @@ -1411,8 +1416,8 @@ void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) { return; } uint8_t sequenceFlags = spacePacketBuffer[2] >> 6; - if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT) && - (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { + if (sequenceFlags != static_cast(supv::SequenceFlags::LAST_PKT) && + (sequenceFlags != static_cast(supv::SequenceFlags::STANDALONE_PKT))) { // Command expects at least one MRAM packet more and the execution report info->expectedReplies = 2; // Wait maximum of 2 cycles for next MRAM packet @@ -1428,8 +1433,8 @@ void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) { } ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() { - uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & PLOC_SPV::APID_MASK; - if (apid != PLOC_SPV::APID_MRAM_DUMP_TM) { + uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & supv::APID_MASK; + if (apid != supv::APID_MRAM_DUMP_TM) { return NO_MRAM_PACKET; } return APERIODIC_REPLY; @@ -1439,9 +1444,9 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) { ReturnValue_t result = RETURN_OK; uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer); - if (id == PLOC_SPV::FIRST_MRAM_DUMP) { - if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) || - (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { + if (id == supv::FIRST_MRAM_DUMP) { + if (sequenceFlags == static_cast(supv::SequenceFlags::FIRST_PKT) || + (sequenceFlags == static_cast(supv::SequenceFlags::STANDALONE_PKT))) { result = createMramDumpFile(); if (result != RETURN_OK) { return result; @@ -1455,7 +1460,7 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) { } std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out); file.write( - reinterpret_cast(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH), + reinterpret_cast(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH), packetLen - 1); file.close(); return RETURN_OK; diff --git a/linux/devices/ploc/PlocSupervisorHandler.h b/linux/devices/ploc/PlocSupervisorHandler.h index c3cfb44a..b21ecf91 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.h +++ b/linux/devices/ploc/PlocSupervisorHandler.h @@ -25,7 +25,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase { public: PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, - Gpio uartIsolatorSwitch); + Gpio uartIsolatorSwitch, power::Switch_t powerSwitch); virtual ~PlocSupervisorHandler(); virtual ReturnValue_t initialize() override; @@ -105,24 +105,24 @@ class PlocSupervisorHandler : public DeviceHandlerBase { static const uint16_t APID_MASK = 0x7FF; static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; - uint8_t commandBuffer[PLOC_SPV::MAX_COMMAND_SIZE]; + uint8_t commandBuffer[supv::MAX_COMMAND_SIZE]; /** * This variable is used to store the id of the next reply to receive. This is necessary * because the PLOC sends as reply to each command at least one acknowledgment and execution * report. */ - DeviceCommandId_t nextReplyId = PLOC_SPV::NONE; + DeviceCommandId_t nextReplyId = supv::NONE; UartComIF* uartComIf = nullptr; LinuxLibgpioIF* gpioComIF = nullptr; Gpio uartIsolatorSwitch; - PLOC_SPV::HkSet hkset; - PLOC_SPV::BootStatusReport bootStatusReport; - PLOC_SPV::LatchupStatusReport latchupStatusReport; + supv::HkSet hkset; + supv::BootStatusReport bootStatusReport; + supv::LatchupStatusReport latchupStatusReport; - const power::Switch_t powerSwitch = pcduSwitches::PDU1_CH6_PLOC_12V; + const power::Switch_t powerSwitch = power::NO_SWITCH; /** Number of expected replies following the MRAM dump command */ uint32_t expectedMramDumpPackets = 0; @@ -133,7 +133,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase { uint16_t bufferTop = 0; /** This buffer is used to concatenate space packets received in two different read steps */ - uint8_t spacePacketBuffer[PLOC_SPV::MAX_PACKET_SIZE]; + uint8_t spacePacketBuffer[supv::MAX_PACKET_SIZE]; #ifdef TE0720_1CFA SdCardManager* sdcMan = nullptr; diff --git a/linux/devices/ploc/PlocUpdater.cpp b/linux/devices/ploc/PlocUpdater.cpp index 0980f669..220b1e00 100644 --- a/linux/devices/ploc/PlocUpdater.cpp +++ b/linux/devices/ploc/PlocUpdater.cpp @@ -123,9 +123,6 @@ void PlocUpdater::readCommandQueue() { if (result == HasReturnvaluesIF::RETURN_OK) { continue; } - - sif::debug << "PlocUpdater::readCommandQueue: Received message with invalid format" - << std::endl; } } @@ -145,7 +142,6 @@ void PlocUpdater::doStateMachine() { case State::COMMAND_EXECUTING: break; default: - sif::debug << "PlocUpdater::doStateMachine: Invalid state" << std::endl; break; } } @@ -199,10 +195,10 @@ void PlocUpdater::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_ void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) { switch (pendingCommand) { - case (PLOC_SPV::UPDATE_AVAILABLE): + case (supv::UPDATE_AVAILABLE): state = State::UPDATE_TRANSFER; break; - case (PLOC_SPV::UPDATE_IMAGE_DATA): + case (supv::UPDATE_IMAGE_DATA): if (remainingPackets == 0) { packetsSent = 0; // Reset packets sent variable for next update sequence state = State::UPDATE_VERIFY; @@ -210,14 +206,12 @@ void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) { state = State::UPDATE_TRANSFER; } break; - case (PLOC_SPV::UPDATE_VERIFY): + case (supv::UPDATE_VERIFY): triggerEvent(UPDATE_FINISHED); state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; + pendingCommand = supv::NONE; break; default: - sif::debug << "PlocUpdater::completionSuccessfulReceived: Invalid pending command" - << std::endl; state = State::IDLE; break; } @@ -225,20 +219,19 @@ void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) { void PlocUpdater::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { switch (pendingCommand) { - case (PLOC_SPV::UPDATE_AVAILABLE): { + case (supv::UPDATE_AVAILABLE): { triggerEvent(UPDATE_AVAILABLE_FAILED); break; } - case (PLOC_SPV::UPDATE_IMAGE_DATA): { + case (supv::UPDATE_IMAGE_DATA): { triggerEvent(UPDATE_TRANSFER_FAILED, packetsSent); break; } - case (PLOC_SPV::UPDATE_VERIFY): { + case (supv::UPDATE_VERIFY): { triggerEvent(UPDATE_VERIFY_FAILED); break; } default: - sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command " << std::endl; break; } state = State::IDLE; @@ -268,23 +261,23 @@ void PlocUpdater::commandUpdateAvailable() { calcImageCrc(); - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(image), + supv::UpdateInfo packet(supv::APID_UPDATE_AVAILABLE, static_cast(image), static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(), + supv::UPDATE_AVAILABLE, packet.getWholeData(), packet.getFullSize()); if (result != RETURN_OK) { sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_AVAILABLE); + triggerEvent(ACTION_COMMANDING_FAILED, result, supv::UPDATE_AVAILABLE); state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; + pendingCommand = supv::NONE; return; } - pendingCommand = PLOC_SPV::UPDATE_AVAILABLE; + pendingCommand = supv::UPDATE_AVAILABLE; state = State::COMMAND_EXECUTING; return; } @@ -308,56 +301,56 @@ void PlocUpdater::commandUpdatePacket() { payloadLength = MAX_SP_DATA; } - PLOC_SPV::UpdatePacket packet(payloadLength); + supv::UpdatePacket packet(payloadLength); file.read(reinterpret_cast(packet.getDataFieldPointer()), payloadLength); file.close(); // sequence count of first packet is 1 - packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK); + packet.setPacketSequenceCount((packetsSent + 1) & supv::SEQUENCE_COUNT_MASK); if (numOfUpdatePackets > 1) { adjustSequenceFlags(packet); } packet.makeCrc(); result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(), + supv::UPDATE_IMAGE_DATA, packet.getWholeData(), packet.getFullSize()); if (result != RETURN_OK) { sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update" << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_IMAGE_DATA); + triggerEvent(ACTION_COMMANDING_FAILED, result, supv::UPDATE_IMAGE_DATA); state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; + pendingCommand = supv::NONE; return; } remainingPackets--; packetsSent++; - pendingCommand = PLOC_SPV::UPDATE_IMAGE_DATA; + pendingCommand = supv::UPDATE_IMAGE_DATA; state = State::COMMAND_EXECUTING; } void PlocUpdater::commandUpdateVerify() { ReturnValue_t result = RETURN_OK; - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(image), + supv::UpdateInfo packet(supv::APID_UPDATE_VERIFY, static_cast(image), static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); result = - commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, PLOC_SPV::UPDATE_VERIFY, + commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_VERIFY, packet.getWholeData(), packet.getFullSize()); if (result != RETURN_OK) { sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_VERIFY); + triggerEvent(ACTION_COMMANDING_FAILED, result, supv::UPDATE_VERIFY); state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; + pendingCommand = supv::NONE; return; } state = State::COMMAND_EXECUTING; - pendingCommand = PLOC_SPV::UPDATE_VERIFY; + pendingCommand = supv::UPDATE_VERIFY; return; } @@ -384,12 +377,12 @@ void PlocUpdater::calcImageCrc() { imageCrc = (remainder ^ FINAL_XOR_VALUE_32); } -void PlocUpdater::adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet) { +void PlocUpdater::adjustSequenceFlags(supv::UpdatePacket& packet) { if (packetsSent == 0) { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT)); + packet.setSequenceFlags(static_cast(supv::SequenceFlags::FIRST_PKT)); } else if (remainingPackets == 1) { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::LAST_PKT)); + packet.setSequenceFlags(static_cast(supv::SequenceFlags::LAST_PKT)); } else { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::CONTINUED_PKT)); + packet.setSequenceFlags(static_cast(supv::SequenceFlags::CONTINUED_PKT)); } } diff --git a/linux/devices/ploc/PlocUpdater.h b/linux/devices/ploc/PlocUpdater.h index a7e6db4a..1bb9a1bd 100644 --- a/linux/devices/ploc/PlocUpdater.h +++ b/linux/devices/ploc/PlocUpdater.h @@ -23,7 +23,7 @@ * packets and sent to the PlocSupervisorHandler. * * @details The MPSoC has two boot memories (NVM0 and NVM1) where each stores two images (Partition - * A and Partition B) + * A and Partition B) * * @author J. Meier */ @@ -122,7 +122,7 @@ class PlocUpdater : public SystemObject, State state = State::IDLE; - ActionId_t pendingCommand = PLOC_SPV::NONE; + ActionId_t pendingCommand = supv::NONE; enum class Image : uint8_t { NONE, A, B }; @@ -168,7 +168,7 @@ class PlocUpdater : public SystemObject, void calcImageCrc(); - void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet); + void adjustSequenceFlags(supv::UpdatePacket& packet); }; #endif /* MISSION_DEVICES_PLOCUPDATER_H_ */ diff --git a/linux/devices/startracker/StarTrackerHandler.cpp b/linux/devices/startracker/StarTrackerHandler.cpp index 86bbc0dc..9b3c7721 100644 --- a/linux/devices/startracker/StarTrackerHandler.cpp +++ b/linux/devices/startracker/StarTrackerHandler.cpp @@ -15,7 +15,7 @@ extern "C" { } StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, - StrHelper* strHelper) + StrHelper* strHelper, power::Switch_t powerSwitch) : DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), @@ -39,7 +39,8 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, subscriptionSet(this), logSubscriptionSet(this), debugCameraSet(this), - strHelper(strHelper) { + strHelper(strHelper), + powerSwitch(powerSwitch) { if (comCookie == nullptr) { sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; } @@ -1223,8 +1224,10 @@ ReturnValue_t StarTrackerHandler::doSendReadHook() { return RETURN_OK; } -ReturnValue_t StarTrackerHandler::getSwitches(const uint8_t** switches, - uint8_t* numberOfSwitches) { +ReturnValue_t StarTrackerHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) { + if (powerSwitch == power::NO_SWITCH) { + return DeviceHandlerBase::NO_SWITCH; + } *numberOfSwitches = 1; *switches = &powerSwitch; return RETURN_OK; diff --git a/linux/devices/startracker/StarTrackerHandler.h b/linux/devices/startracker/StarTrackerHandler.h index 781eff02..2667db31 100644 --- a/linux/devices/startracker/StarTrackerHandler.h +++ b/linux/devices/startracker/StarTrackerHandler.h @@ -35,7 +35,7 @@ class StarTrackerHandler : public DeviceHandlerBase { * to high to enable the device. */ StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, - StrHelper* strHelper); + StrHelper* strHelper, power::Switch_t powerSwitch); virtual ~StarTrackerHandler(); ReturnValue_t initialize() override; @@ -163,14 +163,12 @@ class StarTrackerHandler : public DeviceHandlerBase { static const uint32_t BOOT_TIMEOUT = 1000; static const uint32_t DEFAULT_TRANSITION_DELAY = 15000; - class FlashReadCmd { - public: + struct FlashReadCmd { // Minimum length of a read command (region, length and filename) static const size_t MIN_LENGTH = 7; }; - class ChecksumCmd { - public: + struct ChecksumCmd { static const uint8_t ADDRESS_OFFSET = 1; static const uint8_t LENGTH_OFFSET = 5; // Length of checksum command @@ -270,7 +268,7 @@ class StarTrackerHandler : public DeviceHandlerBase { bool strHelperExecuting = false; - const power::Switch_t powerSwitch = pcduSwitches::PDU1_CH2_STAR_TRACKER_5V; + const power::Switch_t powerSwitch = power::NO_SWITCH; /** * @brief Handles internal state diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 8694f261..73581e4d 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -4,8 +4,12 @@ #include "OBSWConfig.h" -SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) - : DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this) { +SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + power::Switch_t powerSwitch) + : DeviceHandlerBase(objectId, comIF, comCookie), + rxDataset(this), + txDataset(this), + powerSwitch(powerSwitch) { if (comCookie == NULL) { sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl; } @@ -146,6 +150,22 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() { SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); } +//ReturnValue_t SyrlinksHkHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, +// uint8_t expectedReplies, bool useAlternateId, +// DeviceCommandId_t alternateReplyID) { +// switch (command->first) { +// case SYRLINKS::RESET_UNIT: { +// case SYRLINKS::SET_TX_MODE_STANDBY: +// case SYRLINKS::SET_TX_MODE_MODULATION: +// case SYRLINKS::SET_TX_MODE_CW: +// return DeviceHandlerBase::enableReplyInReplyMap(command, 1, true, SYRLINKS::ACK_REPLY); +// } +// default: +// break; +// } +// return DeviceHandlerBase::enableReplyInReplyMap(command); +//} + ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { ReturnValue_t result = RETURN_OK; @@ -177,6 +197,15 @@ ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remai return result; } +ReturnValue_t SyrlinksHkHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) { + if (powerSwitch == power::NO_SWITCH) { + return DeviceHandlerBase::NO_SWITCH; + } + *numberOfSwitches = 1; + *switches = &powerSwitch; + return RETURN_OK; +} + ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { ReturnValue_t result; @@ -184,7 +213,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons case (SYRLINKS::ACK_REPLY): result = verifyReply(packet, SYRLINKS::ACK_SIZE); if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgement reply has " + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgment reply has " "invalid crc" << std::endl; return CRC_FAILURE; diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index b2e893b2..8f828756 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -1,8 +1,9 @@ #ifndef MISSION_DEVICES_SYRLINKSHKHANDLER_H_ #define MISSION_DEVICES_SYRLINKSHKHANDLER_H_ -#include -#include +#include "devices/powerSwitcherList.h" +#include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" #include /** @@ -15,7 +16,8 @@ */ class SyrlinksHkHandler : public DeviceHandlerBase { public: - SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + power::Switch_t powerSwitch); virtual ~SyrlinksHkHandler(); /** @@ -28,12 +30,16 @@ class SyrlinksHkHandler : public DeviceHandlerBase { void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override; - void fillCommandAndReplyMap() override; ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, size_t commandDataLen) override; + void fillCommandAndReplyMap() override; +// ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, +// uint8_t expectedReplies = 1, bool useAlternateId = false, +// DeviceCommandId_t alternateReplyID = 0) override; ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) override; ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override; + ReturnValue_t getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) override; void setNormalDatapoolEntriesInvalid() override; uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -75,6 +81,8 @@ class SyrlinksHkHandler : public DeviceHandlerBase { SYRLINKS::RxDataset rxDataset; SYRLINKS::TxDataset txDataset; + const power::Switch_t powerSwitch = power::NO_SWITCH; + uint8_t agcValueHighByte; uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE]; From cfaba492da1cff3350b452fe015a0ad0c1b451ef Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 30 Mar 2022 09:21:40 +0200 Subject: [PATCH 05/17] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index b52f1925..532607bf 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit b52f19254b8072a32203eaab91ea3c65b513ba7e +Subproject commit 532607bf8f0e5b62788e5fb8a33ef5ae3a29aeb5 From ea23fda599713466c79d182a0c1ca2949da9af3d Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 30 Mar 2022 09:22:25 +0200 Subject: [PATCH 06/17] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index ed85e170..c1a81709 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit ed85e1706f818ec652285b57a31b113f60128f70 +Subproject commit c1a8170945f1cb5ed041175506eb8c1cfcbefc6a From 61a7f71e80cde6698b30b6bbbb328c7a77212841 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 30 Mar 2022 11:25:03 +0200 Subject: [PATCH 07/17] syrlinks writing lcl register --- mission/devices/SyrlinksHkHandler.cpp | 8 ++++++++ mission/devices/SyrlinksHkHandler.h | 2 ++ mission/devices/devicedefinitions/SyrlinksDefinitions.h | 1 + tmtc | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 73581e4d..15011c55 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -88,6 +88,12 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic rawPacket = commandBuffer; return RETURN_OK; } + case (SYRLINKS::WRITE_LCL_CONFIG): { + writeLclConfig.copy(reinterpret_cast(commandBuffer), writeLclConfig.size(), 0); + rawPacketLen = writeLclConfig.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } case (SYRLINKS::READ_RX_STATUS_REGISTERS): { readRxStatusRegCommand.copy(reinterpret_cast(commandBuffer), readRxStatusRegCommand.size(), 0); @@ -138,6 +144,8 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() { false, true, SYRLINKS::ACK_REPLY); this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, false, true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::WRITE_LCL_CONFIG, 2, nullptr, SYRLINKS::ACK_SIZE, false, + true, SYRLINKS::ACK_REPLY); this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset, diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index 8f828756..922cf0d1 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -61,12 +61,14 @@ class SyrlinksHkHandler : public DeviceHandlerBase { static const uint8_t CRC_INITIAL_VALUE = 0x0; + // Uses CRC-16/XMODEM std::string resetCommand = ""; std::string readRxStatusRegCommand = ""; std::string setTxModeStandby = ""; /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ std::string setTxModeModulation = ""; std::string setTxModeCw = ""; + std::string writeLclConfig = ""; std::string readTxStatus = ""; std::string readTxWaveform = ""; std::string readTxAgcValueHighByte = ""; diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index 3b56918a..268cb9ea 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -18,6 +18,7 @@ static const DeviceCommandId_t READ_TX_STATUS = 0x07; static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08; static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09; static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; +static const DeviceCommandId_t WRITE_LCL_CONFIG = 0x0B; /** Size of a simple transmission success response */ static const uint8_t ACK_SIZE = 12; diff --git a/tmtc b/tmtc index 5816f05c..c1a81709 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5816f05ccf8971f3cf2dd1d603dd3f5a33f6f504 +Subproject commit c1a8170945f1cb5ed041175506eb8c1cfcbefc6a From 53aca633b8249822198274f05cf0c58e7f7e5d3e Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 30 Mar 2022 16:29:58 +0200 Subject: [PATCH 08/17] write lcl config register --- linux/obc/PdecHandler.cpp | 2 ++ mission/devices/SyrlinksHkHandler.cpp | 28 ++++++++++++++++++- mission/devices/SyrlinksHkHandler.h | 5 +++- .../devicedefinitions/SyrlinksDefinitions.h | 3 +- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index b302d99e..48816512 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -326,6 +326,7 @@ void PdecHandler::handleNewTc() { printTC(tcLength); #endif /* OBSW_DEBUG_PDEC_HANDLER */ +#if OBSW_TC_FROM_PDEC == 1 store_address_t storeId; result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1); if (result != RETURN_OK) { @@ -343,6 +344,7 @@ void PdecHandler::handleNewTc() { tcStore->deleteData(storeId); return; } +#endif /* OBSW_TC_FROM_PDEC == 1 */ return; } diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 15011c55..34b27f42 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -101,6 +101,14 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic rawPacket = commandBuffer; return RETURN_OK; } + case (SYRLINKS::READ_LCL_CONFIG): { + readLclConfig.copy(reinterpret_cast(commandBuffer), + readLclConfig.size(), 0); + rawPacketLen = readLclConfig.size(); + rawPacket = commandBuffer; + rememberCommandId = SYRLINKS::READ_LCL_CONFIG; + return RETURN_OK; + } case (SYRLINKS::READ_TX_STATUS): { readTxStatus.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); rawPacketLen = readTxStatus.size(); @@ -144,8 +152,10 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() { false, true, SYRLINKS::ACK_REPLY); this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::WRITE_LCL_CONFIG, 2, nullptr, SYRLINKS::ACK_SIZE, false, + this->insertInCommandAndReplyMap(SYRLINKS::WRITE_LCL_CONFIG, 1, nullptr, SYRLINKS::ACK_SIZE, false, true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::READ_LCL_CONFIG, 1, nullptr, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset, @@ -241,6 +251,15 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons } parseRxStatusRegistersReply(packet); break; + case (SYRLINKS::READ_LCL_CONFIG): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read config lcl reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseLclConfigReply(packet); + break; case (SYRLINKS::READ_TX_STATUS): result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { @@ -427,6 +446,13 @@ void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { #endif } +void SyrlinksHkHandler::parseLclConfigReply(const uint8_t* packet) { + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + uint8_t lclConfig = convertHexStringToUint8(reinterpret_cast(packet + offset)); + sif::info << "SyrlinksHkHandler::parseRxStatusRegistersReply: Lcl config: " + << static_cast(lclConfig) << std::endl; +} + void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { PoolReadGuard readHelper(&txDataset); uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index 922cf0d1..5f9e461b 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -68,11 +68,12 @@ class SyrlinksHkHandler : public DeviceHandlerBase { /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ std::string setTxModeModulation = ""; std::string setTxModeCw = ""; - std::string writeLclConfig = ""; + std::string writeLclConfig = ""; std::string readTxStatus = ""; std::string readTxWaveform = ""; std::string readTxAgcValueHighByte = ""; std::string readTxAgcValueLowByte = ""; + std::string readLclConfig = ""; /** * In some cases it is not possible to extract from the received reply the information about @@ -162,6 +163,8 @@ class SyrlinksHkHandler : public DeviceHandlerBase { */ void parseRxStatusRegistersReply(const uint8_t* packet); + void parseLclConfigReply(const uint8_t* packet); + /** * @brief This function writes the read tx status register to the txStatusDataset. * @param packet Pointer to the received packet. diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index 268cb9ea..7399f2ac 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -18,7 +18,8 @@ static const DeviceCommandId_t READ_TX_STATUS = 0x07; static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08; static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09; static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; -static const DeviceCommandId_t WRITE_LCL_CONFIG = 0x0B; +static const DeviceCommandId_t WRITE_LCL_CONFIG = 11; +static const DeviceCommandId_t READ_LCL_CONFIG = 12; /** Size of a simple transmission success response */ static const uint8_t ACK_SIZE = 12; From d01d6d92f8f326935f1902735075cb4bfedc51bb Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 30 Mar 2022 18:11:21 +0200 Subject: [PATCH 09/17] rad sensor debug flag --- mission/devices/RadiationSensorHandler.cpp | 19 ++++++++++++++++++- .../devicedefinitions/RadSensorDefinitions.h | 8 +++++--- mission/tmtc/CCSDSHandler.cpp | 2 +- tmtc | 2 +- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index 5852ed6b..179444ca 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -91,6 +91,16 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t rawPacketLen = RAD_SENSOR::READ_SIZE; return RETURN_OK; } + case RAD_SENSOR::ENABLE_DEBUG_OUTPUT: { + printPeriodicData = true; + rawPacketLen = 0; + return RETURN_OK; + } + case RAD_SENSOR::DISABLE_DEBUG_OUTPUT: { + rawPacketLen = 0; + printPeriodicData = false; + return RETURN_OK; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -100,6 +110,8 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t void RadiationSensorHandler::fillCommandAndReplyMap() { this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP); this->insertInCommandMap(RAD_SENSOR::START_CONVERSION); + this->insertInCommandMap(RAD_SENSOR::ENABLE_DEBUG_OUTPUT); + this->insertInCommandMap(RAD_SENSOR::DISABLE_DEBUG_OUTPUT); this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset, RAD_SENSOR::READ_SIZE); } @@ -111,18 +123,23 @@ ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t switch (*foundId) { case RAD_SENSOR::START_CONVERSION: case RAD_SENSOR::WRITE_SETUP: + *foundLen = remainingSize; return IGNORE_REPLY_DATA; case RAD_SENSOR::READ_CONVERSIONS: { ReturnValue_t result = gpioIF->pullLow(gpioIds::ENABLE_RADFET); if (result != HasReturnvaluesIF::RETURN_OK) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "RadiationSensorHandler::buildCommandFromCommand; Pulling RADFET Enale pin " + sif::warning << "RadiationSensorHandler::scanForReply; Pulling RADFET Enale pin " "low failed" << std::endl; #endif } break; } + case RAD_SENSOR::ENABLE_DEBUG_OUTPUT: + case RAD_SENSOR::DISABLE_DEBUG_OUTPUT: + sif::info << "RadiationSensorHandler::scanForReply: " << remainingSize << std::endl; + break; default: break; } diff --git a/mission/devices/devicedefinitions/RadSensorDefinitions.h b/mission/devices/devicedefinitions/RadSensorDefinitions.h index ab49b61b..8f6b9f0b 100644 --- a/mission/devices/devicedefinitions/RadSensorDefinitions.h +++ b/mission/devices/devicedefinitions/RadSensorDefinitions.h @@ -9,9 +9,11 @@ static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending * This command initiates the ADC conversion for all channels including the internal * temperature sensor. */ -static const DeviceCommandId_t WRITE_SETUP = 0x1; -static const DeviceCommandId_t START_CONVERSION = 0x2; -static const DeviceCommandId_t READ_CONVERSIONS = 0x3; +static const DeviceCommandId_t WRITE_SETUP = 1; +static const DeviceCommandId_t START_CONVERSION = 2; +static const DeviceCommandId_t READ_CONVERSIONS = 3; +static const DeviceCommandId_t ENABLE_DEBUG_OUTPUT = 4; +static const DeviceCommandId_t DISABLE_DEBUG_OUTPUT = 5; /** * @brief This is the configuration byte which will be written to the setup register after diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 70e71052..a42a798a 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -313,7 +313,7 @@ void CCSDSHandler::enableTransmit() { return; } transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT); -#ifdef TE0720_1CFA +#ifndef TE0720_1CFA gpioIF->pullHigh(enTxClock); gpioIF->pullHigh(enTxData); #endif /* BOARD_TE0720 == 0 */ diff --git a/tmtc b/tmtc index c1a81709..eb4dc951 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit c1a8170945f1cb5ed041175506eb8c1cfcbefc6a +Subproject commit eb4dc95160ccf9093b46fa2d48240c69c85226ea From 6052363cdba88e38db69bd9380ceda5868cb29be Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 30 Mar 2022 18:13:14 +0200 Subject: [PATCH 10/17] submodule updates --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 532607bf..d8450c45 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 532607bf8f0e5b62788e5fb8a33ef5ae3a29aeb5 +Subproject commit d8450c45a7693f1d0f69da0d793e90c59f977be6 diff --git a/tmtc b/tmtc index eb4dc951..f7a3ad99 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit eb4dc95160ccf9093b46fa2d48240c69c85226ea +Subproject commit f7a3ad9981c2792d9d6bda335cb22e540c8f9b1a From 387595495e89e02cf8545daab1d1599d3bf83d6d Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 31 Mar 2022 09:11:01 +0200 Subject: [PATCH 11/17] reading temperature value --- mission/devices/SyrlinksHkHandler.cpp | 119 ++++++++++++++---- mission/devices/SyrlinksHkHandler.h | 18 ++- .../devicedefinitions/SyrlinksDefinitions.h | 26 ++-- 3 files changed, 121 insertions(+), 42 deletions(-) diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 34b27f42..881db510 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -102,8 +102,7 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic return RETURN_OK; } case (SYRLINKS::READ_LCL_CONFIG): { - readLclConfig.copy(reinterpret_cast(commandBuffer), - readLclConfig.size(), 0); + readLclConfig.copy(reinterpret_cast(commandBuffer), readLclConfig.size(), 0); rawPacketLen = readLclConfig.size(); rawPacket = commandBuffer; rememberCommandId = SYRLINKS::READ_LCL_CONFIG; @@ -117,26 +116,53 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic return RETURN_OK; } case (SYRLINKS::READ_TX_WAVEFORM): { - readTxWaveform.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + readTxWaveform.copy(reinterpret_cast(commandBuffer), readTxWaveform.size(), 0); rawPacketLen = readTxWaveform.size(); rememberCommandId = SYRLINKS::READ_TX_WAVEFORM; rawPacket = commandBuffer; return RETURN_OK; } case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): { - readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), readTxAgcValueHighByte.size(), 0); rawPacketLen = readTxAgcValueHighByte.size(); rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; rawPacket = commandBuffer; return RETURN_OK; } case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): { - readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), readTxAgcValueLowByte.size(), 0); rawPacketLen = readTxAgcValueLowByte.size(); rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; rawPacket = commandBuffer; return RETURN_OK; } + case (SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE): + tempPowerAmpBoardHighByte.copy(reinterpret_cast(commandBuffer), tempPowerAmpBoardHighByte.size(), + 0); + rawPacketLen = tempPowerAmpBoardHighByte.size(); + rememberCommandId = SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE; + rawPacket = commandBuffer; + return RETURN_OK; + case (SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE): + tempBasebandBoardHighByte.copy(reinterpret_cast(commandBuffer), tempBasebandBoardHighByte.size(), + 0); + rawPacketLen = tempBasebandBoardHighByte.size(); + rememberCommandId = SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE; + rawPacket = commandBuffer; + return RETURN_OK; + case (SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE): + tempBasebandBoardHighByte.copy(reinterpret_cast(commandBuffer), tempBasebandBoardHighByte.size(), + 0); + rawPacketLen = tempBasebandBoardHighByte.size(); + rememberCommandId = SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE; + rawPacket = commandBuffer; + return RETURN_OK; + case (SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE): + tempBasebandBoardLowByte.copy(reinterpret_cast(commandBuffer), tempBasebandBoardLowByte.size(), 0); + rawPacketLen = tempBasebandBoardLowByte.size(); + rememberCommandId = SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE; + rawPacket = commandBuffer; + return RETURN_OK; default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -152,10 +178,10 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() { false, true, SYRLINKS::ACK_REPLY); this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::WRITE_LCL_CONFIG, 1, nullptr, SYRLINKS::ACK_SIZE, false, - true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::READ_LCL_CONFIG, 1, nullptr, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::WRITE_LCL_CONFIG, 1, nullptr, SYRLINKS::ACK_SIZE, + false, true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::READ_LCL_CONFIG, 1, nullptr, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset, @@ -164,26 +190,18 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() { SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE, 1, nullptr, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE, 1, nullptr, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE, 1, nullptr, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE, 1, nullptr, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxDataset, SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); } -//ReturnValue_t SyrlinksHkHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, -// uint8_t expectedReplies, bool useAlternateId, -// DeviceCommandId_t alternateReplyID) { -// switch (command->first) { -// case SYRLINKS::RESET_UNIT: { -// case SYRLINKS::SET_TX_MODE_STANDBY: -// case SYRLINKS::SET_TX_MODE_MODULATION: -// case SYRLINKS::SET_TX_MODE_CW: -// return DeviceHandlerBase::enableReplyInReplyMap(command, 1, true, SYRLINKS::ACK_REPLY); -// } -// default: -// break; -// } -// return DeviceHandlerBase::enableReplyInReplyMap(command); -//} - ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { ReturnValue_t result = RETURN_OK; @@ -296,6 +314,51 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons } parseAgcLowByte(packet); break; + case (SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read temperature baseband board " + << "high byte reply has invalid crc" << std::endl; + return CRC_FAILURE; + } + rawTempBasebandBoard = convertHexStringToUint8(reinterpret_cast( + packet + SYRLINKS::MESSAGE_HEADER_SIZE)) + << 8; + break; + case (SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read temperature baseband board" + " low byte reply has invalid crc" + << std::endl; + return CRC_FAILURE; + } + rawTempBasebandBoard |= convertHexStringToUint8( + reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); + tempBasebandBoard = calcTempVal(rawTempBasebandBoard); + break; + case (SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read temperature power amplifier " + << "board high byte reply has invalid crc" << std::endl; + return CRC_FAILURE; + } + rawTempBasebandBoard = convertHexStringToUint8(reinterpret_cast( + packet + SYRLINKS::MESSAGE_HEADER_SIZE)) + << 8; + break; + case (SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read temperature power amplifier" + << " board low byte reply has invalid crc" << std::endl; + return CRC_FAILURE; + } + rawTempBasebandBoard |= convertHexStringToUint8( + reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); + rawTempPowerAmplifier = calcTempVal(rawTempPowerAmplifier); + break; default: { sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" << std::endl; return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; @@ -449,8 +512,8 @@ void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { void SyrlinksHkHandler::parseLclConfigReply(const uint8_t* packet) { uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; uint8_t lclConfig = convertHexStringToUint8(reinterpret_cast(packet + offset)); - sif::info << "SyrlinksHkHandler::parseRxStatusRegistersReply: Lcl config: " - << static_cast(lclConfig) << std::endl; + sif::info << "SyrlinksHkHandler::parseRxStatusRegistersReply: Lcl config: " + << static_cast(lclConfig) << std::endl; } void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { @@ -512,3 +575,5 @@ ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& lo } void SyrlinksHkHandler::setModeNormal() { mode = MODE_NORMAL; } + +float SyrlinksHkHandler::calcTempVal(uint16_t raw) { return 0.126984 * raw - 67.87; } diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index 5f9e461b..9b9e05c2 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -33,9 +33,6 @@ class SyrlinksHkHandler : public DeviceHandlerBase { ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, size_t commandDataLen) override; void fillCommandAndReplyMap() override; -// ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, -// uint8_t expectedReplies = 1, bool useAlternateId = false, -// DeviceCommandId_t alternateReplyID = 0) override; ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) override; ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override; @@ -74,6 +71,10 @@ class SyrlinksHkHandler : public DeviceHandlerBase { std::string readTxAgcValueHighByte = ""; std::string readTxAgcValueLowByte = ""; std::string readLclConfig = ""; + std::string tempPowerAmpBoardHighByte = ""; + std::string tempPowerAmpBoardLowByte = ""; + std::string tempBasebandBoardHighByte = ""; + std::string tempBasebandBoardLowByte = ""; /** * In some cases it is not possible to extract from the received reply the information about @@ -86,7 +87,11 @@ class SyrlinksHkHandler : public DeviceHandlerBase { const power::Switch_t powerSwitch = power::NO_SWITCH; - uint8_t agcValueHighByte; + uint8_t agcValueHighByte = 0; + uint16_t rawTempPowerAmplifier = 0; + uint16_t rawTempBasebandBoard = 0; + float tempPowerAmplifier = 0; + float tempBasebandBoard = 0; uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE]; @@ -182,6 +187,11 @@ class SyrlinksHkHandler : public DeviceHandlerBase { */ void parseAgcLowByte(const uint8_t* packet); void parseAgcHighByte(const uint8_t* packet); + + /** + * @brief Calculates temperature in degree celcius form raw value + */ + float calcTempVal(uint16_t); }; #endif /* MISSION_DEVICES_SYRLINKSHKHANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index 7399f2ac..affebff7 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -3,23 +3,27 @@ namespace SYRLINKS { -static const DeviceCommandId_t NONE = 0x0; -static const DeviceCommandId_t RESET_UNIT = 0x01; +static const DeviceCommandId_t NONE = 0; +static const DeviceCommandId_t RESET_UNIT = 1; /** Reads out all status registers */ -static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02; +static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 2; /** Sets Tx mode to standby */ -static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03; +static const DeviceCommandId_t SET_TX_MODE_STANDBY = 3; /** Starts transmission mode. Only reached when clock signal is applying to the data tx input */ -static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04; +static const DeviceCommandId_t SET_TX_MODE_MODULATION = 4; /** Sends out a single carrier wave for testing purpose */ -static const DeviceCommandId_t SET_TX_MODE_CW = 0x05; -static const DeviceCommandId_t ACK_REPLY = 0x06; -static const DeviceCommandId_t READ_TX_STATUS = 0x07; -static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08; -static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09; -static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; +static const DeviceCommandId_t SET_TX_MODE_CW = 5; +static const DeviceCommandId_t ACK_REPLY = 6; +static const DeviceCommandId_t READ_TX_STATUS = 7; +static const DeviceCommandId_t READ_TX_WAVEFORM = 8; +static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 9; +static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 10; static const DeviceCommandId_t WRITE_LCL_CONFIG = 11; static const DeviceCommandId_t READ_LCL_CONFIG = 12; +static const DeviceCommandId_t TEMP_POWER_AMPLIFIER_HIGH_BYTE = 13; +static const DeviceCommandId_t TEMP_POWER_AMPLIFIER_LOW_BYTE = 14; +static const DeviceCommandId_t TEMP_BASEBAND_BOARD_HIGH_BYTE = 15; +static const DeviceCommandId_t TEMP_BASEBAND_BOARD_LOW_BYTE = 16; /** Size of a simple transmission success response */ static const uint8_t ACK_SIZE = 12; From e9b2def10e0931bc9defca96a570775310a710f0 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 31 Mar 2022 11:50:33 +0200 Subject: [PATCH 12/17] mpsoc sending action command during startup to supervisor --- fsfw | 2 +- linux/devices/ploc/PlocMPSoCHandler.cpp | 84 +++++++++++++++++-------- mission/devices/SyrlinksHkHandler.cpp | 31 +++++++-- tmtc | 2 +- 4 files changed, 86 insertions(+), 33 deletions(-) diff --git a/fsfw b/fsfw index d8450c45..29cf8c90 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d8450c45a7693f1d0f69da0d793e90c59f977be6 +Subproject commit 29cf8c9009d1bbdc67512c35b2d161fe13659c34 diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index 06c72bae..d6777afd 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -87,8 +87,8 @@ void PlocMPSoCHandler::performOperationHook() { } } CommandMessage message; - for (ReturnValue_t result = commandActionHelperQueue->receiveMessage(&event); result == RETURN_OK; - result = commandActionHelperQueue->receiveMessage(&event)) { + for (ReturnValue_t result = commandActionHelperQueue->receiveMessage(&message); result == RETURN_OK; + result = commandActionHelperQueue->receiveMessage(&message)) { result = commandActionHelper.handleReply(&message); if (result == RETURN_OK) { continue; @@ -158,7 +158,6 @@ void PlocMPSoCHandler::doShutDown() { setMode(_MODE_POWER_DOWN); break; default: - sif::debug << "PlocMPSoCHandler::doShutDown: This should never happen" << std::endl; break; } } @@ -168,7 +167,7 @@ ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) } ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { - return HasReturnvaluesIF::RETURN_OK; + return NOTHING_TO_SEND; } ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, @@ -313,7 +312,7 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {} -uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } +uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { @@ -713,8 +712,26 @@ void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) } void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step, - ReturnValue_t returnCode) { - handleActionCommandFailure(actionId); + ReturnValue_t returnCode) { + switch (actionId) { + case supv::START_MPSOC: + sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to start MPSoC" + << std::endl; + powerState = PowerState::OFF; + break; + case supv::SHUTDOWN_MPSOC: + triggerEvent(MPSOC_SHUTDOWN_FAILED); + sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to shutdown MPSoC" + << std::endl; + // TODO: Setting state to on or off here? + powerState = PowerState::ON; + break; + default: + sif::debug + << "PlocMPSoCHandler::stepFailedReceived: Received unexpected action reply" + << std::endl; + break; + } } void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { @@ -722,18 +739,21 @@ void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, ui } void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) { - switch(actionId) { - case supv::START_MPSOC: { + if (actionId != supv::EXE_REPORT) { + sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action " + << "ID" << std::endl; + return; + } + switch(powerState) { + case PowerState::BOOTING: { powerState = PowerState::ON; break; } - case supv::SHUTDOWN_MPSOC: { + case PowerState::SHUTDOWN: { powerState = PowerState::OFF; break; - default: - sif::debug - << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action reply" - << std::endl; + } + default: { break; } } @@ -798,7 +818,7 @@ void PlocMPSoCHandler::disableAllReplies() { } } - /* We must always disable the execution report reply here */ + /* We always need to disable the execution report reply here */ disableExeReportReply(); nextReplyId = mpsoc::NONE; } @@ -840,17 +860,29 @@ uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) { void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) { switch (actionId) { - case supv::START_MPSOC: - powerState = PowerState::ON; - break; - case supv::SHUTDOWN_MPSOC: - triggerEvent(MPSOC_SHUTDOWN_FAILED); - // TODO: Setting state to on or off here? - powerState = PowerState::OFF; - break; + case supv::ACK_REPORT: + case supv::EXE_REPORT: + break; default: - sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Received unexpected action reply" - << std::endl; - break; + sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Did not expect this action ID " + << std::endl; + return; } + switch(powerState) { + case PowerState::BOOTING: { + sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to boot MPSoC" + << std::endl; + powerState = PowerState::OFF; + break; + } + case PowerState::SHUTDOWN: { + sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to shutdown MPSoC" + << std::endl; + powerState = PowerState::ON; + break; + } + default: + break; + } + return; } diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 881db510..017bd53c 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -45,6 +45,22 @@ ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) break; case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): *id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + nextCommand = SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE; + break; + case (SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE): + *id = SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE; + nextCommand = SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE; + break; + case (SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE): + *id = SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE; + nextCommand = SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE; + break; + case (SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE): + *id = SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE; + nextCommand = SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE; + break; + case (SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE): + *id = SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE; nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; break; default: @@ -144,9 +160,9 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic rawPacket = commandBuffer; return RETURN_OK; case (SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE): - tempBasebandBoardHighByte.copy(reinterpret_cast(commandBuffer), tempBasebandBoardHighByte.size(), + tempPowerAmpBoardLowByte.copy(reinterpret_cast(commandBuffer), tempPowerAmpBoardLowByte.size(), 0); - rawPacketLen = tempBasebandBoardHighByte.size(); + rawPacketLen = tempPowerAmpBoardLowByte.size(); rememberCommandId = SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE; rawPacket = commandBuffer; return RETURN_OK; @@ -336,6 +352,8 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons rawTempBasebandBoard |= convertHexStringToUint8( reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); tempBasebandBoard = calcTempVal(rawTempBasebandBoard); + sif::info << "Syrlinks temperature baseband board: " << tempBasebandBoard << " °C" + << std::endl; break; case (SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE): result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); @@ -344,7 +362,8 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons << "board high byte reply has invalid crc" << std::endl; return CRC_FAILURE; } - rawTempBasebandBoard = convertHexStringToUint8(reinterpret_cast( + rawTempPowerAmplifier = 0; + rawTempPowerAmplifier = convertHexStringToUint8(reinterpret_cast( packet + SYRLINKS::MESSAGE_HEADER_SIZE)) << 8; break; @@ -355,9 +374,11 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons << " board low byte reply has invalid crc" << std::endl; return CRC_FAILURE; } - rawTempBasebandBoard |= convertHexStringToUint8( + rawTempPowerAmplifier |= convertHexStringToUint8( reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); - rawTempPowerAmplifier = calcTempVal(rawTempPowerAmplifier); + tempPowerAmplifier = calcTempVal(rawTempPowerAmplifier); + sif::info << "Syrlinks temperature power amplifier board: " << tempPowerAmplifier << " °C" + << std::endl; break; default: { sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" << std::endl; diff --git a/tmtc b/tmtc index f7a3ad99..5ac8912d 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f7a3ad9981c2792d9d6bda335cb22e540c8f9b1a +Subproject commit 5ac8912dd2b47f01f66093187f15a9f9824ffd66 From f20ad98a523d5a5864db2e77c9ffa2750a758f48 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 31 Mar 2022 15:36:48 +0200 Subject: [PATCH 13/17] fsfw update --- SDK.log | 5 ----- fsfw | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 SDK.log diff --git a/SDK.log b/SDK.log deleted file mode 100644 index d90ec6b5..00000000 --- a/SDK.log +++ /dev/null @@ -1,5 +0,0 @@ -10:00:08 INFO : Registering command handlers for SDK TCF services -10:00:10 INFO : Launching XSCT server: xsct.bat -interactive C:\Users\EIVE_Reinraumrechner\eive-software\eive-obsw\temp_xsdb_launch_script.tcl -10:00:16 INFO : XSCT server has started successfully. -10:00:22 INFO : Successfully done setting XSCT server connection channel -10:00:22 INFO : Successfully done setting SDK workspace diff --git a/fsfw b/fsfw index 29cf8c90..fbf9626f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 29cf8c9009d1bbdc67512c35b2d161fe13659c34 +Subproject commit fbf9626fde2961cf08bd88bf87f5c1bca900e287 From 61769de4bf1cd7302061cec4d9a765d18b70ffb4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 31 Mar 2022 19:12:40 +0200 Subject: [PATCH 14/17] activate all suses again --- .../pollingSequenceFactory.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 652fb3bc..fdd4897e 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -165,17 +165,17 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #if OBSW_ADD_SUN_SENSORS == 1 - bool addSus0 = false; - bool addSus1 = false; - bool addSus2 = false; - bool addSus3 = false; - bool addSus4 = false; - bool addSus5 = false; - bool addSus6 = false; - bool addSus7 = false; - bool addSus8 = false; - bool addSus9 = false; - bool addSus10 = false; + bool addSus0 = true; + bool addSus1 = true; + bool addSus2 = true; + bool addSus3 = true; + bool addSus4 = true; + bool addSus5 = true; + bool addSus6 = true; + bool addSus7 = true; + bool addSus8 = true; + bool addSus9 = true; + bool addSus10 = true; bool addSus11 = true; /** * The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all From 1eb5a428cb35fbec27f67a7d5ce08d116e3c50fb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 1 Apr 2022 14:01:12 +0200 Subject: [PATCH 15/17] move GNSS NReset handling to assembly - Also update fsfwgen dependency --- bsp_q7s/core/InitMission.cpp | 6 ++-- bsp_q7s/core/ObjectFactory.cpp | 21 ++++++------ generators/fsfwgen | 2 +- linux/fsfwconfig/OBSWConfig.h.in | 2 +- mission/system/AcsBoardAssembly.cpp | 48 ++++++++++++++++++++------- mission/system/AcsBoardAssembly.h | 2 ++ mission/system/DualLaneAssemblyBase.h | 1 + 7 files changed, 55 insertions(+), 27 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 1d502fef..ced1d12a 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -127,12 +127,14 @@ void initmission::initTasks() { "SYS_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc); result = sysTask->addComponent(objects::ACS_BOARD_ASS); if (result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("ACS_ASS", objects::ACS_BOARD_ASS); + initmission::printAddObjectError("ACS_BOARD_ASS", objects::ACS_BOARD_ASS); } +#if OBSW_ADD_SUS_BOARD_ASS == 1 result = sysTask->addComponent(objects::SUS_BOARD_ASS); if (result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("SUS_ASS", objects::SUS_BOARD_ASS); + initmission::printAddObjectError("SUS_BOARD_ASS", objects::SUS_BOARD_ASS); } +#endif result = sysTask->addComponent(objects::TCS_BOARD_ASS); if (result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("TCS_BOARD_ASS", objects::TCS_BOARD_ASS); diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 125010f4..7bf53420 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -253,10 +253,8 @@ void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchI new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie); PDU1Handler* pdu1handler = new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie); - pdu1handler->assignChannelHookFunction(&pcdu::switchCallback, gpioComIF); PDU2Handler* pdu2handler = new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie); - pdu2handler->assignChannelHookFunction(&pcdu::switchCallback, gpioComIF); ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie); auto pcduHandler = new PCDUHandler(objects::PCDU_HANDLER, 50); @@ -559,15 +557,6 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI auto acsAss = new AcsBoardAssembly(objects::ACS_BOARD_ASS, objects::NO_OBJECT, pwrSwitcher, acsBoardHelper, gpioComIF); static_cast(acsAss); -#if OBSW_TEST_ACS_BOARD_ASS == 1 - CommandMessage msg; - ModeMessage::setModeMessage(&msg, ModeMessage::CMD_MODE_COMMAND, DeviceHandlerIF::MODE_NORMAL, - duallane::A_SIDE); - ReturnValue_t result = MessageQueueSenderIF::sendMessage(acsAss->getCommandQueue(), &msg); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Sending mode command failed" << std::endl; - } -#endif #endif /* OBSW_ADD_ACS_HANDLERS == 1 */ } @@ -962,3 +951,13 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { new UartTestClass(objects::UART_TEST); #endif } + +void ObjectFactory::testAcsBrdAss(AcsBoardAssembly* acsAss) { + CommandMessage msg; + ModeMessage::setModeMessage(&msg, ModeMessage::CMD_MODE_COMMAND, DeviceHandlerIF::MODE_NORMAL, + duallane::A_SIDE); + ReturnValue_t result = MessageQueueSenderIF::sendMessage(acsAss->getCommandQueue(), &msg); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Sending mode command failed" << std::endl; + } +} diff --git a/generators/fsfwgen b/generators/fsfwgen index 1c8be25e..5ad9fb94 160000 --- a/generators/fsfwgen +++ b/generators/fsfwgen @@ -1 +1 @@ -Subproject commit 1c8be25e185aada13392a75234fa463240f424a0 +Subproject commit 5ad9fb94af3312d29863527106396395f7b808a5 diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index e8525df1..bbf8da64 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -44,6 +44,7 @@ debugging. */ #define OBSW_ADD_PLOC_SUPERVISOR 0 #define OBSW_ADD_PLOC_MPSOC 0 #define OBSW_ADD_SUN_SENSORS 1 +#define OBSW_ADD_SUS_BOARD_ASS 1 #define OBSW_ADD_ACS_BOARD 1 #define OBSW_ADD_ACS_HANDLERS 1 #define OBSW_ADD_RW 0 @@ -115,7 +116,6 @@ debugging. */ #define OBSW_ADD_UART_TEST_CODE 0 #define OBSW_TEST_ACS 0 -#define OBSW_TEST_ACS_BOARD_ASS 0 #define OBSW_DEBUG_ACS 0 #define OBSW_TEST_SUS 0 #define OBSW_DEBUG_SUS 0 diff --git a/mission/system/AcsBoardAssembly.cpp b/mission/system/AcsBoardAssembly.cpp index 5a8f0956..e319f32b 100644 --- a/mission/system/AcsBoardAssembly.cpp +++ b/mission/system/AcsBoardAssembly.cpp @@ -142,12 +142,14 @@ ReturnValue_t AcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t s cmdSeq(helper.mgm0Lis3IdSideA, helper.mgm0SideAMode, ModeTableIdx::MGM_0_A); cmdSeq(helper.mgm1Rm3100IdSideA, helper.mgm1SideAMode, ModeTableIdx::MGM_1_A); if (gpsUsable) { - if (gpioIF->pullLow(gpioIds::GNSS_SELECT) != HasReturnvaluesIF::RETURN_OK) { -#if OBSW_VERBOSE_LEVEL >= 1 - sif::error << "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull GNSS select low" - << std::endl; -#endif - } + gpioHandler(gpioIds::GNSS_0_NRESET, true, + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" + "of GNSS 0 high (used GNSS)"); + gpioHandler(gpioIds::GNSS_1_NRESET, false, + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" + "of GNSS 1 low (unused GNSS)"); + gpioHandler(gpioIds::GNSS_SELECT, false, + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull GNSS select low"); } break; } @@ -165,12 +167,14 @@ ReturnValue_t AcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t s cmdSeq(helper.mgm2Lis3IdSideB, helper.mgm2SideBMode, ModeTableIdx::MGM_2_B); cmdSeq(helper.mgm3Rm3100IdSideB, helper.mgm3SideBMode, ModeTableIdx::MGM_3_B); if (gpsUsable) { - if (gpioIF->pullHigh(gpioIds::GNSS_SELECT) != HasReturnvaluesIF::RETURN_OK) { -#if OBSW_VERBOSE_LEVEL >= 1 - sif::error << "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull GNSS select high" - << std::endl; -#endif - } + gpioHandler(gpioIds::GNSS_0_NRESET, false, + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" + "of GNSS 0 low (unused GNSS)"); + gpioHandler(gpioIds::GNSS_1_NRESET, true, + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" + "of GNSS 1 high (used GNSS)"); + gpioHandler(gpioIds::GNSS_SELECT, true, + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull GNSS select high"); } break; } @@ -186,6 +190,12 @@ ReturnValue_t AcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t s cmdSeq(helper.mgm3Rm3100IdSideB, helper.mgm3SideBMode, ModeTableIdx::MGM_3_B); ReturnValue_t status = RETURN_OK; if (gpsUsable) { + gpioHandler(gpioIds::GNSS_0_NRESET, true, + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" + "of GNSS 0 high (used GNSS)"); + gpioHandler(gpioIds::GNSS_1_NRESET, true, + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" + "of GNSS 1 high (used GNSS)"); if (defaultSubmode == Submodes::A_SIDE) { status = gpioIF->pullLow(gpioIds::GNSS_SELECT); } else { @@ -233,6 +243,20 @@ void AcsBoardAssembly::selectGpsInDualMode(duallane::Submodes side) { } } +void AcsBoardAssembly::gpioHandler(gpioId_t gpio, bool high, std::string error) { + ReturnValue_t result = RETURN_OK; + if(high) { + result = gpioIF->pullHigh(gpio); + } else { + result = gpioIF->pullLow(gpio); + } + if (result != HasReturnvaluesIF::RETURN_OK) { +#if OBSW_VERBOSE_LEVEL >= 1 + sif::error << error << std::endl; +#endif + } +} + void AcsBoardAssembly::refreshHelperModes() { try { helper.gyro0SideAMode = childrenMap.at(helper.gyro0AdisIdSideA).mode; diff --git a/mission/system/AcsBoardAssembly.h b/mission/system/AcsBoardAssembly.h index 45242d1c..0ed65227 100644 --- a/mission/system/AcsBoardAssembly.h +++ b/mission/system/AcsBoardAssembly.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "DualLaneAssemblyBase.h" #include "DualLanePowerStateMachine.h" @@ -115,6 +116,7 @@ class AcsBoardAssembly : public DualLaneAssemblyBase { GpioIF* gpioIF = nullptr; FixedArrayList modeTable; + void gpioHandler(gpioId_t gpio, bool high, std::string error); ReturnValue_t initialize() override; diff --git a/mission/system/DualLaneAssemblyBase.h b/mission/system/DualLaneAssemblyBase.h index e0996848..3017afc0 100644 --- a/mission/system/DualLaneAssemblyBase.h +++ b/mission/system/DualLaneAssemblyBase.h @@ -50,6 +50,7 @@ class DualLaneAssemblyBase : public AssemblyBase, public ConfirmsFailuresIF { * @return */ bool isUseable(object_id_t object, Mode_t mode); + /** * Thin wrapper function which is required because the helper class * can not access protected member functions. From d3050625bbf5911eacdea71f2aeda80aa4175f45 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 1 Apr 2022 14:12:14 +0200 Subject: [PATCH 16/17] update fsfw dependency --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index fbf9626f..ce2f7c4f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit fbf9626fde2961cf08bd88bf87f5c1bca900e287 +Subproject commit ce2f7c4fdf97d92466c921135b9cec770ba7fd20 From 8a4de72713e2f2d5c2da59969bf3749913b39928 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 1 Apr 2022 14:13:37 +0200 Subject: [PATCH 17/17] update header file as well --- bsp_q7s/core/ObjectFactory.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 9bb2043c..bfa045c1 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -6,6 +6,7 @@ class UartComIF; class SpiComIF; class I2cComIF; class PowerSwitchIF; +class AcsBoardAssembly; namespace ObjectFactory { @@ -29,6 +30,8 @@ void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF); void createCcsdsComponents(LinuxLibgpioIF* gpioComIF); void createTestComponents(LinuxLibgpioIF* gpioComIF); +void testAcsBrdAss(AcsBoardAssembly* assAss); + }; // namespace ObjectFactory #endif /* BSP_Q7S_OBJECTFACTORY_H_ */