From 8e41885ca182bcddcef7747556221195e6e175a5 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 23 Aug 2023 15:21:40 +0200 Subject: [PATCH 01/18] tle gets stored presistent now --- mission/controller/AcsController.cpp | 76 +++++++++++++++---- mission/controller/AcsController.h | 15 ++-- .../AcsCtrlDefinitions.h | 14 ---- 3 files changed, 71 insertions(+), 34 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 1350bcf0..f0c1f3e0 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -22,8 +22,7 @@ AcsController::AcsController(object_id_t objectId, bool enableHkSets) mekfData(this), ctrlValData(this), actuatorCmdData(this), - fusedRotRateData(this), - tleData(this) {} + fusedRotRateData(this) {} ReturnValue_t AcsController::initialize() { ReturnValue_t result = parameterHelper.initialize(); @@ -67,19 +66,13 @@ ReturnValue_t AcsController::executeAction(ActionId_t actionId, MessageQueueId_t if (size != 69 * 2) { return INVALID_PARAMETERS; } - ReturnValue_t result = navigation.updateTle(data, data + 69); + ReturnValue_t result = updateTle(data, data + 69, false); if (result != returnvalue::OK) { - PoolReadGuard pg(&tleData); - navigation.updateTle(tleData.line1.value, tleData.line2.value); return result; } - { - PoolReadGuard pg(&tleData); - if (pg.getReadResult() == returnvalue::OK) { - std::memcpy(tleData.line1.value, data, 69); - std::memcpy(tleData.line2.value, data + 69, 69); - tleData.setValidity(true, true); - } + result = writeTleToFs(data); + if (result != returnvalue::OK) { + return result; } return HasActionsIF::EXECUTION_FINISHED; } @@ -130,6 +123,10 @@ void AcsController::performControlOperation() { } case InternalState::INITIAL_DELAY: { if (initialCountdown.hasTimedOut()) { + uint8_t line1[69] = {}; + uint8_t line2[69] = {}; + readTleFromFs(line1, line2); + updateTle(line1, line2, true); internalState = InternalState::READY; } return; @@ -801,9 +798,6 @@ ReturnValue_t AcsController::initializeLocalDataPool(localpool::DataPool &localD localDataPoolMap.emplace(acsctrl::PoolIds::ROT_RATE_PARALLEL, &rotRateParallel); localDataPoolMap.emplace(acsctrl::PoolIds::ROT_RATE_TOTAL, &rotRateTotal); poolManager.subscribeForRegularPeriodicPacket({fusedRotRateData.getSid(), enableHkSets, 10.0}); - // TLE Data - localDataPoolMap.emplace(acsctrl::PoolIds::TLE_LINE_1, &line1); - localDataPoolMap.emplace(acsctrl::PoolIds::TLE_LINE_2, &line2); return returnvalue::OK; } @@ -1031,6 +1025,58 @@ void AcsController::copySusData() { } } +ReturnValue_t AcsController::updateTle(const uint8_t *line1, const uint8_t *line2, bool fromFile) { + ReturnValue_t result = navigation.updateTle(line1, line2); + if (result != returnvalue::OK) { + if (not fromFile) { + uint8_t fileLine1[69] = {}; + uint8_t fileLine2[69] = {}; + readTleFromFs(fileLine1, fileLine2); + navigation.updateTle(fileLine1, fileLine2); + } + return result; + } + return returnvalue::OK; +} + +ReturnValue_t AcsController::writeTleToFs(const uint8_t *tle) { + // split TLE to two lines + // not sure why these need to be 70 long + uint8_t tleLine1[70] = {}; + uint8_t tleLine2[70] = {}; + std::memcpy(tleLine1, tle, 69); + std::memcpy(tleLine2, tle + 69, 69); + // ToDo: check which SD card is active via sdcMan + std::string path = SD_0 + TLE_FILE; + // Clear existing TLE from file + std::ofstream tleFile(path.c_str(), std::ofstream::out | std::ofstream::trunc); + if (tleFile.is_open()) { + tleFile << tleLine1 << "\n" << tleLine2 << "\n"; + } else { + // return error + } + tleFile.close(); + return returnvalue::OK; +} + +ReturnValue_t AcsController::readTleFromFs(uint8_t *line1, uint8_t *line2) { + // ToDo: check which SD card is active via sdcMan + std::string path = SD_0 + TLE_FILE; + // Read existing TLE from file + std::fstream tleFile = std::fstream(path.c_str(), std::fstream::in); + if (tleFile.is_open()) { + std::string tleLine1, tleLine2; + getline(tleFile, tleLine1); + std::memcpy(line1, tleLine1.c_str(), 69); + getline(tleFile, tleLine2); + std::memcpy(line2, tleLine2.c_str(), 69); + } else { + // return error + } + tleFile.close(); + return returnvalue::OK; +} + void AcsController::copyGyrData() { { PoolReadGuard pg(&sensorValues.gyr0AdisSet); diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index e03f2a55..9d91ae10 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -25,6 +25,8 @@ #include #include +#include + class AcsController : public ExtendedControllerBase, public ReceivesParameterMessagesIF { public: static constexpr dur_millis_t INIT_DELAY = 500; @@ -125,6 +127,14 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes void updateCtrlValData(const double* tgtQuat, const double* errQuat, double errAng, const double* tgtRotRate); + ReturnValue_t updateTle(const uint8_t* line1, const uint8_t* line2, bool fromFile); + ReturnValue_t writeTleToFs(const uint8_t* tle); + ReturnValue_t readTleFromFs(uint8_t* line1, uint8_t* line2); + + const std::string SD_0 = "/mnt/sd0/"; + const std::string SD_1 = "/mnt/sd1/"; + const std::string TLE_FILE = "conf/tle.txt"; + /* ACS Sensor Values */ ACS::SensorValues sensorValues; @@ -238,11 +248,6 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes PoolEntry rotRateParallel = PoolEntry(3); PoolEntry rotRateTotal = PoolEntry(3); - // TLE Dataset - acsctrl::TleData tleData; - PoolEntry line1 = PoolEntry(69); - PoolEntry line2 = PoolEntry(69); - // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(INIT_DELAY); }; diff --git a/mission/controller/controllerdefinitions/AcsCtrlDefinitions.h b/mission/controller/controllerdefinitions/AcsCtrlDefinitions.h index b843ca0c..ac348cf9 100644 --- a/mission/controller/controllerdefinitions/AcsCtrlDefinitions.h +++ b/mission/controller/controllerdefinitions/AcsCtrlDefinitions.h @@ -110,9 +110,6 @@ enum PoolIds : lp_id_t { ROT_RATE_ORTHOGONAL, ROT_RATE_PARALLEL, ROT_RATE_TOTAL, - // TLE - TLE_LINE_1, - TLE_LINE_2, }; static constexpr uint8_t MGM_SET_RAW_ENTRIES = 6; @@ -126,7 +123,6 @@ static constexpr uint8_t MEKF_SET_ENTRIES = 3; static constexpr uint8_t CTRL_VAL_SET_ENTRIES = 5; static constexpr uint8_t ACT_CMD_SET_ENTRIES = 3; static constexpr uint8_t FUSED_ROT_RATE_SET_ENTRIES = 3; -static constexpr uint8_t TLE_SET_ENTRIES = 2; /** * @brief Raw MGM sensor data. Includes the IMTQ sensor data and actuator status. @@ -299,16 +295,6 @@ class FusedRotRateData : public StaticLocalDataSet { private: }; -class TleData : public StaticLocalDataSet { - public: - TleData(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, TLE_SET) {} - - lp_vec_t line1 = lp_vec_t(sid.objectId, TLE_LINE_1, this); - lp_vec_t line2 = lp_vec_t(sid.objectId, TLE_LINE_1, this); - - private: -}; - } // namespace acsctrl #endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_ACSCTRLDEFINITIONS_H_ */ From e40dd74f396b41590563a83af4ab9af1e58f9e5c Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 14 Sep 2023 13:54:05 +0200 Subject: [PATCH 02/18] lets see if this robin guy knows what he is talking about --- mission/controller/AcsController.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index f0c1f3e0..c78ed47a 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -1040,18 +1040,14 @@ ReturnValue_t AcsController::updateTle(const uint8_t *line1, const uint8_t *line } ReturnValue_t AcsController::writeTleToFs(const uint8_t *tle) { - // split TLE to two lines - // not sure why these need to be 70 long - uint8_t tleLine1[70] = {}; - uint8_t tleLine2[70] = {}; - std::memcpy(tleLine1, tle, 69); - std::memcpy(tleLine2, tle + 69, 69); // ToDo: check which SD card is active via sdcMan std::string path = SD_0 + TLE_FILE; // Clear existing TLE from file std::ofstream tleFile(path.c_str(), std::ofstream::out | std::ofstream::trunc); if (tleFile.is_open()) { - tleFile << tleLine1 << "\n" << tleLine2 << "\n"; + tleFile.write(static_cast(tle), 69); + tleFile << "\n"; + tleFile.write(static_cast(tle + 69), 69); } else { // return error } From 1d51bfba3d203f3b34e7f1896d340729028bafe6 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 15 Sep 2023 13:34:16 +0200 Subject: [PATCH 03/18] boop --- mission/controller/AcsController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index c78ed47a..de226515 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -1045,9 +1045,9 @@ ReturnValue_t AcsController::writeTleToFs(const uint8_t *tle) { // Clear existing TLE from file std::ofstream tleFile(path.c_str(), std::ofstream::out | std::ofstream::trunc); if (tleFile.is_open()) { - tleFile.write(static_cast(tle), 69); + tleFile.write(reinterpret_cast(tle), 69); tleFile << "\n"; - tleFile.write(static_cast(tle + 69), 69); + tleFile.write(reinterpret_cast(tle + 69), 69); } else { // return error } From 463841526489c519838f569b69874a1bf282b614 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 14 Nov 2023 13:21:03 +0100 Subject: [PATCH 04/18] b-side as default --- mission/system/acs/acsModeTree.cpp | 35 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/mission/system/acs/acsModeTree.cpp b/mission/system/acs/acsModeTree.cpp index 185ad9eb..6429c0d4 100644 --- a/mission/system/acs/acsModeTree.cpp +++ b/mission/system/acs/acsModeTree.cpp @@ -106,7 +106,7 @@ Subsystem& satsystem::acs::init() { // Build TARGET PT transition 0 iht(objects::IMTQ_ASSY, NML, 0, ACS_TABLE_PTG_TRANS_0.second); iht(objects::SUS_BOARD_ASS, NML, duallane::A_SIDE, ACS_TABLE_PTG_TRANS_0.second, true); - iht(objects::ACS_BOARD_ASS, NML, duallane::A_SIDE, ACS_TABLE_PTG_TRANS_0.second, true); + iht(objects::ACS_BOARD_ASS, NML, duallane::B_SIDE, ACS_TABLE_PTG_TRANS_0.second, true); iht(objects::RW_ASSY, NML, 0, ACS_TABLE_PTG_TRANS_0.second); iht(objects::STR_ASSY, NML, 0, ACS_TABLE_PTG_TRANS_0.second); check(ACS_SUBSYSTEM.addTable( @@ -160,7 +160,8 @@ void buildOffSequence(Subsystem& ss, ModeListEntry& eh) { // Build OFF transition 1 iht(objects::IMTQ_ASSY, OFF, 0, ACS_TABLE_OFF_TRANS_1.second); iht(objects::STR_ASSY, OFF, 0, ACS_TABLE_OFF_TRANS_1.second); - iht(objects::ACS_BOARD_ASS, OFF, 0, ACS_TABLE_OFF_TRANS_1.second); + iht(objects::ACS_BOARD_ASS, OFF, duallane::B_SIDE, ACS_TABLE_OFF_TRANS_1.second); + iht(objects::SUS_BOARD_ASS, OFF, duallane::A_SIDE, ACS_TABLE_OFF_TRANS_1.second); iht(objects::RW_ASSY, OFF, 0, ACS_TABLE_OFF_TRANS_1.second); check(ss.addTable(TableEntry(ACS_TABLE_OFF_TRANS_1.first, &ACS_TABLE_OFF_TRANS_1.second)), ctxc); @@ -199,13 +200,13 @@ void buildSafeSequence(Subsystem& ss, ModeListEntry& eh) { iht(objects::ACS_CONTROLLER, acs::AcsMode::SAFE, acs::SafeSubmode::DEFAULT, ACS_TABLE_SAFE_TGT.second, true); iht(objects::IMTQ_ASSY, NML, 0, ACS_TABLE_SAFE_TGT.second); - iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_SAFE_TGT.second, true); - iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_SAFE_TGT.second, true); + iht(objects::SUS_BOARD_ASS, NML, duallane::A_SIDE, ACS_TABLE_SAFE_TGT.second, true); + iht(objects::ACS_BOARD_ASS, NML, duallane::B_SIDE, ACS_TABLE_SAFE_TGT.second, true); check(ss.addTable(&ACS_TABLE_SAFE_TGT.second, ACS_TABLE_SAFE_TGT.first, false, true), ctxc); // Build SAFE transition 0 iht(objects::IMTQ_ASSY, NML, 0, ACS_TABLE_SAFE_TRANS_0.second); - iht(objects::ACS_BOARD_ASS, NML, duallane::A_SIDE, ACS_TABLE_SAFE_TRANS_0.second, true); + iht(objects::ACS_BOARD_ASS, NML, duallane::B_SIDE, ACS_TABLE_SAFE_TRANS_0.second, true); iht(objects::SUS_BOARD_ASS, NML, duallane::A_SIDE, ACS_TABLE_SAFE_TRANS_0.second, true); iht(objects::STR_ASSY, OFF, 0, ACS_TABLE_SAFE_TRANS_0.second); iht(objects::RW_ASSY, OFF, 0, ACS_TABLE_SAFE_TRANS_0.second); @@ -256,13 +257,13 @@ void buildIdleSequence(Subsystem& ss, ModeListEntry& eh) { iht(objects::IMTQ_ASSY, NML, 0, ACS_TABLE_IDLE_TGT.second); iht(objects::RW_ASSY, NML, 0, ACS_TABLE_IDLE_TGT.second); iht(objects::STR_ASSY, NML, 0, ACS_TABLE_IDLE_TGT.second); - iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_IDLE_TGT.second, true); - iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_IDLE_TGT.second, true); + iht(objects::SUS_BOARD_ASS, NML, duallane::A_SIDE, ACS_TABLE_IDLE_TGT.second, true); + iht(objects::ACS_BOARD_ASS, NML, duallane::B_SIDE, ACS_TABLE_IDLE_TGT.second, true); ss.addTable(&ACS_TABLE_IDLE_TGT.second, ACS_TABLE_IDLE_TGT.first, false, true); // Build IDLE transition 0 iht(objects::IMTQ_ASSY, NML, 0, ACS_TABLE_IDLE_TRANS_0.second); - iht(objects::ACS_BOARD_ASS, NML, duallane::A_SIDE, ACS_TABLE_IDLE_TRANS_0.second, true); + iht(objects::ACS_BOARD_ASS, NML, duallane::B_SIDE, ACS_TABLE_IDLE_TRANS_0.second, true); iht(objects::SUS_BOARD_ASS, NML, duallane::A_SIDE, ACS_TABLE_IDLE_TRANS_0.second, true); iht(objects::RW_ASSY, NML, 0, ACS_TABLE_IDLE_TRANS_0.second); iht(objects::STR_ASSY, NML, 0, ACS_TABLE_IDLE_TRANS_0.second); @@ -306,8 +307,8 @@ void buildTargetPtSequence(Subsystem& ss, ModeListEntry& eh) { // Build TARGET PT table iht(objects::ACS_CONTROLLER, acs::AcsMode::PTG_TARGET, 0, ACS_TABLE_PTG_TARGET_TGT.second); iht(objects::IMTQ_ASSY, NML, 0, ACS_TABLE_PTG_TARGET_TGT.second); - iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_PTG_TARGET_TGT.second, true); - iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_PTG_TARGET_TGT.second, true); + iht(objects::SUS_BOARD_ASS, NML, duallane::A_SIDE, ACS_TABLE_PTG_TARGET_TGT.second, true); + iht(objects::ACS_BOARD_ASS, NML, duallane::B_SIDE, ACS_TABLE_PTG_TARGET_TGT.second, true); iht(objects::RW_ASSY, NML, 0, ACS_TABLE_PTG_TARGET_TGT.second); iht(objects::STR_ASSY, NML, 0, ACS_TABLE_PTG_TARGET_TGT.second); check(ss.addTable(&ACS_TABLE_PTG_TARGET_TGT.second, ACS_TABLE_PTG_TARGET_TGT.first, false, true), @@ -355,8 +356,8 @@ void buildTargetPtNadirSequence(Subsystem& ss, ModeListEntry& eh) { // Build TARGET PT table iht(objects::ACS_CONTROLLER, acs::AcsMode::PTG_NADIR, 0, ACS_TABLE_PTG_TARGET_NADIR_TGT.second); iht(objects::IMTQ_ASSY, NML, 0, ACS_TABLE_PTG_TARGET_NADIR_TGT.second); - iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_PTG_TARGET_NADIR_TGT.second, true); - iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_PTG_TARGET_NADIR_TGT.second, true); + iht(objects::SUS_BOARD_ASS, NML, duallane::A_SIDE, ACS_TABLE_PTG_TARGET_NADIR_TGT.second, true); + iht(objects::ACS_BOARD_ASS, NML, duallane::B_SIDE, ACS_TABLE_PTG_TARGET_NADIR_TGT.second, true); iht(objects::RW_ASSY, NML, 0, ACS_TABLE_PTG_TARGET_NADIR_TGT.second); iht(objects::STR_ASSY, NML, 0, ACS_TABLE_PTG_TARGET_NADIR_TGT.second); check(ss.addTable(TableEntry(ACS_TABLE_PTG_TARGET_NADIR_TGT.first, @@ -408,8 +409,8 @@ void buildTargetPtGsSequence(Subsystem& ss, ModeListEntry& eh) { // Build TARGET PT table iht(objects::ACS_CONTROLLER, acs::AcsMode::PTG_TARGET_GS, 0, ACS_TABLE_PTG_TARGET_GS_TGT.second); iht(objects::IMTQ_ASSY, NML, 0, ACS_TABLE_PTG_TARGET_GS_TGT.second); - iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_PTG_TARGET_GS_TGT.second, true); - iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_PTG_TARGET_GS_TGT.second, true); + iht(objects::SUS_BOARD_ASS, NML, duallane::A_SIDE, ACS_TABLE_PTG_TARGET_GS_TGT.second, true); + iht(objects::ACS_BOARD_ASS, NML, duallane::B_SIDE, ACS_TABLE_PTG_TARGET_GS_TGT.second, true); iht(objects::RW_ASSY, NML, 0, ACS_TABLE_PTG_TARGET_GS_TGT.second); iht(objects::STR_ASSY, NML, 0, ACS_TABLE_PTG_TARGET_GS_TGT.second); check(ss.addTable( @@ -461,8 +462,10 @@ void buildTargetPtInertialSequence(Subsystem& ss, ModeListEntry& eh) { iht(objects::ACS_CONTROLLER, acs::AcsMode::PTG_INERTIAL, 0, ACS_TABLE_PTG_TARGET_INERTIAL_TGT.second); iht(objects::IMTQ_ASSY, NML, 0, ACS_TABLE_PTG_TARGET_INERTIAL_TGT.second); - iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_PTG_TARGET_INERTIAL_TGT.second, true); - iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_PTG_TARGET_INERTIAL_TGT.second, true); + iht(objects::SUS_BOARD_ASS, NML, duallane::A_SIDE, ACS_TABLE_PTG_TARGET_INERTIAL_TGT.second, + true); + iht(objects::ACS_BOARD_ASS, NML, duallane::B_SIDE, ACS_TABLE_PTG_TARGET_INERTIAL_TGT.second, + true); iht(objects::RW_ASSY, NML, 0, ACS_TABLE_PTG_TARGET_INERTIAL_TGT.second); iht(objects::STR_ASSY, NML, 0, ACS_TABLE_PTG_TARGET_INERTIAL_TGT.second); check(ss.addTable(TableEntry(ACS_TABLE_PTG_TARGET_INERTIAL_TGT.first, From bd71446e051ea84550e187ee07fdae4763c1022e Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 29 Nov 2023 10:42:36 +0100 Subject: [PATCH 05/18] changelog --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74bd77e3..2b7e6eef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,11 @@ will consitute of a breaking change warranting a new major release: - The TMTC interface changes in any shape of form. - The behaviour of the OBSW changes in a major shape or form relevant for operations -# [unreleased] +# [v7.4.0] 2023-12-XX + +## Changed + +- ACS-Board default side changed to B-Side # [v7.3.0] 2023-11-07 From 6ed3dc1b50f8e2d42008197397122a837b6eab16 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 29 Nov 2023 10:43:10 +0100 Subject: [PATCH 06/18] one of those days ... --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b7e6eef..2c7e549c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ will consitute of a breaking change warranting a new major release: - The TMTC interface changes in any shape of form. - The behaviour of the OBSW changes in a major shape or form relevant for operations -# [v7.4.0] 2023-12-XX +# [v7.5.0] 2023-12-XX ## Changed From 3c8b0d1a7139b141ba190ad1ab840bf48694112c Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 29 Nov 2023 16:58:43 +0100 Subject: [PATCH 07/18] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index cc3e64e7..c906acd6 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit cc3e64e70d90f6a2b5c59215b2569c1771e890f0 +Subproject commit c906acd65960d400e7766fc12947815551d10a1a From 370eff5204fda3cae2088ced269569b3eaa8df16 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 29 Nov 2023 16:59:03 +0100 Subject: [PATCH 08/18] get correct sd card --- bsp_q7s/em/emObjectFactory.cpp | 2 +- bsp_q7s/fmObjectFactory.cpp | 2 +- linux/ObjectFactory.cpp | 5 +-- linux/ObjectFactory.h | 3 +- mission/acs/defs.h | 2 ++ mission/controller/AcsController.cpp | 49 ++++++++++++++++------------ mission/controller/AcsController.h | 16 ++++++--- 7 files changed, 49 insertions(+), 30 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 41dab3e6..bcba1331 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -175,7 +175,7 @@ void ObjectFactory::produce(void* args) { createScexComponents(q7s::UART_SCEX_DEV, pwrSwitcher, *SdCardManager::instance(), false, power::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V); #endif - createAcsController(true, enableHkSets); + createAcsController(true, enableHkSets, *SdCardManager::instance()); HeaterHandler* heaterHandler; createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler); createThermalController(*heaterHandler, true); diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index b154ac52..118b583e 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -130,6 +130,6 @@ void ObjectFactory::produce(void* args) { createMiscComponents(); createThermalController(*heaterHandler, false); - createAcsController(true, enableHkSets); + createAcsController(true, enableHkSets, *SdCardManager::instance()); satsystem::init(false); } diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 756dc0af..4956c1d6 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -335,8 +335,9 @@ void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwr scexHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM); } -AcsController* ObjectFactory::createAcsController(bool connectSubsystem, bool enableHkSets) { - auto acsCtrl = new AcsController(objects::ACS_CONTROLLER, enableHkSets); +AcsController* ObjectFactory::createAcsController(bool connectSubsystem, bool enableHkSets, + SdCardMountedIF& mountedIF) { + auto acsCtrl = new AcsController(objects::ACS_CONTROLLER, enableHkSets, mountedIF); if (connectSubsystem) { acsCtrl->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); } diff --git a/linux/ObjectFactory.h b/linux/ObjectFactory.h index 46baa685..b813d823 100644 --- a/linux/ObjectFactory.h +++ b/linux/ObjectFactory.h @@ -31,7 +31,8 @@ void createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher, void gpioChecker(ReturnValue_t result, std::string output); -AcsController* createAcsController(bool connectSubsystem, bool enableHkSets); +AcsController* createAcsController(bool connectSubsystem, bool enableHkSets, + SdCardMountedIF& mountedIF); PowerController* createPowerController(bool connectSubsystem, bool enableHkSets); } // namespace ObjectFactory diff --git a/mission/acs/defs.h b/mission/acs/defs.h index baed276d..ce308f7c 100644 --- a/mission/acs/defs.h +++ b/mission/acs/defs.h @@ -73,6 +73,8 @@ static constexpr Event MEKF_INVALID_MODE_VIOLATION = MAKE_EVENT(6, severity::HIG static constexpr Event SAFE_MODE_CONTROLLER_FAILURE = MAKE_EVENT(7, severity::HIGH); //! [EXPORT] : [COMMENT] The TLE for the SGP4 Propagator has become too old. static constexpr Event TLE_TOO_OLD = MAKE_EVENT(8, severity::INFO); +//! [EXPORT] : [COMMENT] The TLE for the SGP4 Propagator has become too old. +static constexpr Event TLE_FILE_READ_FAILED = MAKE_EVENT(9, severity::LOW); extern const char* getModeStr(AcsMode mode); diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index de226515..7dce604e 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -1,12 +1,9 @@ #include "AcsController.h" -#include -#include -#include - -AcsController::AcsController(object_id_t objectId, bool enableHkSets) +AcsController::AcsController(object_id_t objectId, bool enableHkSets, SdCardMountedIF &sdcMan) : ExtendedControllerBase(objectId), enableHkSets(enableHkSets), + sdcMan(sdcMan), fusedRotationEstimation(&acsParameters), guidance(&acsParameters), safeCtrl(&acsParameters), @@ -1040,8 +1037,11 @@ ReturnValue_t AcsController::updateTle(const uint8_t *line1, const uint8_t *line } ReturnValue_t AcsController::writeTleToFs(const uint8_t *tle) { - // ToDo: check which SD card is active via sdcMan - std::string path = SD_0 + TLE_FILE; + auto mntPrefix = sdcMan.getCurrentMountPrefix(); + if (mntPrefix == nullptr or !sdcMan.isSdCardUsable(std::nullopt)) { + return returnvalue::FAILED; + } + std::string path = mntPrefix + TLE_FILE; // Clear existing TLE from file std::ofstream tleFile(path.c_str(), std::ofstream::out | std::ofstream::trunc); if (tleFile.is_open()) { @@ -1049,27 +1049,34 @@ ReturnValue_t AcsController::writeTleToFs(const uint8_t *tle) { tleFile << "\n"; tleFile.write(reinterpret_cast(tle + 69), 69); } else { - // return error + return WRITE_FILE_FAILED; } tleFile.close(); return returnvalue::OK; } ReturnValue_t AcsController::readTleFromFs(uint8_t *line1, uint8_t *line2) { - // ToDo: check which SD card is active via sdcMan - std::string path = SD_0 + TLE_FILE; - // Read existing TLE from file - std::fstream tleFile = std::fstream(path.c_str(), std::fstream::in); - if (tleFile.is_open()) { - std::string tleLine1, tleLine2; - getline(tleFile, tleLine1); - std::memcpy(line1, tleLine1.c_str(), 69); - getline(tleFile, tleLine2); - std::memcpy(line2, tleLine2.c_str(), 69); - } else { - // return error + auto mntPrefix = sdcMan.getCurrentMountPrefix(); + if (mntPrefix == nullptr or !sdcMan.isSdCardUsable(std::nullopt)) { + return returnvalue::FAILED; + } + std::string path = mntPrefix + TLE_FILE; + std::error_code e; + if (std::filesystem::exists(path, e)) { + // Read existing TLE from file + std::fstream tleFile = std::fstream(path.c_str(), std::fstream::in); + if (tleFile.is_open()) { + std::string tleLine1, tleLine2; + getline(tleFile, tleLine1); + std::memcpy(line1, tleLine1.c_str(), 69); + getline(tleFile, tleLine2); + std::memcpy(line2, tleLine2.c_str(), 69); + } else { + triggerEvent(acs::TLE_FILE_READ_FAILED); + return returnvalue::FAILED; + } + tleFile.close(); } - tleFile.close(); return returnvalue::OK; } diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index 9d91ae10..c2e4790f 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -4,15 +4,18 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include +#include #include #include #include @@ -23,15 +26,18 @@ #include #include #include +#include #include +#include #include +#include class AcsController : public ExtendedControllerBase, public ReceivesParameterMessagesIF { public: static constexpr dur_millis_t INIT_DELAY = 500; - AcsController(object_id_t objectId, bool enableHkSets); + AcsController(object_id_t objectId, bool enableHkSets, SdCardMountedIF& sdcMan); MessageQueueId_t getCommandQueue() const; ReturnValue_t getParameter(uint8_t domainId, uint8_t parameterId, @@ -51,6 +57,8 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes bool enableHkSets = false; + SdCardMountedIF& sdcMan; + AcsParameters acsParameters; SensorProcessing sensorProcessing; FusedRotationEstimation fusedRotationEstimation; @@ -93,6 +101,8 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes static const uint8_t INTERFACE_ID = CLASS_ID::ACS_CTRL; //! [EXPORT] : [COMMENT] File deletion failed and at least one file is still existent. static constexpr ReturnValue_t FILE_DELETION_FAILED = MAKE_RETURN_CODE(0); + //! [EXPORT] : [COMMENT] Writing the TLE to the file has failed. + static constexpr ReturnValue_t WRITE_FILE_FAILED = MAKE_RETURN_CODE(1); ReturnValue_t initialize() override; ReturnValue_t handleCommandMessage(CommandMessage* message) override; @@ -131,9 +141,7 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes ReturnValue_t writeTleToFs(const uint8_t* tle); ReturnValue_t readTleFromFs(uint8_t* line1, uint8_t* line2); - const std::string SD_0 = "/mnt/sd0/"; - const std::string SD_1 = "/mnt/sd1/"; - const std::string TLE_FILE = "conf/tle.txt"; + const std::string TLE_FILE = "/conf/tle.txt"; /* ACS Sensor Values */ ACS::SensorValues sensorValues; From 882c5ce5980c7246f7929efb399e2dd26827c580 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 29 Nov 2023 17:03:34 +0100 Subject: [PATCH 09/18] changelog --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74bd77e3..a3d12faa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,15 @@ will consitute of a breaking change warranting a new major release: - The TMTC interface changes in any shape of form. - The behaviour of the OBSW changes in a major shape or form relevant for operations -# [unreleased] +# [v7.5.0] 2023-12-XX + +## Changed + +- The TLE uploaded now gets stored in a file on the filesystem. It will always be stored on + the current active SD Card. After a reboot, the TLE will be read from the filesystem. + A filesystem change via `prefSD` on bootup, can lead to the TLE not being read, even + though it is there. +- Bumped `eive-fsfw` # [v7.3.0] 2023-11-07 From a481fc23f22e8a119f3880ab2efaf3a4d95445b0 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 29 Nov 2023 17:11:46 +0100 Subject: [PATCH 10/18] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index c906acd6..7187f2b5 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c906acd65960d400e7766fc12947815551d10a1a +Subproject commit 7187f2b5cdfe163bf7ed1a8fab48900d69f4c8bf From f395c71fd08640807718e891291f4a407023305e Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 29 Nov 2023 17:12:10 +0100 Subject: [PATCH 11/18] changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3d12faa..a71a5863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,6 @@ will consitute of a breaking change warranting a new major release: the current active SD Card. After a reboot, the TLE will be read from the filesystem. A filesystem change via `prefSD` on bootup, can lead to the TLE not being read, even though it is there. -- Bumped `eive-fsfw` # [v7.3.0] 2023-11-07 From 7239b2e26d5ea68bd78aa636da318b677c69d6c1 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 30 Nov 2023 11:43:12 +0100 Subject: [PATCH 12/18] small fixes --- CHANGELOG.md | 2 ++ mission/system/acs/acsModeTree.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae47a8f7..cd298df1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ will consitute of a breaking change warranting a new major release: - ACS-Board default side changed to B-Side +# [v7.4.0] 2023-12-XX + ## Changed - Rewrote the PLOC Supervisor Handler, which is now based on a new device handler base class. diff --git a/mission/system/acs/acsModeTree.cpp b/mission/system/acs/acsModeTree.cpp index 6429c0d4..018418a4 100644 --- a/mission/system/acs/acsModeTree.cpp +++ b/mission/system/acs/acsModeTree.cpp @@ -160,8 +160,8 @@ void buildOffSequence(Subsystem& ss, ModeListEntry& eh) { // Build OFF transition 1 iht(objects::IMTQ_ASSY, OFF, 0, ACS_TABLE_OFF_TRANS_1.second); iht(objects::STR_ASSY, OFF, 0, ACS_TABLE_OFF_TRANS_1.second); - iht(objects::ACS_BOARD_ASS, OFF, duallane::B_SIDE, ACS_TABLE_OFF_TRANS_1.second); - iht(objects::SUS_BOARD_ASS, OFF, duallane::A_SIDE, ACS_TABLE_OFF_TRANS_1.second); + iht(objects::ACS_BOARD_ASS, OFF, 0, ACS_TABLE_OFF_TRANS_1.second); + iht(objects::SUS_BOARD_ASS, OFF, 0, ACS_TABLE_OFF_TRANS_1.second); iht(objects::RW_ASSY, OFF, 0, ACS_TABLE_OFF_TRANS_1.second); check(ss.addTable(TableEntry(ACS_TABLE_OFF_TRANS_1.first, &ACS_TABLE_OFF_TRANS_1.second)), ctxc); From 325a6ff70b1f8e22f6cdb887d3377456746f1221 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 30 Nov 2023 15:20:50 +0100 Subject: [PATCH 13/18] prep v7.4.0 --- CHANGELOG.md | 2 ++ CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df2d01dc..8ca3755a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ will consitute of a breaking change warranting a new major release: # [unreleased] +# [v7.4.0] 2023-11-30 + ## Changed - Rewrote the PLOC Supervisor Handler, which is now based on a new device handler base class. diff --git a/CMakeLists.txt b/CMakeLists.txt index a6b5f6e6..b3d0b344 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ cmake_minimum_required(VERSION 3.13) set(OBSW_VERSION_MAJOR 7) -set(OBSW_VERSION_MINOR 3) +set(OBSW_VERSION_MINOR 4) set(OBSW_VERSION_REVISION 0) # set(CMAKE_VERBOSE TRUE) From fa727b1e44d1c1292abef9a737c6fe671a2da889 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 30 Nov 2023 15:47:12 +0100 Subject: [PATCH 14/18] bump tmtc to v5.11.0 --- CHANGELOG.md | 2 ++ tmtc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ca3755a..7e14f0fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ will consitute of a breaking change warranting a new major release: # [v7.4.0] 2023-11-30 +- `eive-tmtc` v5.11.0 + ## Changed - Rewrote the PLOC Supervisor Handler, which is now based on a new device handler base class. diff --git a/tmtc b/tmtc index 098843a7..74e55b16 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 098843a74f93a7ec94500bc0fc9faa1abb165508 +Subproject commit 74e55b16dcca73023254493d911be3debc36adb2 From c6d0357ac9732e3808a821c5a606b618565b03ea Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 1 Dec 2023 10:22:52 +0100 Subject: [PATCH 15/18] changelog fix --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1f06f95..a7dd8a6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,8 +20,6 @@ will consitute of a breaking change warranting a new major release: - ACS-Board default side changed to B-Side -# [v7.4.0] 2023-12-XX - # [v7.4.0] 2023-11-30 - `eive-tmtc` v5.11.0 From c28ff551dbdf7061109512b14bf8b07b11459456 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 1 Dec 2023 11:41:35 +0100 Subject: [PATCH 16/18] small fix --- mission/acs/defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/acs/defs.h b/mission/acs/defs.h index ce308f7c..91030839 100644 --- a/mission/acs/defs.h +++ b/mission/acs/defs.h @@ -73,7 +73,7 @@ static constexpr Event MEKF_INVALID_MODE_VIOLATION = MAKE_EVENT(6, severity::HIG static constexpr Event SAFE_MODE_CONTROLLER_FAILURE = MAKE_EVENT(7, severity::HIGH); //! [EXPORT] : [COMMENT] The TLE for the SGP4 Propagator has become too old. static constexpr Event TLE_TOO_OLD = MAKE_EVENT(8, severity::INFO); -//! [EXPORT] : [COMMENT] The TLE for the SGP4 Propagator has become too old. +//! [EXPORT] : [COMMENT] The TLE could not be read from the filesystem. static constexpr Event TLE_FILE_READ_FAILED = MAKE_EVENT(9, severity::LOW); extern const char* getModeStr(AcsMode mode); From d22a2abf64f6ae1edc61f3852ab56f2d3aa98f0a Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 1 Dec 2023 11:42:27 +0100 Subject: [PATCH 17/18] added action cmd to read tle from file --- mission/controller/AcsController.cpp | 11 +++++++++++ mission/controller/AcsController.h | 1 + 2 files changed, 12 insertions(+) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 7dce604e..2b6a1ffc 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -73,6 +73,17 @@ ReturnValue_t AcsController::executeAction(ActionId_t actionId, MessageQueueId_t } return HasActionsIF::EXECUTION_FINISHED; } + case (READ_TLE): { + uint8_t tle[69 * 2] = {}; + uint8_t line2[69] = {}; + ReturnValue_t result = readTleFromFs(tle, line2); + if (result != returnvalue::OK) { + return result; + } + std::memcpy(tle + 69, line2, 69); + actionHelper.reportData(commandedBy, actionId, tle, 69 * 2); + return EXECUTION_FINISHED; + } default: { return HasActionsIF::INVALID_ACTION_ID; } diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index c2e4790f..4c0480bd 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -97,6 +97,7 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes static const DeviceCommandId_t RESET_MEKF = 0x1; static const DeviceCommandId_t RESTORE_MEKF_NONFINITE_RECOVERY = 0x2; static const DeviceCommandId_t UPDATE_TLE = 0x3; + static const DeviceCommandId_t READ_TLE = 0x4; static const uint8_t INTERFACE_ID = CLASS_ID::ACS_CTRL; //! [EXPORT] : [COMMENT] File deletion failed and at least one file is still existent. From b86ee21da0ab2171aaf9802e804f1239abbe2136 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 1 Dec 2023 12:56:31 +0100 Subject: [PATCH 18/18] fix for failed handling --- CHANGELOG.md | 1 + mission/controller/AcsController.cpp | 5 ++++- mission/controller/AcsController.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dd6ef7c..e0926cc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ will consitute of a breaking change warranting a new major release: the current active SD Card. After a reboot, the TLE will be read from the filesystem. A filesystem change via `prefSD` on bootup, can lead to the TLE not being read, even though it is there. +- Added action cmd to read the currently stored TLE. # [v7.4.0] 2023-11-30 diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 2b6a1ffc..8bdc7d15 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -1084,9 +1084,12 @@ ReturnValue_t AcsController::readTleFromFs(uint8_t *line1, uint8_t *line2) { std::memcpy(line2, tleLine2.c_str(), 69); } else { triggerEvent(acs::TLE_FILE_READ_FAILED); - return returnvalue::FAILED; + return READ_FILE_FAILED; } tleFile.close(); + } else { + triggerEvent(acs::TLE_FILE_READ_FAILED); + return READ_FILE_FAILED; } return returnvalue::OK; } diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index 4c0480bd..4d80da3e 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -104,6 +104,8 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes static constexpr ReturnValue_t FILE_DELETION_FAILED = MAKE_RETURN_CODE(0); //! [EXPORT] : [COMMENT] Writing the TLE to the file has failed. static constexpr ReturnValue_t WRITE_FILE_FAILED = MAKE_RETURN_CODE(1); + //! [EXPORT] : [COMMENT] Reading the TLE to the file has failed. + static constexpr ReturnValue_t READ_FILE_FAILED = MAKE_RETURN_CODE(2); ReturnValue_t initialize() override; ReturnValue_t handleCommandMessage(CommandMessage* message) override;