From 74fa81d8f6ec422972dc0c6efd64cd6ae9063d12 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 14:44:32 +0100 Subject: [PATCH 1/6] 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 2/6] 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 3/6] 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 4/6] 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 5/6] 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 2f263c6aa6c270c37fe36187ef999c4f82ffa7f2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 16:21:05 +0100 Subject: [PATCH 6/6] 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.