From f358719778fff29646ac91959d030c17f2a5f6f7 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 13 Mar 2023 16:33:48 +0100 Subject: [PATCH 01/40] added event in case of safe mode controller failure --- mission/acsDefs.h | 2 ++ mission/controller/AcsController.cpp | 9 ++++++++- mission/controller/AcsController.h | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mission/acsDefs.h b/mission/acsDefs.h index a724bbd7..7ba8dc13 100644 --- a/mission/acsDefs.h +++ b/mission/acsDefs.h @@ -32,6 +32,8 @@ static constexpr Event MULTIPLE_RW_INVALID = MAKE_EVENT(2, severity::HIGH); static constexpr Event MEKF_INVALID_INFO = MAKE_EVENT(3, severity::INFO); //!< MEKF was not able to compute a solution during any pointing ACS mode for a prolonged time. static constexpr Event MEKF_INVALID_MODE_VIOLATION = MAKE_EVENT(4, severity::HIGH); +//!< The ACS safe mode controller was not able to compute a solution and has failed. +static constexpr Event SAFE_MODE_CONTROLLER_FAILURE = MAKE_EVENT(5, severity::HIGH); extern const char* getModeStr(AcsMode mode); diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index d513d114..5eb4abac 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -173,7 +173,14 @@ void AcsController::performSafe() { sunTargetDir, satRateSafe, &errAng, magMomMtq); } if (result == returnvalue::FAILED) { - // ToDo: this should never ever happen or we are dead. prob add an event at least + if (not doomFlag) { + triggerEvent(acs::SAFE_MODE_CONTROLLER_FAILURE); + doomFlag = true; + } + doomCounter++; + if (doomCounter > 5) { + doomFlag = false; + } } actuatorCmd.cmdDipolMtq(magMomMtq, cmdDipolMtqs, diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index c0376127..829ab099 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -62,6 +62,9 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes uint8_t multipleRwUnavailableCounter = 0; bool mekfInvalidFlag = false; uint8_t mekfInvalidCounter = 0; + bool doomFlag = false; + uint8_t doomCounter = 0; + int32_t cmdSpeedRws[4] = {0, 0, 0, 0}; int16_t cmdDipolMtqs[3] = {0, 0, 0}; From 1f9935cf22ea369c639632e948d0fbfb46063716 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 13:12:42 +0100 Subject: [PATCH 02/40] tweak scheduling frequencies --- CHANGELOG.md | 7 +++++++ bsp_q7s/core/scheduling.cpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be95f310..828f87a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ will consitute of a breaking change warranting a new major release: ## Added - Added `EXECUTE_SHELL_CMD` action command for `CoreController` to execute arbitrary Linux commands. +- Added some missing PLOC commands. + PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/462 ## Fixed @@ -26,6 +28,11 @@ will consitute of a breaking change warranting a new major release: - Limitation of RW speeds was done before converting them to the correct unit scale. - The Syrlinks task now has a proper name instead of `MAIN_SPI`. +## Changed + +- I2C PST now has a polling frequency of 0.4 seconds instead of 0.2 seconds. +- GS PST now has a polling frequency of 0.5 seconds instead of 1 second. + # [v1.37.0] 2023-03-11 eive-tmtc: v2.18.1 diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index 33869afd..4faa643a 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -488,7 +488,7 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction #if OBSW_ADD_I2C_TEST_CODE == 0 FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask( - "I2C_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + "I2C_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.4, missedDeadlineFunc); result = pst::pstI2c(i2cPst); if (result != returnvalue::OK) { if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { @@ -503,7 +503,7 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction #if OBSW_ADD_GOMSPACE_PCDU == 1 FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask( - "GS_PST_TASK", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); + "GS_PST_TASK", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc); result = pst::pstGompaceCan(gomSpacePstTask); if (result != returnvalue::OK) { if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { From c9e16642c5956b8e2384157502834441c2da95ac Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 13:32:13 +0100 Subject: [PATCH 03/40] refactor power code --- CHANGELOG.md | 7 +++++ bsp_q7s/core/CoreController.cpp | 22 +++++++++----- bsp_q7s/core/ObjectFactory.cpp | 12 ++++---- bsp_q7s/obsw.cpp | 2 ++ mission/devices/PcduHandler.cpp | 4 +++ mission/devices/PcduHandler.h | 7 ++++- .../{PDU1Handler.cpp => Pdu1Handler.cpp} | 29 +++++++++---------- .../devices/{PDU1Handler.h => Pdu1Handler.h} | 6 ++-- .../{PDU2Handler.cpp => Pdu2Handler.cpp} | 29 +++++++++---------- .../devices/{PDU2Handler.h => Pdu2Handler.h} | 6 ++-- 10 files changed, 73 insertions(+), 51 deletions(-) rename mission/devices/{PDU1Handler.cpp => Pdu1Handler.cpp} (87%) rename mission/devices/{PDU1Handler.h => Pdu1Handler.h} (93%) rename mission/devices/{PDU2Handler.cpp => Pdu2Handler.cpp} (88%) rename mission/devices/{PDU2Handler.h => Pdu2Handler.h} (93%) diff --git a/CHANGELOG.md b/CHANGELOG.md index be95f310..92c4cc77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,13 @@ will consitute of a breaking change warranting a new major release: - Limitation of RW speeds was done before converting them to the correct unit scale. - The Syrlinks task now has a proper name instead of `MAIN_SPI`. +## Changed + +- Initialize switch states to a special `SWITCH_STATE_UNKNOWN` (2) variable. Return + `returnvalue::FAILED` in switch state getter. +- Wait 1 second before commanding SAFE mode. This ensures or at least increases the chance that + the switch states were initialized. + # [v1.37.0] 2023-03-11 eive-tmtc: v2.18.1 diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 702264ab..085d27de 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -32,8 +32,13 @@ xsc::Chip CoreController::CURRENT_CHIP = xsc::Chip::NO_CHIP; xsc::Copy CoreController::CURRENT_COPY = xsc::Copy::NO_COPY; CoreController::CoreController(object_id_t objectId) - : ExtendedControllerBase(objectId, 5), cmdExecutor(4096), cmdReplyBuf(4096, true), cmdRepliesSizes(128), - opDivider5(5), opDivider10(10), hkSet(this) { + : ExtendedControllerBase(objectId, 5), + cmdExecutor(4096), + cmdReplyBuf(4096, true), + cmdRepliesSizes(128), + opDivider5(5), + opDivider10(10), + hkSet(this) { cmdExecutor.setRingBuffer(&cmdReplyBuf, &cmdRepliesSizes); try { sdcMan = SdCardManager::instance(); @@ -102,14 +107,14 @@ void CoreController::performControlOperation() { sdStateMachine(); performMountedSdCardOperations(); readHkData(); - if(shellCmdIsExecuting) { + if (shellCmdIsExecuting) { bool replyReceived = false; // TODO: We could read the data in the ring buffer and send it as an action data reply. - if(cmdExecutor.check(replyReceived) == CommandExecutor::EXECUTION_FINISHED) { + if (cmdExecutor.check(replyReceived) == CommandExecutor::EXECUTION_FINISHED) { actionHelper.finish(true, successRecipient, EXECUTE_SHELL_CMD); shellCmdIsExecuting = false; cmdReplyBuf.clear(); - while(not cmdRepliesSizes.empty()) { + while (not cmdRepliesSizes.empty()) { cmdRepliesSizes.pop(); } successRecipient = MessageQueueIF::NO_QUEUE; @@ -316,14 +321,15 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_ // Warning: This function will never return, because it reboots the system return actionReboot(data, size); } - case(EXECUTE_SHELL_CMD): { + case (EXECUTE_SHELL_CMD): { std::string cmd = std::string(cmd, size); - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or shellCmdIsExecuting) { + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or + shellCmdIsExecuting) { return HasActionsIF::IS_BUSY; } cmdExecutor.load(cmd, false, false); ReturnValue_t result = cmdExecutor.execute(); - if(result != returnvalue::OK) { + if (result != returnvalue::OK) { return result; } shellCmdIsExecuting = true; diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 3092e69d..057c7e47 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -74,6 +74,8 @@ #include #include #include +#include +#include #include #include #include @@ -102,8 +104,6 @@ #include "mission/devices/HeaterHandler.h" #include "mission/devices/Max31865PT1000Handler.h" #include "mission/devices/P60DockHandler.h" -#include "mission/devices/PDU1Handler.h" -#include "mission/devices/PDU2Handler.h" #include "mission/devices/PayloadPcduHandler.h" #include "mission/devices/RadiationSensorHandler.h" #include "mission/devices/RwHandler.h" @@ -193,12 +193,12 @@ void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchI new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie, p60Fdir); auto pdu1Fdir = new GomspacePowerFdir(objects::PDU1_HANDLER); - PDU1Handler* pdu1handler = - new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie, pdu1Fdir); + Pdu1Handler* pdu1handler = + new Pdu1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie, pdu1Fdir); auto pdu2Fdir = new GomspacePowerFdir(objects::PDU2_HANDLER); - PDU2Handler* pdu2handler = - new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie, pdu2Fdir); + Pdu2Handler* pdu2handler = + new Pdu2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie, pdu2Fdir); auto acuFdir = new GomspacePowerFdir(objects::ACU_HANDLER); ACUHandler* acuhandler = diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index e264283f..e16d30bb 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -66,6 +66,8 @@ int obsw::obsw(int argc, char* argv[]) { // Command the EIVE system to safe mode #if OBSW_COMMAND_SAFE_MODE_AT_STARTUP == 1 + // This ensures that the PCDU switches were updated. + TaskFactory::delayTask(1000); commandEiveSystemToSafe(); #else announceAllModes(); diff --git a/mission/devices/PcduHandler.cpp b/mission/devices/PcduHandler.cpp index f5873fcf..17e2f88f 100644 --- a/mission/devices/PcduHandler.cpp +++ b/mission/devices/PcduHandler.cpp @@ -19,6 +19,7 @@ PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) commandQueue = QueueFactory::instance()->createMessageQueue( cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); pwrLock = MutexFactory::instance()->createMutex(); + std::memset(switchStates, SWITCH_STATE_UNKNOWN, sizeof(switchStates)); } PCDUHandler::~PCDUHandler() {} @@ -407,6 +408,9 @@ ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { MutexGuard mg(pwrLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); currentState = switchStates[switchNr]; } + if (currentState == SWITCH_STATE_UNKNOWN) { + return returnvalue::FAILED; + } if (currentState == 1) { return PowerSwitchIF::SWITCH_ON; } else { diff --git a/mission/devices/PcduHandler.h b/mission/devices/PcduHandler.h index 45bbd392..dbd9b5e3 100644 --- a/mission/devices/PcduHandler.h +++ b/mission/devices/PcduHandler.h @@ -35,7 +35,11 @@ class PCDUHandler : public PowerSwitchIF, virtual ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override; virtual ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override; - virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override; + /** + * @param switchNr + * @return returnvalue::FAILED if the switch state has not been updated yet. + */ + ReturnValue_t getSwitchState(uint8_t switchNr) const override; virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; virtual uint32_t getSwitchDelayMs(void) const override; virtual object_id_t getObjectId() const override; @@ -84,6 +88,7 @@ class PCDUHandler : public PowerSwitchIF, /** The timeStamp of the current pdu1HkTableDataset */ CCSDSTime::CDS_short timeStampPdu1HkDataset; + uint8_t SWITCH_STATE_UNKNOWN = 2; uint8_t switchStates[pcdu::NUMBER_OF_SWITCHES]; /** * Pointer to the IPCStore. diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/Pdu1Handler.cpp similarity index 87% rename from mission/devices/PDU1Handler.cpp rename to mission/devices/Pdu1Handler.cpp index 9a44da5e..25f14c76 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/Pdu1Handler.cpp @@ -1,11 +1,10 @@ -#include "PDU1Handler.h" - #include +#include #include #include "devices/powerSwitcherList.h" -PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, +Pdu1Handler::Pdu1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, FailureIsolationBase *customFdir) : GomspaceDeviceHandler(objectId, comIF, comCookie, cfg, customFdir), coreHk(this), @@ -13,23 +12,23 @@ PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comC initPduConfigTable(); } -PDU1Handler::~PDU1Handler() {} +Pdu1Handler::~Pdu1Handler() {} -ReturnValue_t PDU1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { +ReturnValue_t Pdu1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { *id = GOMSPACE::REQUEST_HK_TABLE; return buildCommandFromCommand(*id, NULL, 0); } -void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { +void Pdu1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { parseHkTableReply(packet); } -void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { +void Pdu1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { this->channelSwitchHook = hook; this->hookArgs = args; } -ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker, +ReturnValue_t Pdu1Handler::setParamCallback(SetParamMessageUnpacker &unpacker, bool afterExecution) { using namespace PDU1; GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU1; @@ -79,15 +78,15 @@ ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker, return returnvalue::OK; } -void PDU1Handler::letChildHandleConfigReply(DeviceCommandId_t id, const uint8_t *packet) { +void Pdu1Handler::letChildHandleConfigReply(DeviceCommandId_t id, const uint8_t *packet) { handleDeviceTm(packet, PDU::CONFIG_TABLE_SIZE, id); } -void PDU1Handler::parseHkTableReply(const uint8_t *packet) { +void Pdu1Handler::parseHkTableReply(const uint8_t *packet) { GomspaceDeviceHandler::parsePduHkTable(coreHk, auxHk, packet); } -ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, +ReturnValue_t Pdu1Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { initializePduPool(localDataPoolMap, poolManager, pcdu::INIT_SWITCHES_PDU1); poolManager.subscribeForDiagPeriodicPacket( @@ -97,7 +96,7 @@ ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDat return returnvalue::OK; } -LocalPoolDataSetBase *PDU1Handler::getDataSetHandle(sid_t sid) { +LocalPoolDataSetBase *Pdu1Handler::getDataSetHandle(sid_t sid) { if (sid == coreHk.getSid()) { return &coreHk; } else if (sid == auxHk.getSid()) { @@ -106,7 +105,7 @@ LocalPoolDataSetBase *PDU1Handler::getDataSetHandle(sid_t sid) { return nullptr; } -ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { +ReturnValue_t Pdu1Handler::printStatus(DeviceCommandId_t cmd) { ReturnValue_t result = returnvalue::OK; switch (cmd) { case (GOMSPACE::PRINT_SWITCH_V_I): { @@ -137,7 +136,7 @@ ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { return result; } -void PDU1Handler::printHkTableSwitchVI() { +void Pdu1Handler::printHkTableSwitchVI() { using namespace PDU1; sif::info << "PDU1 Info: " << std::endl; sif::info << "Boot Cause: " << auxHk.bootcause << " | Boot Count: " << std::setw(4) << std::right @@ -163,7 +162,7 @@ void PDU1Handler::printHkTableSwitchVI() { printerHelper("Syrlinks", Channels::SYRLINKS); } -void PDU1Handler::printHkTableLatchups() { +void Pdu1Handler::printHkTableLatchups() { using namespace PDU1; sif::info << "PDU1 Latchup Information" << std::endl; auto printerHelper = [&](std::string channelStr, Channels idx) { diff --git a/mission/devices/PDU1Handler.h b/mission/devices/Pdu1Handler.h similarity index 93% rename from mission/devices/PDU1Handler.h rename to mission/devices/Pdu1Handler.h index 262283a6..b81f647e 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/Pdu1Handler.h @@ -19,11 +19,11 @@ * ACS 3.3V for Side A group, channel 7 * Unoccupied, 5V, channel 8 */ -class PDU1Handler : public GomspaceDeviceHandler { +class Pdu1Handler : public GomspaceDeviceHandler { public: - PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + Pdu1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, FailureIsolationBase* customFdir); - virtual ~PDU1Handler(); + virtual ~Pdu1Handler(); virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/Pdu2Handler.cpp similarity index 88% rename from mission/devices/PDU2Handler.cpp rename to mission/devices/Pdu2Handler.cpp index 4db6999f..363c5f51 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/Pdu2Handler.cpp @@ -1,11 +1,10 @@ -#include "PDU2Handler.h" - #include +#include #include #include "devices/powerSwitcherList.h" -PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, +Pdu2Handler::Pdu2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, FailureIsolationBase *customFdir) : GomspaceDeviceHandler(objectId, comIF, comCookie, cfg, customFdir), coreHk(this), @@ -13,27 +12,27 @@ PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comC initPduConfigTable(); } -PDU2Handler::~PDU2Handler() {} +Pdu2Handler::~Pdu2Handler() {} -ReturnValue_t PDU2Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { +ReturnValue_t Pdu2Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { *id = GOMSPACE::REQUEST_HK_TABLE; return buildCommandFromCommand(*id, NULL, 0); } -void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { +void Pdu2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { parseHkTableReply(packet); } -void PDU2Handler::letChildHandleConfigReply(DeviceCommandId_t id, const uint8_t *packet) { +void Pdu2Handler::letChildHandleConfigReply(DeviceCommandId_t id, const uint8_t *packet) { handleDeviceTm(packet, PDU::CONFIG_TABLE_SIZE, id); } -void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { +void Pdu2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { this->channelSwitchHook = hook; this->hookArgs = args; } -LocalPoolDataSetBase *PDU2Handler::getDataSetHandle(sid_t sid) { +LocalPoolDataSetBase *Pdu2Handler::getDataSetHandle(sid_t sid) { if (sid == coreHk.getSid()) { return &coreHk; } else if (sid == auxHk.getSid()) { @@ -42,11 +41,11 @@ LocalPoolDataSetBase *PDU2Handler::getDataSetHandle(sid_t sid) { return nullptr; } -void PDU2Handler::parseHkTableReply(const uint8_t *packet) { +void Pdu2Handler::parseHkTableReply(const uint8_t *packet) { GomspaceDeviceHandler::parsePduHkTable(coreHk, auxHk, packet); } -ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, +ReturnValue_t Pdu2Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { initializePduPool(localDataPoolMap, poolManager, pcdu::INIT_SWITCHES_PDU2); poolManager.subscribeForDiagPeriodicPacket( @@ -56,7 +55,7 @@ ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDat return returnvalue::OK; } -ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { +ReturnValue_t Pdu2Handler::printStatus(DeviceCommandId_t cmd) { ReturnValue_t result = returnvalue::OK; switch (cmd) { case (GOMSPACE::PRINT_SWITCH_V_I): { @@ -87,7 +86,7 @@ ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { return result; } -void PDU2Handler::printHkTableSwitchVI() { +void Pdu2Handler::printHkTableSwitchVI() { using namespace PDU2; sif::info << "PDU2 Info:" << std::endl; sif::info << "Boot Cause: " << auxHk.bootcause << " | Boot Count: " << std::setw(4) << std::right @@ -111,7 +110,7 @@ void PDU2Handler::printHkTableSwitchVI() { printerHelper("Payload Camera", Channels::PAYLOAD_CAMERA); } -void PDU2Handler::printHkTableLatchups() { +void Pdu2Handler::printHkTableLatchups() { using namespace PDU2; sif::info << "PDU2 Latchup Information" << std::endl; auto printerHelper = [&](std::string channelStr, Channels idx) { @@ -129,7 +128,7 @@ void PDU2Handler::printHkTableLatchups() { printerHelper("Payload Camera", Channels::PAYLOAD_CAMERA); } -ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker, +ReturnValue_t Pdu2Handler::setParamCallback(SetParamMessageUnpacker &unpacker, bool afterExecution) { using namespace PDU2; GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU2; diff --git a/mission/devices/PDU2Handler.h b/mission/devices/Pdu2Handler.h similarity index 93% rename from mission/devices/PDU2Handler.h rename to mission/devices/Pdu2Handler.h index 40204502..acb229dc 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/Pdu2Handler.h @@ -19,11 +19,11 @@ * ACS Board (Gyro, MGMs, GPS), 3.3V channel 7 * Payload Camera, 8V, channel 8 */ -class PDU2Handler : public GomspaceDeviceHandler { +class Pdu2Handler : public GomspaceDeviceHandler { public: - PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + Pdu2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, FailureIsolationBase* customFdir); - virtual ~PDU2Handler(); + virtual ~Pdu2Handler(); virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; From 6688499128aab008332dc5a302a9e35321331ea3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 13:56:19 +0100 Subject: [PATCH 04/40] power updates --- CHANGELOG.md | 2 + bsp_q7s/core/ObjectFactory.cpp | 2 +- fsfw | 2 +- mission/devices/CMakeLists.txt | 4 +- mission/devices/PcduHandler.cpp | 50 +++++++++---------- mission/devices/PcduHandler.h | 6 +-- .../system/objects/DualLaneAssemblyBase.cpp | 6 ++- 7 files changed, 39 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c4cc77..8084922a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ will consitute of a breaking change warranting a new major release: `returnvalue::FAILED` in switch state getter. - Wait 1 second before commanding SAFE mode. This ensures or at least increases the chance that the switch states were initialized. +- Dual Lane Assemblies: The returnvalues of the dual lane power state machine FSM are not ignored + anymore. # [v1.37.0] 2023-03-11 diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 057c7e47..09431ea2 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -203,7 +203,7 @@ void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchI auto acuFdir = new GomspacePowerFdir(objects::ACU_HANDLER); ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie, acuFdir); - auto pcduHandler = new PCDUHandler(objects::PCDU_HANDLER, 50); + auto pcduHandler = new PcduHandler(objects::PCDU_HANDLER, 50); /** * Setting PCDU devices to mode normal immediately after start up because PCDU is always diff --git a/fsfw b/fsfw index 9a8d775e..0b0a0299 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9a8d775eb1a8788ad844215bf2a42d9f707767c0 +Subproject commit 0b0a0299bc044e67413d8912ceb76a779d76ee4e diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index cb6c066a..68e369a0 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -5,8 +5,8 @@ target_sources( Tmp1075Handler.cpp PcduHandler.cpp P60DockHandler.cpp - PDU1Handler.cpp - PDU2Handler.cpp + Pdu1Handler.cpp + Pdu2Handler.cpp ACUHandler.cpp SyrlinksHandler.cpp Max31865PT1000Handler.cpp diff --git a/mission/devices/PcduHandler.cpp b/mission/devices/PcduHandler.cpp index 17e2f88f..4c2f742c 100644 --- a/mission/devices/PcduHandler.cpp +++ b/mission/devices/PcduHandler.cpp @@ -7,7 +7,7 @@ #include #include -PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) +PcduHandler::PcduHandler(object_id_t setObjectId, size_t cmdQueueSize) : SystemObject(setObjectId), poolManager(this, nullptr), p60CoreHk(objects::P60DOCK_HANDLER), @@ -22,9 +22,9 @@ PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) std::memset(switchStates, SWITCH_STATE_UNKNOWN, sizeof(switchStates)); } -PCDUHandler::~PCDUHandler() {} +PcduHandler::~PcduHandler() {} -ReturnValue_t PCDUHandler::performOperation(uint8_t counter) { +ReturnValue_t PcduHandler::performOperation(uint8_t counter) { if (counter == DeviceHandlerIF::PERFORM_OPERATION) { readCommandQueue(); } @@ -52,7 +52,7 @@ ReturnValue_t PCDUHandler::performOperation(uint8_t counter) { return returnvalue::OK; } -ReturnValue_t PCDUHandler::initialize() { +ReturnValue_t PcduHandler::initialize() { ReturnValue_t result; IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); @@ -100,7 +100,7 @@ ReturnValue_t PCDUHandler::initialize() { return returnvalue::OK; } -void PCDUHandler::initializeSwitchStates() { +void PcduHandler::initializeSwitchStates() { using namespace pcdu; try { for (uint8_t idx = 0; idx < NUMBER_OF_SWITCHES; idx++) { @@ -117,7 +117,7 @@ void PCDUHandler::initializeSwitchStates() { } } -void PCDUHandler::readCommandQueue() { +void PcduHandler::readCommandQueue() { ReturnValue_t result = returnvalue::OK; CommandMessage command; @@ -130,9 +130,9 @@ void PCDUHandler::readCommandQueue() { } } -MessageQueueId_t PCDUHandler::getCommandQueue() const { return commandQueue->getId(); } +MessageQueueId_t PcduHandler::getCommandQueue() const { return commandQueue->getId(); } -void PCDUHandler::handleChangedDataset(sid_t sid, store_address_t storeId, bool* clearMessage) { +void PcduHandler::handleChangedDataset(sid_t sid, store_address_t storeId, bool* clearMessage) { if (sid == sid_t(objects::PDU2_HANDLER, static_cast(P60System::SetIds::CORE))) { updateHkTableDataset(storeId, &pdu2CoreHk, &timeStampPdu2HkDataset); updatePdu2SwitchStates(); @@ -144,7 +144,7 @@ void PCDUHandler::handleChangedDataset(sid_t sid, store_address_t storeId, bool* } } -void PCDUHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, +void PcduHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, CCSDSTime::CDS_short* datasetTimeStamp) { ReturnValue_t result; @@ -170,7 +170,7 @@ void PCDUHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSet } } -void PCDUHandler::updatePdu2SwitchStates() { +void PcduHandler::updatePdu2SwitchStates() { using namespace pcdu; using namespace PDU2; GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU2; @@ -207,7 +207,7 @@ void PCDUHandler::updatePdu2SwitchStates() { } } -void PCDUHandler::updatePdu1SwitchStates() { +void PcduHandler::updatePdu1SwitchStates() { using namespace pcdu; using namespace PDU1; PoolReadGuard rg0(&switcherSet); @@ -244,9 +244,9 @@ void PCDUHandler::updatePdu1SwitchStates() { } } -LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { return &poolManager; } +LocalDataPoolManager* PcduHandler::getHkManagerHandle() { return &poolManager; } -ReturnValue_t PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) { +ReturnValue_t PcduHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) { using namespace pcdu; ReturnValue_t result; uint16_t memoryAddress = 0; @@ -396,9 +396,9 @@ ReturnValue_t PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onO return result; } -ReturnValue_t PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) { return returnvalue::OK; } +ReturnValue_t PcduHandler::sendFuseOnCommand(uint8_t fuseNr) { return returnvalue::OK; } -ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { +ReturnValue_t PcduHandler::getSwitchState(uint8_t switchNr) const { if (switchNr >= pcdu::NUMBER_OF_SWITCHES) { sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl; return returnvalue::FAILED; @@ -409,7 +409,7 @@ ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { currentState = switchStates[switchNr]; } if (currentState == SWITCH_STATE_UNKNOWN) { - return returnvalue::FAILED; + return PowerSwitchIF::SWITCH_UNKNOWN; } if (currentState == 1) { return PowerSwitchIF::SWITCH_ON; @@ -418,13 +418,13 @@ ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { } } -ReturnValue_t PCDUHandler::getFuseState(uint8_t fuseNr) const { return returnvalue::OK; } +ReturnValue_t PcduHandler::getFuseState(uint8_t fuseNr) const { return returnvalue::OK; } -uint32_t PCDUHandler::getSwitchDelayMs(void) const { return 20000; } +uint32_t PcduHandler::getSwitchDelayMs(void) const { return 20000; } -object_id_t PCDUHandler::getObjectId() const { return SystemObject::getObjectId(); } +object_id_t PcduHandler::getObjectId() const { return SystemObject::getObjectId(); } -ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, +ReturnValue_t PcduHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { using namespace pcdu; localDataPoolMap.emplace(PoolIds::PDU1_SWITCHES, &pdu1Switches); @@ -435,7 +435,7 @@ ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool& localDat return returnvalue::OK; } -ReturnValue_t PCDUHandler::initializeAfterTaskCreation() { +ReturnValue_t PcduHandler::initializeAfterTaskCreation() { if (executingTask != nullptr) { pstIntervalMs = executingTask->getPeriodMs(); } @@ -446,11 +446,11 @@ ReturnValue_t PCDUHandler::initializeAfterTaskCreation() { return returnvalue::OK; } -uint32_t PCDUHandler::getPeriodicOperationFrequency() const { return pstIntervalMs; } +uint32_t PcduHandler::getPeriodicOperationFrequency() const { return pstIntervalMs; } -void PCDUHandler::setTaskIF(PeriodicTaskIF* task) { executingTask = task; } +void PcduHandler::setTaskIF(PeriodicTaskIF* task) { executingTask = task; } -LocalPoolDataSetBase* PCDUHandler::getDataSetHandle(sid_t sid) { +LocalPoolDataSetBase* PcduHandler::getDataSetHandle(sid_t sid) { if (sid == switcherSet.getSid()) { return &switcherSet; } else { @@ -459,7 +459,7 @@ LocalPoolDataSetBase* PCDUHandler::getDataSetHandle(sid_t sid) { } } -void PCDUHandler::checkAndUpdatePduSwitch(GOMSPACE::Pdu pdu, pcdu::Switches switchIdx, +void PcduHandler::checkAndUpdatePduSwitch(GOMSPACE::Pdu pdu, pcdu::Switches switchIdx, uint8_t setValue) { using namespace pcdu; if (switchStates[switchIdx] != setValue) { diff --git a/mission/devices/PcduHandler.h b/mission/devices/PcduHandler.h index dbd9b5e3..170c27f2 100644 --- a/mission/devices/PcduHandler.h +++ b/mission/devices/PcduHandler.h @@ -20,13 +20,13 @@ * This is necessary because the FSFW manages all power related functionalities via one * power object. This includes for example switching on and off of devices. */ -class PCDUHandler : public PowerSwitchIF, +class PcduHandler : public PowerSwitchIF, public HasLocalDataPoolIF, public SystemObject, public ExecutableObjectIF { public: - PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20); - virtual ~PCDUHandler(); + PcduHandler(object_id_t setObjectId, size_t cmdQueueSize = 20); + virtual ~PcduHandler(); virtual ReturnValue_t initialize() override; virtual ReturnValue_t performOperation(uint8_t counter) override; diff --git a/mission/system/objects/DualLaneAssemblyBase.cpp b/mission/system/objects/DualLaneAssemblyBase.cpp index a55553a0..ca969dbb 100644 --- a/mission/system/objects/DualLaneAssemblyBase.cpp +++ b/mission/system/objects/DualLaneAssemblyBase.cpp @@ -19,7 +19,10 @@ DualLaneAssemblyBase::DualLaneAssemblyBase(object_id_t objectId, PowerSwitchIF* void DualLaneAssemblyBase::performChildOperation() { using namespace duallane; if (pwrStateMachine.active()) { - pwrStateMachineWrapper(); + ReturnValue_t result = pwrStateMachineWrapper(); + if (result != returnvalue::OK) { + handleModeTransitionFailed(result); + } } // Only perform the regular child operation if the power state machine is not active. // It does not make any sense to command device modes while the power switcher is busy @@ -112,6 +115,7 @@ void DualLaneAssemblyBase::handleModeReached() { pwrStateMachine.start(targetMode, targetSubmode); // Now we can switch off the power. After that, the AssemblyBase::handleModeReached function // will be called + // Ignore failures for now. pwrStateMachineWrapper(); } else { finishModeOp(); From 6e049f3ee1a1ca37ca349cae32f0e763f4932b93 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 14:03:27 +0100 Subject: [PATCH 05/40] changelog update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6bbd642..c79e34d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,7 @@ will consitute of a breaking change warranting a new major release: ## Changed - Initialize switch states to a special `SWITCH_STATE_UNKNOWN` (2) variable. Return - `returnvalue::FAILED` in switch state getter. + `PowerSwitchIF::SWITCH_UNKNOWN` in switch state getter if this is the state. - Wait 1 second before commanding SAFE mode. This ensures or at least increases the chance that the switch states were initialized. - Dual Lane Assemblies: The returnvalues of the dual lane power state machine FSM are not ignored From 74fa81d8f6ec422972dc0c6efd64cd6ae9063d12 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 14:44:32 +0100 Subject: [PATCH 06/40] boot sequence --- mission/sysDefs.h | 11 ++++++ mission/system/tree/system.cpp | 70 +++++++++++++++++++++++++++++----- 2 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 mission/sysDefs.h diff --git a/mission/sysDefs.h b/mission/sysDefs.h new file mode 100644 index 00000000..1d1db0a8 --- /dev/null +++ b/mission/sysDefs.h @@ -0,0 +1,11 @@ +#ifndef MISSION_SYSDEFS_H_ +#define MISSION_SYSDEFS_H_ + +#include "acsDefs.h" +namespace satsystem { + +enum Mode : Mode_t { BOOT = 5, SAFE = acs::AcsMode::SAFE, PTG_IDLE = acs::AcsMode::PTG_IDLE }; + +} + +#endif /* MISSION_SYSDEFS_H_ */ diff --git a/mission/system/tree/system.cpp b/mission/system/tree/system.cpp index 2dd729d7..30f76609 100644 --- a/mission/system/tree/system.cpp +++ b/mission/system/tree/system.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "acsModeTree.h" #include "comModeTree.h" @@ -16,6 +17,7 @@ namespace { // Alias for checker function const auto check = subsystem::checkInsert; +void buildBootSequence(Subsystem& ss, ModeListEntry& eh); void buildSafeSequence(Subsystem& ss, ModeListEntry& eh); void buildIdleSequence(Subsystem& ss, ModeListEntry& eh); } // namespace @@ -33,29 +35,36 @@ void satsystem::init() { auto& comSubsystem = com::init(); comSubsystem.connectModeTreeParent(EIVE_SYSTEM); ModeListEntry entry; + buildBootSequence(EIVE_SYSTEM, entry); buildSafeSequence(EIVE_SYSTEM, entry); buildIdleSequence(EIVE_SYSTEM, entry); - EIVE_SYSTEM.setInitialMode(HasModesIF::MODE_OFF, 0); + EIVE_SYSTEM.setInitialMode(satsystem::Mode::BOOT, 0); } EiveSystem satsystem::EIVE_SYSTEM = EiveSystem(objects::EIVE_SYSTEM, 12, 24); -auto EIVE_SEQUENCE_SAFE = std::make_pair(acs::AcsMode::SAFE, FixedArrayList()); +auto EIVE_SEQUENCE_BOOT = std::make_pair(satsystem::Mode::BOOT, FixedArrayList()); +auto EIVE_TABLE_BOOT_TGT = + std::make_pair((satsystem::Mode::BOOT << 24) | 1, FixedArrayList()); +auto EIVE_TABLE_BOOT_TRANS_0 = + std::make_pair((satsystem::Mode::BOOT << 24) | 2, FixedArrayList()); + +auto EIVE_SEQUENCE_SAFE = std::make_pair(satsystem::Mode::SAFE, FixedArrayList()); auto EIVE_TABLE_SAFE_TGT = - std::make_pair((acs::AcsMode::SAFE << 24) | 1, FixedArrayList()); + std::make_pair((satsystem::Mode::SAFE << 24) | 1, FixedArrayList()); auto EIVE_TABLE_SAFE_TRANS_0 = - std::make_pair((acs::AcsMode::SAFE << 24) | 2, FixedArrayList()); + std::make_pair((satsystem::Mode::SAFE << 24) | 2, FixedArrayList()); auto EIVE_TABLE_SAFE_TRANS_1 = - std::make_pair((acs::AcsMode::SAFE << 24) | 3, FixedArrayList()); + std::make_pair((satsystem::Mode::SAFE << 24) | 3, FixedArrayList()); auto EIVE_SEQUENCE_IDLE = - std::make_pair(acs::AcsMode::PTG_IDLE, FixedArrayList()); + std::make_pair(satsystem::Mode::PTG_IDLE, FixedArrayList()); auto EIVE_TABLE_IDLE_TGT = - std::make_pair((acs::AcsMode::PTG_IDLE << 24) | 1, FixedArrayList()); + std::make_pair((satsystem::Mode::PTG_IDLE << 24) | 1, FixedArrayList()); auto EIVE_TABLE_IDLE_TRANS_0 = - std::make_pair((acs::AcsMode::PTG_IDLE << 24) | 2, FixedArrayList()); + std::make_pair((satsystem::Mode::PTG_IDLE << 24) | 2, FixedArrayList()); auto EIVE_TABLE_IDLE_TRANS_1 = - std::make_pair((acs::AcsMode::PTG_IDLE << 24) | 3, FixedArrayList()); + std::make_pair((satsystem::Mode::PTG_IDLE << 24) | 3, FixedArrayList()); namespace { @@ -140,4 +149,47 @@ void buildIdleSequence(Subsystem& ss, ModeListEntry& eh) { ctxc); } +void buildBootSequence(Subsystem& ss, ModeListEntry& eh) { + std::string context = "satsystem::buildBootSequence"; + auto ctxc = context.c_str(); + // Insert Helper Table + auto iht = [&](object_id_t obj, Mode_t mode, Submode_t submode, ArrayList& table, + bool allowAllSubmodes = false) { + eh.setObject(obj); + eh.setMode(mode); + eh.setSubmode(submode); + if (allowAllSubmodes) { + eh.allowAllSubmodes(); + } + check(table.insert(eh), ctxc); + }; + // Insert Helper Sequence + auto ihs = [&](ArrayList& sequence, Mode_t tableId, uint32_t waitSeconds, + bool checkSuccess) { + eh.setTableId(tableId); + eh.setWaitSeconds(waitSeconds); + eh.setCheckSuccess(checkSuccess); + check(sequence.insert(eh), ctxc); + }; + + iht(objects::ACS_SUBSYSTEM, acs::AcsMode::OFF, 0, EIVE_TABLE_BOOT_TGT.second, true); + iht(objects::PL_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TGT.second); + iht(objects::COM_SUBSYSTEM, com::RX_ONLY, 0, EIVE_TABLE_BOOT_TRANS_0.second); + iht(objects::TCS_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TRANS_0.second); + check(ss.addTable(TableEntry(EIVE_TABLE_BOOT_TGT.first, &EIVE_TABLE_BOOT_TGT.second)), ctxc); + + // Build SAFE transition 0. + iht(objects::TCS_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TRANS_0.second); + iht(objects::COM_SUBSYSTEM, com::RX_ONLY, 0, EIVE_TABLE_BOOT_TRANS_0.second); + iht(objects::PL_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TRANS_0.second); + iht(objects::ACS_SUBSYSTEM, acs::AcsMode::OFF, 0, EIVE_TABLE_BOOT_TRANS_0.second, true); + check(ss.addTable(TableEntry(EIVE_TABLE_BOOT_TRANS_0.first, &EIVE_TABLE_BOOT_TRANS_0.second)), + ctxc); + + // Build Safe sequence + ihs(EIVE_SEQUENCE_BOOT.second, EIVE_TABLE_BOOT_TGT.first, 0, false); + ihs(EIVE_SEQUENCE_BOOT.second, EIVE_TABLE_BOOT_TRANS_0.first, 0, false); + check(ss.addSequence(SequenceEntry(EIVE_SEQUENCE_BOOT.first, &EIVE_SEQUENCE_BOOT.second, + EIVE_SEQUENCE_SAFE.first)), + ctxc); } // namespace From f8c9ddbc3c27d047a3528ae50b4601ddd0aec28c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 14:48:12 +0100 Subject: [PATCH 07/40] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18709e9c..5d5d7f5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ will consitute of a breaking change warranting a new major release: - Added `EXECUTE_SHELL_CMD` action command for `CoreController` to execute arbitrary Linux commands. - Add `PcduHandlerDummy` component. - Added parameter for timeout until `MEKF_INVALID_MODE_VIOLATION` event is triggered. +- EIVE system: Add boot mode which is also the initial mode. The fallback mode of the boot mode + will be the SAFE mode. The boot mode can also be used to switch as many devices as possible OFF. ## Fixed From dcbf1502a2d972ed1558be3d4c7bd52a3da1e464 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 15:08:56 +0100 Subject: [PATCH 08/40] boot sequence EIVE sys --- bsp_q7s/obsw.cpp | 20 ++++++++++++++++++-- bsp_q7s/obsw.h | 1 + mission/system/tree/system.cpp | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index e264283f..d355a10f 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -15,6 +15,7 @@ #include "fsfw/tasks/TaskFactory.h" #include "fsfw/version.h" #include "mission/acsDefs.h" +#include "mission/comDefs.h" #include "mission/system/tree/system.h" #include "q7sConfig.h" #include "watchdog/definitions.h" @@ -116,7 +117,22 @@ void obsw::commandEiveSystemToSafe() { ReturnValue_t result = MessageQueueSenderIF::sendMessage(sysQueueId, &msg, MessageQueueIF::NO_QUEUE, false); if (result != returnvalue::OK) { - sif::error << "Sending safe mode command to EIVE system failed" << std::endl; + sif::error << "obsw: Sending safe mode command to EIVE system failed" << std::endl; + } +} + +void obsw::commandComSubsystemRxOnly() { + auto* comSs = ObjectManager::instance()->get(objects::COM_SUBSYSTEM); + if (comSs == nullptr) { + sif::error << "obsw: Could not retrieve COM subsystem object" << std::endl; + return; + } + CommandMessage msg; + ModeMessage::setCmdModeMessage(msg, com::RX_ONLY, 0); + ReturnValue_t result = MessageQueueSenderIF::sendMessage(comSs->getCommandQueue(), &msg, + MessageQueueIF::NO_QUEUE, false); + if (result != returnvalue::OK) { + sif::error << "obsw: Sending RX_ONLY mode command to COM subsystem failed" << std::endl; } } @@ -127,6 +143,6 @@ void obsw::announceAllModes() { ReturnValue_t result = MessageQueueSenderIF::sendMessage(sysQueueId, &msg, MessageQueueIF::NO_QUEUE, false); if (result != returnvalue::OK) { - sif::error << "Sending safe mode command to EIVE system failed" << std::endl; + sif::error << "obsw: Sending safe mode command to EIVE system failed" << std::endl; } } diff --git a/bsp_q7s/obsw.h b/bsp_q7s/obsw.h index 1a6e4e05..8260a605 100644 --- a/bsp_q7s/obsw.h +++ b/bsp_q7s/obsw.h @@ -7,6 +7,7 @@ int obsw(int argc, char* argv[]); void bootDelayHandling(); void commandEiveSystemToSafe(); +void commandComSubsystemRxOnly(); void announceAllModes(); }; // namespace obsw diff --git a/mission/system/tree/system.cpp b/mission/system/tree/system.cpp index 30f76609..a242e8cd 100644 --- a/mission/system/tree/system.cpp +++ b/mission/system/tree/system.cpp @@ -98,7 +98,6 @@ void buildSafeSequence(Subsystem& ss, ModeListEntry& eh) { // Build SAFE transition 0. iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_SAFE_TRANS_0.second); - iht(objects::COM_SUBSYSTEM, com::RX_ONLY, 0, EIVE_TABLE_SAFE_TRANS_0.second); iht(objects::PL_SUBSYSTEM, OFF, 0, EIVE_TABLE_SAFE_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::SAFE, 0, EIVE_TABLE_SAFE_TRANS_0.second, true); check(ss.addTable(TableEntry(EIVE_TABLE_SAFE_TRANS_0.first, &EIVE_TABLE_SAFE_TRANS_0.second)), @@ -192,4 +191,5 @@ void buildBootSequence(Subsystem& ss, ModeListEntry& eh) { check(ss.addSequence(SequenceEntry(EIVE_SEQUENCE_BOOT.first, &EIVE_SEQUENCE_BOOT.second, EIVE_SEQUENCE_SAFE.first)), ctxc); +} } // namespace From 9c300298b7bedee69724680204eacc7edca7e491 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 15:26:39 +0100 Subject: [PATCH 09/40] missing code --- bsp_q7s/obsw.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index d355a10f..b32d808f 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -67,6 +67,7 @@ int obsw::obsw(int argc, char* argv[]) { // Command the EIVE system to safe mode #if OBSW_COMMAND_SAFE_MODE_AT_STARTUP == 1 + commandComSubsystemRxOnly(); commandEiveSystemToSafe(); #else announceAllModes(); From d32209657301043c3b5ac84d78e80087fd37f62c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 18:41:11 +0100 Subject: [PATCH 10/40] changelog --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a2b4abe..b5ffe739 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,6 @@ will consitute of a breaking change warranting a new major release: - Added parameter for timeout until `MEKF_INVALID_MODE_VIOLATION` event is triggered. - EIVE system: Add boot mode which is also the initial mode. The fallback mode of the boot mode will be the SAFE mode. The boot mode can also be used to switch as many devices as possible OFF. - ## Fixed - Pointing control of the `AcsController` was still expecting submodes instead of modes. @@ -44,6 +43,11 @@ will consitute of a breaking change warranting a new major release: - Set `OBSW_ADD_TCS_CTRL` to 1. Always add TCS controller now for both EM and FM. - generators module: Bump `fsfwgen` dependency to v0.3.1. The returnvalue CSV files are now sorted. - generators module: Always generate subsystem ID CSV files now. +- The COM subsystem is now not commanded by the EIVE system anymore. Instead, + a separate RX_ONLY mode command will be sent at OBSW boot. After that, + commanding is done autonomously by the COM subsystem internally or by the operator. This prevents + the transmitter from going off during fallbacks to the SAFE mode, which might not always be + desired. # [v1.37.0] 2023-03-11 From ccf1fcaa7910126165564a1df57dd5e3fc4c811a Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 15 Mar 2023 10:06:24 +0100 Subject: [PATCH 11/40] stuff --- mission/controller/AcsController.cpp | 12 +++++++----- mission/controller/AcsController.h | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 8e7b1b9a..220ba178 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -173,14 +173,16 @@ void AcsController::performSafe() { sunTargetDir, satRateSafe, &errAng, magMomMtq); } if (result == returnvalue::FAILED) { - if (not doomFlag) { + if (not safeCtrlFailureFlag) { triggerEvent(acs::SAFE_MODE_CONTROLLER_FAILURE); - doomFlag = true; + safeCtrlFailureFlag = true; } - doomCounter++; - if (doomCounter > 5) { - doomFlag = false; + safeCtrlFailureCounter++; + if (safeCtrlFailureCounter > 50) { + safeCtrlFailureFlag = false; } + } else { + safeCtrlFailureFlag = false; } actuatorCmd.cmdDipolMtq(magMomMtq, cmdDipolMtqs, diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index 2b0cda17..3c309bd4 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -62,8 +62,8 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes uint8_t multipleRwUnavailableCounter = 0; bool mekfInvalidFlag = false; uint16_t mekfInvalidCounter = 0; - bool doomFlag = false; - uint8_t doomCounter = 0; + bool safeCtrlFailureFlag = false; + uint8_t safeCtrlFailureCounter = 0; int32_t cmdSpeedRws[4] = {0, 0, 0, 0}; int16_t cmdDipolMtqs[3] = {0, 0, 0}; From c4fe772fe7e76a2d07c6af8d7de2d794682a78ec Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 15 Mar 2023 10:08:58 +0100 Subject: [PATCH 12/40] changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c1891d6..dfa43418 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,12 @@ will consitute of a breaking change warranting a new major release: # [unreleased] +## Added + +- Failure of Safe Mode Ctrl will now trigger an event. As this can only be caused by sensors not + being in the correct mode, the assemblies should take care that this will never happen and no + additional FDIR is needed. + # [v1.37.2] 2023-03-14 - Changed `PoolManager` bugfix implementation in the FSFW. From 102228100e61f3f0808e3af56ee84a8dd19ed3d3 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 15 Mar 2023 10:10:47 +0100 Subject: [PATCH 13/40] reran event gens --- bsp_hosted/fsfwconfig/events/translateEvents.cpp | 7 +++++-- generators/bsp_hosted_events.csv | 1 + generators/bsp_q7s_events.csv | 1 + generators/events/translateEvents.cpp | 7 +++++-- linux/fsfwconfig/events/translateEvents.cpp | 7 +++++-- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index e0f9c58f..32b61bca 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 277 translations. + * @brief Auto-generated event translation file. Contains 278 translations. * @details - * Generated on: 2023-03-14 17:08:41 + * Generated on: 2023-03-15 10:10:04 */ #include "translateEvents.h" @@ -97,6 +97,7 @@ const char *SAFE_RATE_RECOVERY_STRING = "SAFE_RATE_RECOVERY"; const char *MULTIPLE_RW_INVALID_STRING = "MULTIPLE_RW_INVALID"; const char *MEKF_INVALID_INFO_STRING = "MEKF_INVALID_INFO"; const char *MEKF_INVALID_MODE_VIOLATION_STRING = "MEKF_INVALID_MODE_VIOLATION"; +const char *SAFE_MODE_CONTROLLER_FAILURE_STRING = "SAFE_MODE_CONTROLLER_FAILURE"; const char *SWITCH_CMD_SENT_STRING = "SWITCH_CMD_SENT"; const char *SWITCH_HAS_CHANGED_STRING = "SWITCH_HAS_CHANGED"; const char *SWITCHING_Q7S_DENIED_STRING = "SWITCHING_Q7S_DENIED"; @@ -464,6 +465,8 @@ const char *translateEvents(Event event) { return MEKF_INVALID_INFO_STRING; case (11204): return MEKF_INVALID_MODE_VIOLATION_STRING; + case (11205): + return SAFE_MODE_CONTROLLER_FAILURE_STRING; case (11300): return SWITCH_CMD_SENT_STRING; case (11301): diff --git a/generators/bsp_hosted_events.csv b/generators/bsp_hosted_events.csv index ec5050cc..2f10693c 100644 --- a/generators/bsp_hosted_events.csv +++ b/generators/bsp_hosted_events.csv @@ -91,6 +91,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 11202;0x2bc2;MULTIPLE_RW_INVALID;HIGH;No description;mission/acsDefs.h 11203;0x2bc3;MEKF_INVALID_INFO;INFO;No description;mission/acsDefs.h 11204;0x2bc4;MEKF_INVALID_MODE_VIOLATION;HIGH;No description;mission/acsDefs.h +11205;0x2bc5;SAFE_MODE_CONTROLLER_FAILURE;HIGH;No description;mission/acsDefs.h 11300;0x2c24;SWITCH_CMD_SENT;INFO;Indicates that a FSFW object requested setting a switch P1: 1 if on was requested, 0 for off | P2: Switch Index;mission/devices/devicedefinitions/powerDefinitions.h 11301;0x2c25;SWITCH_HAS_CHANGED;INFO;Indicated that a switch state has changed P1: New switch state, 1 for on, 0 for off | P2: Switch Index;mission/devices/devicedefinitions/powerDefinitions.h 11302;0x2c26;SWITCHING_Q7S_DENIED;MEDIUM;No description;mission/devices/devicedefinitions/powerDefinitions.h diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index ec5050cc..2f10693c 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -91,6 +91,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 11202;0x2bc2;MULTIPLE_RW_INVALID;HIGH;No description;mission/acsDefs.h 11203;0x2bc3;MEKF_INVALID_INFO;INFO;No description;mission/acsDefs.h 11204;0x2bc4;MEKF_INVALID_MODE_VIOLATION;HIGH;No description;mission/acsDefs.h +11205;0x2bc5;SAFE_MODE_CONTROLLER_FAILURE;HIGH;No description;mission/acsDefs.h 11300;0x2c24;SWITCH_CMD_SENT;INFO;Indicates that a FSFW object requested setting a switch P1: 1 if on was requested, 0 for off | P2: Switch Index;mission/devices/devicedefinitions/powerDefinitions.h 11301;0x2c25;SWITCH_HAS_CHANGED;INFO;Indicated that a switch state has changed P1: New switch state, 1 for on, 0 for off | P2: Switch Index;mission/devices/devicedefinitions/powerDefinitions.h 11302;0x2c26;SWITCHING_Q7S_DENIED;MEDIUM;No description;mission/devices/devicedefinitions/powerDefinitions.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index e0f9c58f..32b61bca 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 277 translations. + * @brief Auto-generated event translation file. Contains 278 translations. * @details - * Generated on: 2023-03-14 17:08:41 + * Generated on: 2023-03-15 10:10:04 */ #include "translateEvents.h" @@ -97,6 +97,7 @@ const char *SAFE_RATE_RECOVERY_STRING = "SAFE_RATE_RECOVERY"; const char *MULTIPLE_RW_INVALID_STRING = "MULTIPLE_RW_INVALID"; const char *MEKF_INVALID_INFO_STRING = "MEKF_INVALID_INFO"; const char *MEKF_INVALID_MODE_VIOLATION_STRING = "MEKF_INVALID_MODE_VIOLATION"; +const char *SAFE_MODE_CONTROLLER_FAILURE_STRING = "SAFE_MODE_CONTROLLER_FAILURE"; const char *SWITCH_CMD_SENT_STRING = "SWITCH_CMD_SENT"; const char *SWITCH_HAS_CHANGED_STRING = "SWITCH_HAS_CHANGED"; const char *SWITCHING_Q7S_DENIED_STRING = "SWITCHING_Q7S_DENIED"; @@ -464,6 +465,8 @@ const char *translateEvents(Event event) { return MEKF_INVALID_INFO_STRING; case (11204): return MEKF_INVALID_MODE_VIOLATION_STRING; + case (11205): + return SAFE_MODE_CONTROLLER_FAILURE_STRING; case (11300): return SWITCH_CMD_SENT_STRING; case (11301): diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index e0f9c58f..32b61bca 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 277 translations. + * @brief Auto-generated event translation file. Contains 278 translations. * @details - * Generated on: 2023-03-14 17:08:41 + * Generated on: 2023-03-15 10:10:04 */ #include "translateEvents.h" @@ -97,6 +97,7 @@ const char *SAFE_RATE_RECOVERY_STRING = "SAFE_RATE_RECOVERY"; const char *MULTIPLE_RW_INVALID_STRING = "MULTIPLE_RW_INVALID"; const char *MEKF_INVALID_INFO_STRING = "MEKF_INVALID_INFO"; const char *MEKF_INVALID_MODE_VIOLATION_STRING = "MEKF_INVALID_MODE_VIOLATION"; +const char *SAFE_MODE_CONTROLLER_FAILURE_STRING = "SAFE_MODE_CONTROLLER_FAILURE"; const char *SWITCH_CMD_SENT_STRING = "SWITCH_CMD_SENT"; const char *SWITCH_HAS_CHANGED_STRING = "SWITCH_HAS_CHANGED"; const char *SWITCHING_Q7S_DENIED_STRING = "SWITCHING_Q7S_DENIED"; @@ -464,6 +465,8 @@ const char *translateEvents(Event event) { return MEKF_INVALID_INFO_STRING; case (11204): return MEKF_INVALID_MODE_VIOLATION_STRING; + case (11205): + return SAFE_MODE_CONTROLLER_FAILURE_STRING; case (11300): return SWITCH_CMD_SENT_STRING; case (11301): From 95a4d88ed465489ca9b9a26e5570134d2c50e19f Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 15 Mar 2023 10:17:24 +0100 Subject: [PATCH 14/40] cleanup --- .../acs/MultiplicativeKalmanFilter.cpp | 7 ------- .../acs/MultiplicativeKalmanFilter.h | 6 ++---- mission/controller/acs/util/MathOperations.h | 20 ------------------- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/mission/controller/acs/MultiplicativeKalmanFilter.cpp b/mission/controller/acs/MultiplicativeKalmanFilter.cpp index e752da39..77a3ef00 100644 --- a/mission/controller/acs/MultiplicativeKalmanFilter.cpp +++ b/mission/controller/acs/MultiplicativeKalmanFilter.cpp @@ -1080,12 +1080,6 @@ ReturnValue_t MultiplicativeKalmanFilter::mekfEst( MatrixOperations::add(*cov0, *cov1, *initialCovarianceMatrix, 6, 6); - if (not(MathOperations::checkVectorIsFinite(propagatedQuaternion, 4)) || - not(MathOperations::checkMatrixIsFinite(initialQuaternion, 6, 6))) { - updateDataSetWithoutData(mekfData, MekfStatus::NOT_FINITE); - return MEKF_NOT_FINITE; - } - updateDataSet(mekfData, MekfStatus::RUNNING, quatBJ, rotRateEst); return MEKF_RUNNING; } @@ -1095,7 +1089,6 @@ ReturnValue_t MultiplicativeKalmanFilter::reset(acsctrl::MekfData *mekfData) { double resetCovarianceMatrix[6][6] = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}}; std::memcpy(initialQuaternion, resetQuaternion, 4 * sizeof(double)); - std::memcpy(propagatedQuaternion, resetQuaternion, 4 * sizeof(double)); std::memcpy(initialCovarianceMatrix, resetCovarianceMatrix, 6 * 6 * sizeof(double)); updateDataSetWithoutData(mekfData, MekfStatus::UNINITIALIZED); return MEKF_UNINITIALIZED; diff --git a/mission/controller/acs/MultiplicativeKalmanFilter.h b/mission/controller/acs/MultiplicativeKalmanFilter.h index fe749890..ceb98339 100644 --- a/mission/controller/acs/MultiplicativeKalmanFilter.h +++ b/mission/controller/acs/MultiplicativeKalmanFilter.h @@ -62,7 +62,6 @@ class MultiplicativeKalmanFilter { NO_MODEL_VECTORS = 2, NO_SUS_MGM_STR_DATA = 3, COVARIANCE_INVERSION_FAILED = 4, - NOT_FINITE = 5, INITIALIZED = 10, RUNNING = 11, }; @@ -75,9 +74,8 @@ class MultiplicativeKalmanFilter { static constexpr ReturnValue_t MEKF_NO_SUS_MGM_STR_DATA = returnvalue::makeCode(IF_MEKF_ID, 5); static constexpr ReturnValue_t MEKF_COVARIANCE_INVERSION_FAILED = returnvalue::makeCode(IF_MEKF_ID, 6); - static constexpr ReturnValue_t MEKF_NOT_FINITE = returnvalue::makeCode(IF_MEKF_ID, 7); - static constexpr ReturnValue_t MEKF_INITIALIZED = returnvalue::makeCode(IF_MEKF_ID, 8); - static constexpr ReturnValue_t MEKF_RUNNING = returnvalue::makeCode(IF_MEKF_ID, 9); + static constexpr ReturnValue_t MEKF_INITIALIZED = returnvalue::makeCode(IF_MEKF_ID, 7); + static constexpr ReturnValue_t MEKF_RUNNING = returnvalue::makeCode(IF_MEKF_ID, 8); private: /*Parameters*/ diff --git a/mission/controller/acs/util/MathOperations.h b/mission/controller/acs/util/MathOperations.h index b344451a..f8537740 100644 --- a/mission/controller/acs/util/MathOperations.h +++ b/mission/controller/acs/util/MathOperations.h @@ -404,26 +404,6 @@ class MathOperations { std::memcpy(inverse, identity, sizeof(identity)); return 0; // successful inversion } - - static bool checkVectorIsFinite(const T1 *inputVector, uint8_t size) { - for (uint8_t i = 0; i < size; i++) { - if (not isfinite(inputVector[i])) { - return false; - } - } - return true; - } - - static bool checkMatrixIsFinite(const T1 *inputMatrix, uint8_t rows, uint8_t cols) { - for (uint8_t col = 0; col < cols; col++) { - for (uint8_t row = 0; row < rows; row++) { - if (not isfinite(inputMatrix[row * cols + cols])) { - return false; - } - } - } - return true; - } }; #endif /* ACS_MATH_MATHOPERATIONS_H_ */ From be848ea5e4392e86ce0b9fb43104d15348defeb1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 11:32:58 +0100 Subject: [PATCH 15/40] changelog update --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b2a096f..66bb6c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ will consitute of a breaking change warranting a new major release: ## Changed - Telemetry relevant datasets for the RWs are now set invalid and partially reset on shotdown. +- I2C PST now has a polling frequency of 0.4 seconds instead of 0.2 seconds. +- GS PST now has a polling frequency of 0.5 seconds instead of 1 second. # [v1.37.2] 2023-03-14 @@ -57,8 +59,6 @@ eive-tmtc: v2.19.1 ## Changed - Set `OBSW_ADD_TCS_CTRL` to 1. Always add TCS controller now for both EM and FM. -- I2C PST now has a polling frequency of 0.4 seconds instead of 0.2 seconds. -- GS PST now has a polling frequency of 0.5 seconds instead of 1 second. - generators module: Bump `fsfwgen` dependency to v0.3.1. The returnvalue CSV files are now sorted. - generators module: Always generate subsystem ID CSV files now. From 7c54e920ef5305016505a2c67830f23869fa2c22 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 11:42:03 +0100 Subject: [PATCH 16/40] bump fsfw --- CHANGELOG.md | 1 + fsfw | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bc96840..0e0a74b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ will consitute of a breaking change warranting a new major release: ## Changed - Telemetry relevant datasets for the RWs are now set invalid and partially reset on shotdown. +- Bump FSFW: merged upstream. # [v1.37.2] 2023-03-14 diff --git a/fsfw b/fsfw index cf27954a..d0607824 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit cf27954a867a1c16b4e5b0fe72cd79df946ff903 +Subproject commit d0607824ad551771e4e3ec1f1752f5f2f6a1a7a8 From 7ab01687ce38db63ea8327fb2e6dd011e202ea0d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 11:49:01 +0100 Subject: [PATCH 17/40] some user code fixes --- fsfw | 2 +- mission/core/GenericFactory.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fsfw b/fsfw index d0607824..43fd0b2f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d0607824ad551771e4e3ec1f1752f5f2f6a1a7a8 +Subproject commit 43fd0b2f59c3aeb2d3f4db10cfad56ee3709d68d diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 8bf4eff6..53ca6904 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -112,8 +112,8 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun } { - PoolManager::LocalPoolConfig poolCfg = {{600, 32}, {400, 64}, {400, 128}, {300, 512}, - {250, 1024}, {150, 2048}}; + PoolManager::LocalPoolConfig poolCfg = {{600, 32}, {400, 64}, {400, 128}, + {300, 512}, {250, 1024}, {150, 2048}}; *tmStore = new PoolManager(objects::TM_STORE, poolCfg); } @@ -254,8 +254,8 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun pus::PUS_SERVICE_20); new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, config::EIVE_PUS_APID, pus::PUS_SERVICE_200, 8); - HealthServiceCfg healthCfg(objects::PUS_SERVICE_201_HEALTH, config::EIVE_PUS_APID, *healthTable, - 20); + HealthServiceCfg healthCfg(objects::PUS_SERVICE_201_HEALTH, config::EIVE_PUS_APID, + objects::HEALTH_TABLE, 20); new CServiceHealthCommanding(healthCfg); #if OBSW_ADD_CFDP_COMPONENTS == 1 From 2f263c6aa6c270c37fe36187ef999c4f82ffa7f2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 16:21:05 +0100 Subject: [PATCH 18/40] small bugfix --- mission/system/tree/system.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/system/tree/system.cpp b/mission/system/tree/system.cpp index a242e8cd..b5743f57 100644 --- a/mission/system/tree/system.cpp +++ b/mission/system/tree/system.cpp @@ -173,8 +173,8 @@ void buildBootSequence(Subsystem& ss, ModeListEntry& eh) { iht(objects::ACS_SUBSYSTEM, acs::AcsMode::OFF, 0, EIVE_TABLE_BOOT_TGT.second, true); iht(objects::PL_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TGT.second); - iht(objects::COM_SUBSYSTEM, com::RX_ONLY, 0, EIVE_TABLE_BOOT_TRANS_0.second); - iht(objects::TCS_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TRANS_0.second); + iht(objects::COM_SUBSYSTEM, com::RX_ONLY, 0, EIVE_TABLE_BOOT_TGT.second); + iht(objects::TCS_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TGT.second); check(ss.addTable(TableEntry(EIVE_TABLE_BOOT_TGT.first, &EIVE_TABLE_BOOT_TGT.second)), ctxc); // Build SAFE transition 0. From 6da3d6f06a1a9614720361274d3567007475af09 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Mar 2023 17:45:24 +0100 Subject: [PATCH 19/40] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index a9338149..350e5d77 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit a93381494ac8f908a327f4c9bf4622399d5754a3 +Subproject commit 350e5d77b8113cc9e21eb72242fc37536368f541 From 509d144117baa902777d373e2e892cbc0a1d81fe Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Mar 2023 11:09:29 +0100 Subject: [PATCH 20/40] SA DEPLY updates --- .../devices/SolarArrayDeploymentHandler.cpp | 19 +++++++++++++------ tmtc | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index e4356630..aa471a1c 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -157,10 +157,14 @@ ReturnValue_t SolarArrayDeploymentHandler::performAutonomousDepl(sd::SdCard sdCa return returnvalue::OK; } -bool SolarArrayDeploymentHandler::autonomousDeplForFile(sd::SdCard sdCard, const char* filename, +bool SolarArrayDeploymentHandler::autonomousDeplForFile(sd::SdCard sdCard, const char* infoFile, bool dryRun) { using namespace std; - ifstream file(filename); + std::error_code e; + ifstream file(infoFile); + if (file.bad()) { + return false; + } string line; string word; unsigned int lineNum = 0; @@ -240,15 +244,18 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(sd::SdCard sdCard, const } } if (deplState == AutonomousDeplState::DONE) { - remove(filename); + std::filesystem::remove(infoFile, e); if (sdCard == sd::SdCard::SLOT_0) { - remove(SD_0_DEPL_FILE); + std::filesystem::remove(SD_0_DEPL_FILE, e); } else { - remove(SD_1_DEPL_FILE); + std::filesystem::remove(SD_1_DEPL_FILE, e); } triggerEvent(AUTONOMOUS_DEPLOYMENT_COMPLETED); } else { - std::ofstream of(filename); + std::ofstream of(infoFile); + if (of.bad()) { + return false; + } of << "phase: "; if (deplState == AutonomousDeplState::INIT) { of << PHASE_INIT_STR << "\n"; diff --git a/tmtc b/tmtc index 4f48c25b..350e5d77 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 4f48c25bf757b6c056072049fe5965da890b4f5b +Subproject commit 350e5d77b8113cc9e21eb72242fc37536368f541 From af85c883faaa7dfb1394d00962685333ddecee18 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Mar 2023 16:04:35 +0100 Subject: [PATCH 21/40] bugfix in SD card manager --- bsp_q7s/fs/SdCardManager.cpp | 1 - tmtc | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/bsp_q7s/fs/SdCardManager.cpp b/bsp_q7s/fs/SdCardManager.cpp index e954e7bb..29225899 100644 --- a/bsp_q7s/fs/SdCardManager.cpp +++ b/bsp_q7s/fs/SdCardManager.cpp @@ -37,7 +37,6 @@ SdCardManager::SdCardManager() : SystemObject(objects::SDC_MANAGER), cmdExecutor sif::warning << "CoreController::sdCardInit: " "Preferred SD card not set. Setting to 0" << std::endl; - setPreferredSdCard(sd::SdCard::SLOT_0); scratch::writeNumber(scratch::PREFERED_SDC_KEY, static_cast(sd::SdCard::SLOT_0)); prefSdRaw = sd::SdCard::SLOT_0; diff --git a/tmtc b/tmtc index 4f48c25b..350e5d77 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 4f48c25bf757b6c056072049fe5965da890b4f5b +Subproject commit 350e5d77b8113cc9e21eb72242fc37536368f541 From 5b84808d7cea0849927c6f746470c366455bec07 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Mar 2023 16:16:53 +0100 Subject: [PATCH 22/40] reset the counter --- mission/controller/AcsController.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 220ba178..e3a5ed5e 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -180,9 +180,11 @@ void AcsController::performSafe() { safeCtrlFailureCounter++; if (safeCtrlFailureCounter > 50) { safeCtrlFailureFlag = false; + safeCtrlFailureCounter = 0; } } else { safeCtrlFailureFlag = false; + safeCtrlFailureCounter = 0; } actuatorCmd.cmdDipolMtq(magMomMtq, cmdDipolMtqs, From 9a5901235ca1d6e96ae7e2d9a68a0815269fd04a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Mar 2023 16:19:04 +0100 Subject: [PATCH 23/40] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 061ceca9..743c0aef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ will consitute of a breaking change warranting a new major release: # [unreleased] +## Fixed + +- SA deployment file handling: Use exceptionless API. +- Fix deadlock in SD card manager constructor: Double lock of preferred SD card lock. + ## Added - Failure of Safe Mode Ctrl will now trigger an event. As this can only be caused by sensors not From 9cec20a550de5070564d10aac52aa259e0707bd8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Mar 2023 16:27:00 +0100 Subject: [PATCH 24/40] scheduling tweaks for i2c --- CHANGELOG.md | 1 + bsp_q7s/core/scheduling.cpp | 2 +- mission/core/pollingSeqTables.cpp | 42 +++++++++++++++---------------- mission/core/pollingSeqTables.h | 2 +- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 743c0aef..54689aab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ will consitute of a breaking change warranting a new major release: - I2C PST now has a polling frequency of 0.4 seconds instead of 0.2 seconds. - GS PST now has a polling frequency of 0.5 seconds instead of 1 second. - Bump FSFW: merged upstream. +- Move BPX battery scheduling to ACS PST to avoid clashes with IMTQ scheduling / polling # [v1.37.2] 2023-03-14 diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index d7094806..bd9ee01c 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -487,7 +487,7 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction #if OBSW_ADD_I2C_TEST_CODE == 0 FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask( "I2C_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.4, missedDeadlineFunc); - result = pst::pstI2c(i2cPst); + result = pst::pstI2cProcessingSystem(i2cPst); if (result != returnvalue::OK) { if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { sif::warning << "scheduling::initTasks: I2C PST is empty" << std::endl; diff --git a/mission/core/pollingSeqTables.cpp b/mission/core/pollingSeqTables.cpp index 3b18a0e6..e69262bc 100644 --- a/mission/core/pollingSeqTables.cpp +++ b/mission/core/pollingSeqTables.cpp @@ -36,31 +36,25 @@ ReturnValue_t pst::pstSyrlinks(FixedTimeslotTaskIF *thisSequence) { // I don't think this needs to be in a PST because linux takes care of bus serialization, but // keep it like this for now, it works -ReturnValue_t pst::pstI2c(FixedTimeslotTaskIF *thisSequence) { +ReturnValue_t pst::pstI2cProcessingSystem(FixedTimeslotTaskIF *thisSequence) { // Length of a communication cycle uint32_t length = thisSequence->getPeriodMs(); static_cast(length); - thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * 0.2, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * 0.2, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * 0.3, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * 0.3, DeviceHandlerIF::GET_READ); // These are actually part of another bus, but this works, so keep it like this for now - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.4, + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.2, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.4, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.45, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.45, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.2, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.3, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.3, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.5, + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.4, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.5, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.55, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.55, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.5, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.5, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.6, DeviceHandlerIF::PERFORM_OPERATION); @@ -68,9 +62,9 @@ ReturnValue_t pst::pstI2c(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.65, + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.65, + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.7, DeviceHandlerIF::GET_READ); // damaged /* @@ -90,9 +84,9 @@ ReturnValue_t pst::pstI2c(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.8, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.85, + thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.9, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.85, + thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.9, DeviceHandlerIF::GET_READ); static_cast(length); return thisSequence->checkSequence(); @@ -562,6 +556,12 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::PLPCDU_HANDLER, length * config::spiSched::SCHED_BLOCK_8_PERIOD, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_8_PERIOD, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_8_PERIOD, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_8_PERIOD, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_9_PERIOD, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_9_PERIOD, DeviceHandlerIF::GET_READ); #if OBSW_ADD_RAD_SENSORS == 1 /* Radiation sensor */ diff --git a/mission/core/pollingSeqTables.h b/mission/core/pollingSeqTables.h index 75e18665..e3bc0ad0 100644 --- a/mission/core/pollingSeqTables.h +++ b/mission/core/pollingSeqTables.h @@ -51,7 +51,7 @@ ReturnValue_t pstSyrlinks(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pstTcsAndAcs(FixedTimeslotTaskIF* thisSequence, AcsPstCfg cfg); -ReturnValue_t pstI2c(FixedTimeslotTaskIF* thisSequence); +ReturnValue_t pstI2cProcessingSystem(FixedTimeslotTaskIF* thisSequence); /** * Generic test PST From 97a947f5aa4c54f5a4434ff8dbe582ca29c3dbc4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Mar 2023 17:16:32 +0100 Subject: [PATCH 25/40] 2 seconds are important --- mission/devices/SolarArrayDeploymentHandler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index aa471a1c..81807351 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -215,14 +215,14 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(sd::SdCard sdCard, const stateSwitch = true; } }; - if ((secsSinceBoot > FIRST_BURN_START_TIME) and (secsSinceBoot < FIRST_BURN_END_TIME)) { + if ((secsSinceBoot >= FIRST_BURN_START_TIME) and (secsSinceBoot < FIRST_BURN_END_TIME)) { switchCheck(AutonomousDeplState::FIRST_BURN); - } else if ((secsSinceBoot > WAIT_START_TIME) and (secsSinceBoot < WAIT_END_TIME)) { + } else if ((secsSinceBoot >= WAIT_START_TIME) and (secsSinceBoot < WAIT_END_TIME)) { switchCheck(AutonomousDeplState::WAIT); - } else if ((secsSinceBoot > SECOND_BURN_START_TIME) and + } else if ((secsSinceBoot >= SECOND_BURN_START_TIME) and (secsSinceBoot < SECOND_BURN_END_TIME)) { switchCheck(AutonomousDeplState::SECOND_BURN); - } else if (secsSinceBoot > SECOND_BURN_END_TIME) { + } else if (secsSinceBoot >= SECOND_BURN_END_TIME) { switchCheck(AutonomousDeplState::DONE); } } From 0e8859c278b0f9e09d440af904c328f53a20543f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Mar 2023 18:08:08 +0100 Subject: [PATCH 26/40] prep v1.38.0 --- CHANGELOG.md | 4 ++++ CMakeLists.txt | 4 ++-- tmtc | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2fdd3ec..2f68f5ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ will consitute of a breaking change warranting a new major release: # [unreleased] +# [v1.38.0] 2023-03-17 + +eive-tmtc: v2.19.2 + ## Fixed - SA deployment file handling: Use exceptionless API. diff --git a/CMakeLists.txt b/CMakeLists.txt index 9844510b..9b1441b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ cmake_minimum_required(VERSION 3.13) set(OBSW_VERSION_MAJOR 1) -set(OBSW_VERSION_MINOR 37) -set(OBSW_VERSION_REVISION 2) +set(OBSW_VERSION_MINOR 38) +set(OBSW_VERSION_REVISION 0) # set(CMAKE_VERBOSE TRUE) diff --git a/tmtc b/tmtc index 350e5d77..e5a09e14 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 350e5d77b8113cc9e21eb72242fc37536368f541 +Subproject commit e5a09e148b45d0380dc6d9a1a88002bab4b0376c From ba1cc420c499a373b0ea4591f760dce72df81480 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Mar 2023 18:20:41 +0100 Subject: [PATCH 27/40] afmt --- mission/core/pollingSeqTables.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mission/core/pollingSeqTables.cpp b/mission/core/pollingSeqTables.cpp index e69262bc..cb46bc24 100644 --- a/mission/core/pollingSeqTables.cpp +++ b/mission/core/pollingSeqTables.cpp @@ -64,8 +64,7 @@ ReturnValue_t pst::pstI2cProcessingSystem(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.7, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.7, DeviceHandlerIF::GET_READ); // damaged /* thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, @@ -86,8 +85,7 @@ ReturnValue_t pst::pstI2cProcessingSystem(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.9, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.9, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.9, DeviceHandlerIF::GET_READ); static_cast(length); return thisSequence->checkSequence(); } @@ -558,10 +556,14 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_8_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_8_PERIOD, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_8_PERIOD, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_9_PERIOD, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_9_PERIOD, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_8_PERIOD, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_8_PERIOD, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_9_PERIOD, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_9_PERIOD, + DeviceHandlerIF::GET_READ); #if OBSW_ADD_RAD_SENSORS == 1 /* Radiation sensor */ From 5890e639feb5dbe22bd6dab9d9ba977be9dcc009 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Mar 2023 10:17:41 +0100 Subject: [PATCH 28/40] bugfix for dual to single side transition --- mission/system/objects/DualLaneAssemblyBase.cpp | 12 ++++++++++-- mission/system/objects/DualLaneAssemblyBase.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mission/system/objects/DualLaneAssemblyBase.cpp b/mission/system/objects/DualLaneAssemblyBase.cpp index ca969dbb..582ba886 100644 --- a/mission/system/objects/DualLaneAssemblyBase.cpp +++ b/mission/system/objects/DualLaneAssemblyBase.cpp @@ -34,10 +34,17 @@ void DualLaneAssemblyBase::performChildOperation() { } void DualLaneAssemblyBase::startTransition(Mode_t mode, Submode_t submode) { - // doStartTransition(mode, submode); using namespace duallane; pwrStateMachine.reset(); if (mode != MODE_OFF) { + // Special exception: A transition from dual side to single mode must be handled like + // going OFF. + if ((this->mode == MODE_ON or this->mode == DeviceHandlerIF::MODE_NORMAL) and + this->submode == DUAL_MODE and submode != DUAL_MODE) { + dualToSingleSideTransition = true; + AssemblyBase::startTransition(mode, submode); + return; + } // If anything other than MODE_OFF is commanded, perform power state machine first // Cache the target modes, required by power state machine pwrStateMachine.start(mode, submode); @@ -111,7 +118,7 @@ ReturnValue_t DualLaneAssemblyBase::isModeCombinationValid(Mode_t mode, Submode_ void DualLaneAssemblyBase::handleModeReached() { using namespace duallane; - if (targetMode == MODE_OFF) { + if (targetMode == MODE_OFF or dualToSingleSideTransition) { pwrStateMachine.start(targetMode, targetSubmode); // Now we can switch off the power. After that, the AssemblyBase::handleModeReached function // will be called @@ -229,6 +236,7 @@ void DualLaneAssemblyBase::finishModeOp() { pwrStateMachine.reset(); powerRetryCounter = 0; tryingOtherSide = false; + dualToSingleSideTransition = false; dualModeErrorSwitch = true; } diff --git a/mission/system/objects/DualLaneAssemblyBase.h b/mission/system/objects/DualLaneAssemblyBase.h index a8a2f521..929ef3f9 100644 --- a/mission/system/objects/DualLaneAssemblyBase.h +++ b/mission/system/objects/DualLaneAssemblyBase.h @@ -31,6 +31,7 @@ class DualLaneAssemblyBase : public AssemblyBase, public ConfirmsFailuresIF { uint8_t powerRetryCounter = 0; bool tryingOtherSide = false; bool dualModeErrorSwitch = true; + bool dualToSingleSideTransition = false; duallane::Submodes defaultSubmode = duallane::Submodes::A_SIDE; enum RecoveryCustomStates { From 74bb27e61f87d70a5a3245276312c6fccead4cf5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Mar 2023 11:12:19 +0100 Subject: [PATCH 29/40] some more fixes --- .../system/objects/DualLaneAssemblyBase.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/mission/system/objects/DualLaneAssemblyBase.cpp b/mission/system/objects/DualLaneAssemblyBase.cpp index 582ba886..22728457 100644 --- a/mission/system/objects/DualLaneAssemblyBase.cpp +++ b/mission/system/objects/DualLaneAssemblyBase.cpp @@ -82,9 +82,13 @@ ReturnValue_t DualLaneAssemblyBase::pwrStateMachineWrapper() { // Will be called for transitions to MODE_OFF, where everything is done after power switching finishModeOp(); } else if (opCode == OpCodes::TO_NOT_OFF_DONE) { - // Will be called for transitions from MODE_OFF to anything else, where the mode still has - // to be commanded after power switching - AssemblyBase::startTransition(targetMode, targetSubmode); + if (dualToSingleSideTransition) { + finishModeOp(); + } else { + // Will be called for transitions from MODE_OFF to anything else, where the mode still has + // to be commanded after power switching + AssemblyBase::startTransition(targetMode, targetSubmode); + } } else if (opCode == OpCodes::TIMEOUT_OCCURED) { if (powerRetryCounter == 0) { powerRetryCounter++; @@ -118,13 +122,20 @@ ReturnValue_t DualLaneAssemblyBase::isModeCombinationValid(Mode_t mode, Submode_ void DualLaneAssemblyBase::handleModeReached() { using namespace duallane; - if (targetMode == MODE_OFF or dualToSingleSideTransition) { + if (targetMode == MODE_OFF) { pwrStateMachine.start(targetMode, targetSubmode); // Now we can switch off the power. After that, the AssemblyBase::handleModeReached function // will be called // Ignore failures for now. pwrStateMachineWrapper(); } else { + // For dual to single side transition, devices should be logically off, but the switch + // handling still needs to be done. + if (dualToSingleSideTransition) { + pwrStateMachine.start(targetMode, targetSubmode); + pwrStateMachineWrapper(); + return; + } finishModeOp(); } } From 7cf3247cbd96a291839841f66163a196fc222503 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Mar 2023 13:08:38 +0100 Subject: [PATCH 30/40] seems to work now --- linux/devices/AcsBoardPolling.cpp | 162 ++++++++++++------------ mission/devices/GyrAdis1650XHandler.cpp | 5 +- 2 files changed, 84 insertions(+), 83 deletions(-) diff --git a/linux/devices/AcsBoardPolling.cpp b/linux/devices/AcsBoardPolling.cpp index 307ddebb..adcbbf19 100644 --- a/linux/devices/AcsBoardPolling.cpp +++ b/linux/devices/AcsBoardPolling.cpp @@ -451,95 +451,99 @@ void AcsBoardPolling::gyroAdisHandler(GyroAdis& gyro) { cdHasTimedOut = gyro.countdown.hasTimedOut(); mustPerformStartup = gyro.performStartup; } - if (mode == acs::SimpleSensorMode::NORMAL and cdHasTimedOut) { - if (mustPerformStartup) { - uint8_t regList[6]; - // Read configuration - regList[0] = adis1650x::DIAG_STAT_REG; - regList[1] = adis1650x::FILTER_CTRL_REG; - regList[2] = adis1650x::RANG_MDL_REG; - regList[3] = adis1650x::MSC_CTRL_REG; - regList[4] = adis1650x::DEC_RATE_REG; - regList[5] = adis1650x::PROD_ID_REG; - size_t transferLen = - adis1650x::prepareReadCommand(regList, sizeof(regList), cmdBuf.data(), cmdBuf.size()); - result = readAdisCfg(*gyro.cookie, transferLen); - if (result != returnvalue::OK) { - gyro.replyResult = result; - return; - } - result = spiComIF.readReceivedMessage(gyro.cookie, &rawReply, &dummy); - if (result != returnvalue::OK or rawReply == nullptr) { - gyro.replyResult = result; - return; - } - uint16_t prodId = (rawReply[12] << 8) | rawReply[13]; - if (((gyro.type == adis1650x::Type::ADIS16505) and (prodId != adis1650x::PROD_ID_16505)) or - ((gyro.type == adis1650x::Type::ADIS16507) and (prodId != adis1650x::PROD_ID_16507))) { - sif::warning << "AcsPollingTask: Invalid ADIS product ID " << prodId << std::endl; - gyro.replyResult = returnvalue::FAILED; - return; - } - MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); - gyro.ownReply.cfgWasSet = true; - gyro.ownReply.cfg.diagStat = (rawReply[2] << 8) | rawReply[3]; - gyro.ownReply.cfg.filterSetting = (rawReply[4] << 8) | rawReply[5]; - gyro.ownReply.cfg.rangMdl = (rawReply[6] << 8) | rawReply[7]; - gyro.ownReply.cfg.mscCtrlReg = (rawReply[8] << 8) | rawReply[9]; - gyro.ownReply.cfg.decRateReg = (rawReply[10] << 8) | rawReply[11]; - gyro.ownReply.cfg.prodId = prodId; - gyro.ownReply.data.sensitivity = adis1650x::rangMdlToSensitivity(gyro.ownReply.cfg.rangMdl); - gyro.performStartup = false; - } - // Read regular registers - std::memcpy(cmdBuf.data(), adis1650x::BURST_READ_ENABLE.data(), - adis1650x::BURST_READ_ENABLE.size()); - std::memset(cmdBuf.data() + 2, 0, 10 * 2); - result = spiComIF.sendMessage(gyro.cookie, cmdBuf.data(), adis1650x::SENSOR_READOUT_SIZE); + if (mode == acs::SimpleSensorMode::OFF) { + return; + } + if (not cdHasTimedOut) { + return; + } + if (mustPerformStartup) { + uint8_t regList[6]; + // Read configuration + regList[0] = adis1650x::DIAG_STAT_REG; + regList[1] = adis1650x::FILTER_CTRL_REG; + regList[2] = adis1650x::RANG_MDL_REG; + regList[3] = adis1650x::MSC_CTRL_REG; + regList[4] = adis1650x::DEC_RATE_REG; + regList[5] = adis1650x::PROD_ID_REG; + size_t transferLen = + adis1650x::prepareReadCommand(regList, sizeof(regList), cmdBuf.data(), cmdBuf.size()); + result = readAdisCfg(*gyro.cookie, transferLen); if (result != returnvalue::OK) { - gyro.replyResult = returnvalue::FAILED; + gyro.replyResult = result; return; } result = spiComIF.readReceivedMessage(gyro.cookie, &rawReply, &dummy); if (result != returnvalue::OK or rawReply == nullptr) { + gyro.replyResult = result; + return; + } + uint16_t prodId = (rawReply[12] << 8) | rawReply[13]; + if (((gyro.type == adis1650x::Type::ADIS16505) and (prodId != adis1650x::PROD_ID_16505)) or + ((gyro.type == adis1650x::Type::ADIS16507) and (prodId != adis1650x::PROD_ID_16507))) { + sif::warning << "AcsPollingTask: Invalid ADIS product ID " << prodId << std::endl; gyro.replyResult = returnvalue::FAILED; return; } - uint16_t checksum = (rawReply[20] << 8) | rawReply[21]; - - // Now verify the read checksum with the expected checksum according to datasheet p. 20 - uint16_t calcChecksum = 0; - for (size_t idx = 2; idx < 20; idx++) { - calcChecksum += rawReply[idx]; - } - if (checksum != calcChecksum) { - sif::warning << "AcsPollingTask: Invalid ADIS reply checksum" << std::endl; - gyro.replyResult = returnvalue::FAILED; - return; - } - - auto burstMode = adis1650x::burstModeFromMscCtrl(gyro.ownReply.cfg.mscCtrlReg); - if (burstMode != adis1650x::BurstModes::BURST_16_BURST_SEL_0) { - sif::error << "GyroADIS1650XHandler::interpretDeviceReply: Analysis for select burst mode" - " not implemented!" - << std::endl; - gyro.replyResult = returnvalue::FAILED; - return; - } - MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); - gyro.ownReply.dataWasSet = true; - gyro.ownReply.cfg.diagStat = rawReply[2] << 8 | rawReply[3]; - gyro.ownReply.data.angVelocities[0] = (rawReply[4] << 8) | rawReply[5]; - gyro.ownReply.data.angVelocities[1] = (rawReply[6] << 8) | rawReply[7]; - gyro.ownReply.data.angVelocities[2] = (rawReply[8] << 8) | rawReply[9]; - - gyro.ownReply.data.accelerations[0] = (rawReply[10] << 8) | rawReply[11]; - gyro.ownReply.data.accelerations[1] = (rawReply[12] << 8) | rawReply[13]; - gyro.ownReply.data.accelerations[2] = (rawReply[14] << 8) | rawReply[15]; - - gyro.ownReply.data.temperatureRaw = (rawReply[16] << 8) | rawReply[17]; + gyro.ownReply.cfgWasSet = true; + gyro.ownReply.cfg.diagStat = (rawReply[2] << 8) | rawReply[3]; + gyro.ownReply.cfg.filterSetting = (rawReply[4] << 8) | rawReply[5]; + gyro.ownReply.cfg.rangMdl = (rawReply[6] << 8) | rawReply[7]; + gyro.ownReply.cfg.mscCtrlReg = (rawReply[8] << 8) | rawReply[9]; + gyro.ownReply.cfg.decRateReg = (rawReply[10] << 8) | rawReply[11]; + gyro.ownReply.cfg.prodId = prodId; + gyro.ownReply.data.sensitivity = adis1650x::rangMdlToSensitivity(gyro.ownReply.cfg.rangMdl); + gyro.performStartup = false; } + // Read regular registers + std::memcpy(cmdBuf.data(), adis1650x::BURST_READ_ENABLE.data(), + adis1650x::BURST_READ_ENABLE.size()); + std::memset(cmdBuf.data() + 2, 0, 10 * 2); + result = spiComIF.sendMessage(gyro.cookie, cmdBuf.data(), adis1650x::SENSOR_READOUT_SIZE); + if (result != returnvalue::OK) { + gyro.replyResult = returnvalue::FAILED; + return; + } + result = spiComIF.readReceivedMessage(gyro.cookie, &rawReply, &dummy); + if (result != returnvalue::OK or rawReply == nullptr) { + gyro.replyResult = returnvalue::FAILED; + return; + } + uint16_t checksum = (rawReply[20] << 8) | rawReply[21]; + + // Now verify the read checksum with the expected checksum according to datasheet p. 20 + uint16_t calcChecksum = 0; + for (size_t idx = 2; idx < 20; idx++) { + calcChecksum += rawReply[idx]; + } + if (checksum != calcChecksum) { + sif::warning << "AcsPollingTask: Invalid ADIS reply checksum" << std::endl; + gyro.replyResult = returnvalue::FAILED; + return; + } + + auto burstMode = adis1650x::burstModeFromMscCtrl(gyro.ownReply.cfg.mscCtrlReg); + if (burstMode != adis1650x::BurstModes::BURST_16_BURST_SEL_0) { + sif::error << "GyroADIS1650XHandler::interpretDeviceReply: Analysis for select burst mode" + " not implemented!" + << std::endl; + gyro.replyResult = returnvalue::FAILED; + return; + } + + MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); + gyro.ownReply.dataWasSet = true; + gyro.ownReply.cfg.diagStat = rawReply[2] << 8 | rawReply[3]; + gyro.ownReply.data.angVelocities[0] = (rawReply[4] << 8) | rawReply[5]; + gyro.ownReply.data.angVelocities[1] = (rawReply[6] << 8) | rawReply[7]; + gyro.ownReply.data.angVelocities[2] = (rawReply[8] << 8) | rawReply[9]; + + gyro.ownReply.data.accelerations[0] = (rawReply[10] << 8) | rawReply[11]; + gyro.ownReply.data.accelerations[1] = (rawReply[12] << 8) | rawReply[13]; + gyro.ownReply.data.accelerations[2] = (rawReply[14] << 8) | rawReply[15]; + + gyro.ownReply.data.temperatureRaw = (rawReply[16] << 8) | rawReply[17]; } void AcsBoardPolling::mgmLis3Handler(MgmLis3& mgm) { diff --git a/mission/devices/GyrAdis1650XHandler.cpp b/mission/devices/GyrAdis1650XHandler.cpp index 73e9a0cd..7d576238 100644 --- a/mission/devices/GyrAdis1650XHandler.cpp +++ b/mission/devices/GyrAdis1650XHandler.cpp @@ -65,10 +65,7 @@ ReturnValue_t GyrAdis1650XHandler::buildTransitionDeviceCommand(DeviceCommandId_ } case (InternalState::SHUTDOWN): { *id = adis1650x::REQUEST; - acs::Adis1650XRequest *request = reinterpret_cast(cmdBuf.data()); - request->mode = acs::SimpleSensorMode::OFF; - request->type = adisType; - return returnvalue::OK; + return preparePeriodicRequest(acs::SimpleSensorMode::OFF); } default: { return NOTHING_TO_SEND; From 22f8d256ddd3395c106ee9102908fab692404fd9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Mar 2023 13:09:28 +0100 Subject: [PATCH 31/40] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f68f5ad..e5ca13ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ will consitute of a breaking change warranting a new major release: # [unreleased] +## Fixed + +- Fixed transition for dual power lane assemblies: When going from dual side submode to single side + submode, perform logical commanding first, similarly to when going to OFF mode. + # [v1.38.0] 2023-03-17 eive-tmtc: v2.19.2 From b516f12a61f8d4978bc01e6176e647fdf8b369dd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Mar 2023 15:16:20 +0100 Subject: [PATCH 32/40] str transition fixes --- linux/devices/startracker/StarTrackerHandler.cpp | 16 ++++++++++++++-- linux/devices/startracker/StarTrackerHandler.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/linux/devices/startracker/StarTrackerHandler.cpp b/linux/devices/startracker/StarTrackerHandler.cpp index 0edf6de1..2dd73cbf 100644 --- a/linux/devices/startracker/StarTrackerHandler.cpp +++ b/linux/devices/startracker/StarTrackerHandler.cpp @@ -268,7 +268,8 @@ void StarTrackerHandler::doStartUp() { default: return; } - setMode(_MODE_TO_ON, SUBMODE_BOOTLOADER); + boot = true; + setMode(_MODE_TO_ON); } void StarTrackerHandler::doShutDown() { @@ -707,6 +708,13 @@ void StarTrackerHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { void StarTrackerHandler::doOnTransition(Submode_t subModeFrom) { uint8_t dhbSubmode = getSubmode(); + // We hide that the transition to submode firmware actually goes through the submode bootloader. + // This is because the startracker always starts in bootloader mode but we want to allow direct + // transitions to firmware mode. + if (boot) { + subModeFrom = SUBMODE_BOOTLOADER; + boot = false; + } if (dhbSubmode == SUBMODE_BOOTLOADER && subModeFrom == SUBMODE_FIRMWARE) { bootBootloader(); } else if (dhbSubmode == SUBMODE_FIRMWARE && subModeFrom == SUBMODE_FIRMWARE) { @@ -747,7 +755,11 @@ void StarTrackerHandler::bootFirmware(Mode_t toMode) { internalState = InternalState::IDLE; break; case InternalState::DONE: - setMode(toMode); + if (toMode == MODE_NORMAL) { + setMode(toMode, 0); + } else { + setMode(toMode); + } internalState = InternalState::IDLE; break; default: diff --git a/linux/devices/startracker/StarTrackerHandler.h b/linux/devices/startracker/StarTrackerHandler.h index 11cf7fc3..d6c8c72d 100644 --- a/linux/devices/startracker/StarTrackerHandler.h +++ b/linux/devices/startracker/StarTrackerHandler.h @@ -212,6 +212,7 @@ class StarTrackerHandler : public DeviceHandlerBase { // Pointer to object responsible for uploading and downloading images to/from the star tracker StrHelper* strHelper = nullptr; + bool boot = false; uint8_t commandBuffer[startracker::MAX_FRAME_SIZE]; From d8f84ed00d6656b8b3d2ad9bde8ca01e4ee0eeb7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Mar 2023 15:17:34 +0100 Subject: [PATCH 33/40] small tweak --- linux/devices/startracker/StarTrackerHandler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/devices/startracker/StarTrackerHandler.cpp b/linux/devices/startracker/StarTrackerHandler.cpp index 2dd73cbf..a195f596 100644 --- a/linux/devices/startracker/StarTrackerHandler.cpp +++ b/linux/devices/startracker/StarTrackerHandler.cpp @@ -275,6 +275,7 @@ void StarTrackerHandler::doStartUp() { void StarTrackerHandler::doShutDown() { // If the star tracker is shutdown also stop all running processes in the image loader task strHelper->stopProcess(); + boot = false; setMode(_MODE_POWER_DOWN); } From f9e04ed9a2d0077ba8cc15718f067cd547dbb10a Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 20 Mar 2023 15:42:45 +0100 Subject: [PATCH 34/40] updated gyr bias --- mission/controller/acs/AcsParameters.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mission/controller/acs/AcsParameters.h b/mission/controller/acs/AcsParameters.h index fca8ed8e..5b185ea4 100644 --- a/mission/controller/acs/AcsParameters.h +++ b/mission/controller/acs/AcsParameters.h @@ -768,10 +768,10 @@ class AcsParameters : public HasParametersIF { double gyr2orientationMatrix[3][3] = {{0, 0, -1}, {0, -1, 0}, {-1, 0, 0}}; double gyr3orientationMatrix[3][3] = {{0, 0, -1}, {0, 1, 0}, {1, 0, 0}}; - double gyr0bias[3] = {0.06318149743589743, 0.4283235025641024, -0.16383500000000004}; - double gyr1bias[3] = {-0.12855128205128205, 1.6737307692307695, 1.031724358974359}; - double gyr2bias[3] = {0.15039212820512823, 0.7094475589743591, -0.22298363589743594}; - double gyr3bias[3] = {0.0021730769230769217, -0.6655897435897435, 0.034096153846153845}; + double gyr0bias[3] = {0.0, 0.4, -0.1}; + double gyr1bias[3] = {0.0956745283018868, 2.0854575471698116, 1.2505990566037737}; + double gyr2bias[3] = {0.1, 0.7, -0.2}; + double gyr3bias[3] = {-0.10721698113207549, -0.6111650943396226, 0.1716462264150944}; /* var = sigma^2, sigma = RND*sqrt(freq), following values are RND^2 and not var as freq is * assumed to be equal for the same class of sensors */ From 881a03fbed3d8117a05a684b41d14249c32399d3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Mar 2023 15:49:41 +0100 Subject: [PATCH 35/40] direct transition to normal works again --- fsfw | 2 +- linux/devices/startracker/StarTrackerHandler.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 43fd0b2f..227524a2 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 43fd0b2f59c3aeb2d3f4db10cfad56ee3709d68d +Subproject commit 227524a21da755d125bcb1a5ff67bcbc452f8cf9 diff --git a/linux/devices/startracker/StarTrackerHandler.cpp b/linux/devices/startracker/StarTrackerHandler.cpp index a195f596..9e75c910 100644 --- a/linux/devices/startracker/StarTrackerHandler.cpp +++ b/linux/devices/startracker/StarTrackerHandler.cpp @@ -716,6 +716,9 @@ void StarTrackerHandler::doOnTransition(Submode_t subModeFrom) { subModeFrom = SUBMODE_BOOTLOADER; boot = false; } + if (dhbSubmode == SUBMODE_NONE) { + bootFirmware(MODE_ON); + } if (dhbSubmode == SUBMODE_BOOTLOADER && subModeFrom == SUBMODE_FIRMWARE) { bootBootloader(); } else if (dhbSubmode == SUBMODE_FIRMWARE && subModeFrom == SUBMODE_FIRMWARE) { @@ -759,7 +762,7 @@ void StarTrackerHandler::bootFirmware(Mode_t toMode) { if (toMode == MODE_NORMAL) { setMode(toMode, 0); } else { - setMode(toMode); + setMode(toMode, SUBMODE_FIRMWARE); } internalState = InternalState::IDLE; break; From 11c54e270f96db00ceea885f5a26d540f730c9f4 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 20 Mar 2023 15:50:50 +0100 Subject: [PATCH 36/40] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5ca13ae..6c7c5f65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,11 @@ will consitute of a breaking change warranting a new major release: - Fixed transition for dual power lane assemblies: When going from dual side submode to single side submode, perform logical commanding first, similarly to when going to OFF mode. +## Changed + +- Updated GYR bias values to newest measurements. This also corrects the ADIS values to always + consit of just one digit. + # [v1.38.0] 2023-03-17 eive-tmtc: v2.19.2 From aea4313b7d090ddafdfa9df0f0fb2f6098dd84d3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Mar 2023 15:52:58 +0100 Subject: [PATCH 37/40] some more tweaks --- linux/devices/startracker/StarTrackerHandler.cpp | 7 ++----- linux/devices/startracker/StarTrackerHandler.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/linux/devices/startracker/StarTrackerHandler.cpp b/linux/devices/startracker/StarTrackerHandler.cpp index 9e75c910..79c3a294 100644 --- a/linux/devices/startracker/StarTrackerHandler.cpp +++ b/linux/devices/startracker/StarTrackerHandler.cpp @@ -276,12 +276,9 @@ void StarTrackerHandler::doShutDown() { // If the star tracker is shutdown also stop all running processes in the image loader task strHelper->stopProcess(); boot = false; - setMode(_MODE_POWER_DOWN); -} - -void StarTrackerHandler::doOffActivity() { - startupState = StartupState::IDLE; internalState = InternalState::IDLE; + startupState = StartupState::IDLE; + setMode(_MODE_POWER_DOWN); } ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { diff --git a/linux/devices/startracker/StarTrackerHandler.h b/linux/devices/startracker/StarTrackerHandler.h index d6c8c72d..e76c0047 100644 --- a/linux/devices/startracker/StarTrackerHandler.h +++ b/linux/devices/startracker/StarTrackerHandler.h @@ -60,7 +60,6 @@ class StarTrackerHandler : public DeviceHandlerBase { protected: void doStartUp() override; void doShutDown() override; - void doOffActivity() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override; void fillCommandAndReplyMap() override; From c682d75aff3a405e7dec06714af27871a36480f5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Mar 2023 17:05:57 +0100 Subject: [PATCH 38/40] works now --- linux/devices/startracker/StarTrackerHandler.cpp | 5 ++++- linux/devices/startracker/StarTrackerHandler.h | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/linux/devices/startracker/StarTrackerHandler.cpp b/linux/devices/startracker/StarTrackerHandler.cpp index 79c3a294..d4aa8019 100644 --- a/linux/devices/startracker/StarTrackerHandler.cpp +++ b/linux/devices/startracker/StarTrackerHandler.cpp @@ -268,6 +268,8 @@ void StarTrackerHandler::doStartUp() { default: return; } + startupState = StartupState::IDLE; + internalState = InternalState::IDLE; boot = true; setMode(_MODE_TO_ON); } @@ -711,7 +713,6 @@ void StarTrackerHandler::doOnTransition(Submode_t subModeFrom) { // transitions to firmware mode. if (boot) { subModeFrom = SUBMODE_BOOTLOADER; - boot = false; } if (dhbSubmode == SUBMODE_NONE) { bootFirmware(MODE_ON); @@ -749,6 +750,7 @@ void StarTrackerHandler::bootFirmware(Mode_t toMode) { break; case InternalState::BOOT_DELAY: if (bootCountdown.hasTimedOut()) { + sif::info << "STR: Starting firmware boot" << std::endl; internalState = InternalState::REQ_VERSION; } break; @@ -2086,6 +2088,7 @@ void StarTrackerHandler::handleStartup(const uint8_t* parameterId) { break; } case (startracker::ID::DEBUG_CAMERA): { + sif::info << "Star Tracker configuration done" << std::endl; internalState = InternalState::DONE; break; } diff --git a/linux/devices/startracker/StarTrackerHandler.h b/linux/devices/startracker/StarTrackerHandler.h index e76c0047..3d9f2b93 100644 --- a/linux/devices/startracker/StarTrackerHandler.h +++ b/linux/devices/startracker/StarTrackerHandler.h @@ -277,6 +277,10 @@ class StarTrackerHandler : public DeviceHandlerBase { BOOTING_BOOTLOADER_FAILED }; + enum class CfgSetupState { + + }; + InternalState internalState = InternalState::IDLE; enum class StartupState { From 043a458f420828f61b88c4c9e5d1a9b79726f75d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Mar 2023 17:51:10 +0100 Subject: [PATCH 39/40] seems to work now --- .../startracker/StarTrackerHandler.cpp | 227 ++++++++++-------- .../devices/startracker/StarTrackerHandler.h | 47 ++-- 2 files changed, 146 insertions(+), 128 deletions(-) diff --git a/linux/devices/startracker/StarTrackerHandler.cpp b/linux/devices/startracker/StarTrackerHandler.cpp index d4aa8019..61b77fe2 100644 --- a/linux/devices/startracker/StarTrackerHandler.cpp +++ b/linux/devices/startracker/StarTrackerHandler.cpp @@ -268,18 +268,17 @@ void StarTrackerHandler::doStartUp() { default: return; } - startupState = StartupState::IDLE; + startupState = StartupState::DONE; internalState = InternalState::IDLE; - boot = true; setMode(_MODE_TO_ON); } void StarTrackerHandler::doShutDown() { // If the star tracker is shutdown also stop all running processes in the image loader task strHelper->stopProcess(); - boot = false; internalState = InternalState::IDLE; startupState = StartupState::IDLE; + bootState = FwBootState::NONE; setMode(_MODE_POWER_DOWN); } @@ -303,81 +302,103 @@ ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { switch (internalState) { - case InternalState::BOOT: - *id = startracker::BOOT; - bootCountdown.setTimeout(BOOT_TIMEOUT); - internalState = InternalState::BOOT_DELAY; - return buildCommandFromCommand(*id, nullptr, 0); - case InternalState::REQ_VERSION: - internalState = InternalState::VERIFY_BOOT; - // Again read program to check if firmware boot was successful - *id = startracker::REQ_VERSION; - return buildCommandFromCommand(*id, nullptr, 0); - case InternalState::LOGLEVEL: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::LOGLEVEL; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case InternalState::LIMITS: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::LIMITS; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case InternalState::TRACKING: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::TRACKING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case InternalState::MOUNTING: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::MOUNTING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case InternalState::IMAGE_PROCESSOR: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::IMAGE_PROCESSOR; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case InternalState::CAMERA: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::CAMERA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case InternalState::CENTROIDING: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::CENTROIDING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case InternalState::LISA: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::LISA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case InternalState::MATCHING: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::MATCHING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case InternalState::VALIDATION: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::VALIDATION; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case InternalState::ALGO: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::ALGO; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case InternalState::LOG_SUBSCRIPTION: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::LOGSUBSCRIPTION; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case InternalState::DEBUG_CAMERA: - internalState = InternalState::WAIT_FOR_EXECUTION; - *id = startracker::DEBUG_CAMERA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); + case InternalState::BOOT_FIRMWARE: { + if (bootState == FwBootState::WAIT_FOR_EXECUTION or bootState == FwBootState::VERIFY_BOOT) { + return NOTHING_TO_SEND; + } + if (bootState == FwBootState::NONE) { + *id = startracker::BOOT; + bootCountdown.setTimeout(BOOT_TIMEOUT); + bootState = FwBootState::BOOT_DELAY; + return buildCommandFromCommand(*id, nullptr, 0); + } + if (bootState == FwBootState::BOOT_DELAY) { + if (bootCountdown.isBusy()) { + return NOTHING_TO_SEND; + } + bootState = FwBootState::REQ_VERSION; + } + switch (bootState) { + case (FwBootState::REQ_VERSION): { + bootState = FwBootState::VERIFY_BOOT; + // Again read program to check if firmware boot was successful + *id = startracker::REQ_VERSION; + return buildCommandFromCommand(*id, nullptr, 0); + } + case (FwBootState::LOGLEVEL): { + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::LOGLEVEL; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + } + case (FwBootState::LIMITS): { + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::LIMITS; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + } + case (FwBootState::TRACKING): { + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::TRACKING; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + } + case FwBootState::MOUNTING: + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::MOUNTING; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + case FwBootState::IMAGE_PROCESSOR: + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::IMAGE_PROCESSOR; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + case FwBootState::CAMERA: + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::CAMERA; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + case FwBootState::CENTROIDING: + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::CENTROIDING; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + case FwBootState::LISA: + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::LISA; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + case FwBootState::MATCHING: + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::MATCHING; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + case FwBootState::VALIDATION: + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::VALIDATION; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + case FwBootState::ALGO: + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::ALGO; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + case FwBootState::LOG_SUBSCRIPTION: + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::LOGSUBSCRIPTION; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + case FwBootState::DEBUG_CAMERA: + bootState = FwBootState::WAIT_FOR_EXECUTION; + *id = startracker::DEBUG_CAMERA; + return buildCommandFromCommand( + *id, reinterpret_cast(paramJsonFile.c_str()), paramJsonFile.size()); + default: { + sif::error << "STR: Unexpected boot state" << (int)bootState << std::endl; + return NOTHING_TO_SEND; + } + } + } case InternalState::BOOT_BOOTLOADER: internalState = InternalState::BOOTLOADER_CHECK; *id = startracker::SWITCH_TO_BOOTLOADER_PROGRAM; @@ -711,7 +732,7 @@ void StarTrackerHandler::doOnTransition(Submode_t subModeFrom) { // We hide that the transition to submode firmware actually goes through the submode bootloader. // This is because the startracker always starts in bootloader mode but we want to allow direct // transitions to firmware mode. - if (boot) { + if (startupState == StartupState::DONE) { subModeFrom = SUBMODE_BOOTLOADER; } if (dhbSubmode == SUBMODE_NONE) { @@ -746,13 +767,10 @@ void StarTrackerHandler::doNormalTransition(Mode_t modeFrom, Submode_t subModeFr void StarTrackerHandler::bootFirmware(Mode_t toMode) { switch (internalState) { case InternalState::IDLE: - internalState = InternalState::BOOT; + sif::info << "STR: Booting to firmware mode" << std::endl; + internalState = InternalState::BOOT_FIRMWARE; break; - case InternalState::BOOT_DELAY: - if (bootCountdown.hasTimedOut()) { - sif::info << "STR: Starting firmware boot" << std::endl; - internalState = InternalState::REQ_VERSION; - } + case InternalState::BOOT_FIRMWARE: break; case InternalState::FAILED_FIRMWARE_BOOT: internalState = InternalState::IDLE; @@ -763,7 +781,9 @@ void StarTrackerHandler::bootFirmware(Mode_t toMode) { } else { setMode(toMode, SUBMODE_FIRMWARE); } + sif::info << "STR: Firmware boot success" << std::endl; internalState = InternalState::IDLE; + startupState = StartupState::IDLE; break; default: return; @@ -791,10 +811,11 @@ void StarTrackerHandler::setUpJsonCfgs(JsonConfigs& cfgs, const char* paramJsonF void StarTrackerHandler::bootBootloader() { if (internalState == InternalState::IDLE) { internalState = InternalState::BOOT_BOOTLOADER; - } else if (internalState == InternalState::BOOTING_BOOTLOADER_FAILED) { + } else if (internalState == InternalState::FAILED_BOOTLOADER_BOOT) { internalState = InternalState::IDLE; } else if (internalState == InternalState::DONE) { internalState = InternalState::IDLE; + startupState = StartupState::IDLE; setMode(MODE_ON); } } @@ -1949,7 +1970,7 @@ ReturnValue_t StarTrackerHandler::checkProgram() { if (startupState == StartupState::WAIT_CHECK_PROGRAM) { startupState = StartupState::DONE; } - if (internalState == InternalState::VERIFY_BOOT) { + if (bootState == FwBootState::VERIFY_BOOT) { sif::warning << "StarTrackerHandler::checkProgram: Failed to boot firmware" << std::endl; // Device handler will run into timeout and fall back to transition source mode triggerEvent(BOOTING_FIRMWARE_FAILED_EVENT); @@ -1962,11 +1983,11 @@ ReturnValue_t StarTrackerHandler::checkProgram() { if (startupState == StartupState::WAIT_CHECK_PROGRAM) { startupState = StartupState::BOOT_BOOTLOADER; } - if (internalState == InternalState::VERIFY_BOOT) { - internalState = InternalState::LOGLEVEL; + if (bootState == FwBootState::VERIFY_BOOT) { + bootState = FwBootState::LOGLEVEL; } else if (internalState == InternalState::BOOTLOADER_CHECK) { triggerEvent(BOOTING_BOOTLOADER_FAILED_EVENT); - internalState = InternalState::BOOTING_BOOTLOADER_FAILED; + internalState = InternalState::FAILED_BOOTLOADER_BOOT; } break; default: @@ -2040,55 +2061,55 @@ ReturnValue_t StarTrackerHandler::handleActionReplySet(LocalPoolDataSetBase& dat void StarTrackerHandler::handleStartup(const uint8_t* parameterId) { switch (*parameterId) { case (startracker::ID::LOG_LEVEL): { - internalState = InternalState::LIMITS; + bootState = FwBootState::LIMITS; break; } case (startracker::ID::LIMITS): { - internalState = InternalState::TRACKING; + bootState = FwBootState::TRACKING; break; } case (startracker::ID::TRACKING): { - internalState = InternalState::MOUNTING; + bootState = FwBootState::MOUNTING; break; } case (startracker::ID::MOUNTING): { - internalState = InternalState::IMAGE_PROCESSOR; + bootState = FwBootState::IMAGE_PROCESSOR; break; } case (startracker::ID::IMAGE_PROCESSOR): { - internalState = InternalState::CAMERA; + bootState = FwBootState::CAMERA; break; } case (startracker::ID::CAMERA): { - internalState = InternalState::CENTROIDING; + bootState = FwBootState::CENTROIDING; break; } case (startracker::ID::CENTROIDING): { - internalState = InternalState::LISA; + bootState = FwBootState::LISA; break; } case (startracker::ID::LISA): { - internalState = InternalState::MATCHING; + bootState = FwBootState::MATCHING; break; } case (startracker::ID::MATCHING): { - internalState = InternalState::VALIDATION; + bootState = FwBootState::VALIDATION; break; } case (startracker::ID::VALIDATION): { - internalState = InternalState::ALGO; + bootState = FwBootState::ALGO; break; } case (startracker::ID::ALGO): { - internalState = InternalState::LOG_SUBSCRIPTION; + bootState = FwBootState::LOG_SUBSCRIPTION; break; } case (startracker::ID::LOG_SUBSCRIPTION): { - internalState = InternalState::DEBUG_CAMERA; + bootState = FwBootState::DEBUG_CAMERA; break; } case (startracker::ID::DEBUG_CAMERA): { - sif::info << "Star Tracker configuration done" << std::endl; + bootState = FwBootState::NONE; internalState = InternalState::DONE; break; } diff --git a/linux/devices/startracker/StarTrackerHandler.h b/linux/devices/startracker/StarTrackerHandler.h index 3d9f2b93..a70ff8cf 100644 --- a/linux/devices/startracker/StarTrackerHandler.h +++ b/linux/devices/startracker/StarTrackerHandler.h @@ -211,7 +211,6 @@ class StarTrackerHandler : public DeviceHandlerBase { // Pointer to object responsible for uploading and downloading images to/from the star tracker StrHelper* strHelper = nullptr; - bool boot = false; uint8_t commandBuffer[startracker::MAX_FRAME_SIZE]; @@ -247,14 +246,31 @@ class StarTrackerHandler : public DeviceHandlerBase { NormalState normalState = NormalState::TEMPERATURE_REQUEST; + enum class StartupState { + IDLE, + CHECK_PROGRAM, + WAIT_CHECK_PROGRAM, + BOOT_BOOTLOADER, + WAIT_JCFG, + DONE + }; + StartupState startupState = StartupState::IDLE; + enum class InternalState { IDLE, - BOOT, + BOOT_FIRMWARE, + DONE, + FAILED_FIRMWARE_BOOT, + BOOT_BOOTLOADER, + BOOTLOADER_CHECK, + FAILED_BOOTLOADER_BOOT + }; + + enum class FwBootState { + NONE, + BOOT_DELAY, REQ_VERSION, VERIFY_BOOT, - STARTUP_CHECK, - BOOT_DELAY, - FIRMWARE_CHECK, LOGLEVEL, LIMITS, TRACKING, @@ -270,30 +286,11 @@ class StarTrackerHandler : public DeviceHandlerBase { LOG_SUBSCRIPTION, DEBUG_CAMERA, WAIT_FOR_EXECUTION, - DONE, - FAILED_FIRMWARE_BOOT, - BOOT_BOOTLOADER, - BOOTLOADER_CHECK, - BOOTING_BOOTLOADER_FAILED - }; - - enum class CfgSetupState { - }; + FwBootState bootState = FwBootState::NONE; InternalState internalState = InternalState::IDLE; - enum class StartupState { - IDLE, - CHECK_PROGRAM, - WAIT_CHECK_PROGRAM, - BOOT_BOOTLOADER, - WAIT_JCFG, - DONE - }; - - StartupState startupState = StartupState::IDLE; - bool strHelperExecuting = false; const power::Switch_t powerSwitch = power::NO_SWITCH; From 0dbe6b985432e2e8df2f3e659310d20f0374f72b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Mar 2023 17:53:33 +0100 Subject: [PATCH 40/40] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f68f5ad..ed5f4a77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ will consitute of a breaking change warranting a new major release: # [unreleased] +## Changed + +- Bugfixes for STR mode transitions: Booting to mode ON with submode FIRMWARE now works properly. + Furthermore, the submode in the NORMAL mode now should be 0 instead of some ON mode submode. + # [v1.38.0] 2023-03-17 eive-tmtc: v2.19.2