From 110cb903a609586c77e3bc093851b8d739ddedc3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jul 2023 14:14:31 +0200 Subject: [PATCH 1/8] countdown based HK generation --- CHANGELOG.md | 2 + .../PeriodicHousekeepingHelper.cpp | 47 ++++--------------- .../housekeeping/PeriodicHousekeepingHelper.h | 8 ++-- 3 files changed, 14 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4e9ab8e..c5e05a91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `PusTmZcWriter` now exposes API to set message counter field. ## Changed + +- HK generation is now countdown based. - Bump ETL version to 20.35.14 https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/748 - Renamed `PCDU_2` subsystem ID to `POWER_SWITCH_IF`. diff --git a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp index b39e45c3..852032fa 100644 --- a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp +++ b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp @@ -3,6 +3,7 @@ #include #include "fsfw/datapoollocal/LocalPoolDataSetBase.h" +#include "fsfw/serviceinterface.h" PeriodicHousekeepingHelper::PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner) : owner(owner) {} @@ -10,51 +11,21 @@ PeriodicHousekeepingHelper::PeriodicHousekeepingHelper(LocalPoolDataSetBase* own void PeriodicHousekeepingHelper::initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval) { this->minimumPeriodicInterval = minimumPeriodicInterval; - collectionIntervalTicks = intervalSecondsToIntervalTicks(collectionInterval); - /* This will cause a checkOpNecessary call to be true immediately. I think it's okay - if a HK packet is generated immediately instead of waiting one generation cycle. */ - internalTickCounter = collectionIntervalTicks; -} - -float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() const { - return intervalTicksToSeconds(collectionIntervalTicks); + changeCollectionInterval(collectionInterval); } bool PeriodicHousekeepingHelper::checkOpNecessary() { - if (internalTickCounter >= collectionIntervalTicks) { - internalTickCounter = 1; + if (hkGenerationCd.hasTimedOut()) { + hkGenerationCd.resetTimer(); return true; } - internalTickCounter++; return false; } -uint32_t PeriodicHousekeepingHelper::intervalSecondsToIntervalTicks( - float collectionIntervalSeconds) { - if (owner == nullptr) { - return 0; - } - - /* Avoid division by zero */ - if (minimumPeriodicInterval == 0) { - /* Perform operation each cycle */ - return 1; - - } else { - dur_millis_t intervalInMs = collectionIntervalSeconds * 1000; - uint32_t divisor = minimumPeriodicInterval; - uint32_t ticks = std::ceil(static_cast(intervalInMs) / divisor); - - return ticks; - } -} - -float PeriodicHousekeepingHelper::intervalTicksToSeconds(uint32_t collectionInterval) const { - /* Number of ticks times the minimum interval is in milliseconds, so we divide by 1000 to get - the value in seconds */ - return static_cast(collectionInterval * minimumPeriodicInterval / 1000.0); -} - void PeriodicHousekeepingHelper::changeCollectionInterval(float newIntervalSeconds) { - collectionIntervalTicks = intervalSecondsToIntervalTicks(newIntervalSeconds); + uint32_t intervalMs = newIntervalSeconds * 1000; + if (newIntervalSeconds <= 0) { + intervalMs = minimumPeriodicInterval; + } + hkGenerationCd.setTimeout(intervalMs); } diff --git a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h index 1ec0febf..2e168c85 100644 --- a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h +++ b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h @@ -1,6 +1,8 @@ #ifndef FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ #define FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ +#include + #include #include "fsfw/timemanager/Clock.h" @@ -19,13 +21,9 @@ class PeriodicHousekeepingHelper { private: LocalPoolDataSetBase* owner = nullptr; - - uint32_t intervalSecondsToIntervalTicks(float collectionIntervalSeconds); - float intervalTicksToSeconds(uint32_t collectionInterval) const; + Countdown hkGenerationCd; dur_millis_t minimumPeriodicInterval = 0; - uint32_t internalTickCounter = 1; - uint32_t collectionIntervalTicks = 0; }; #endif /* FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ */ From 9c8b1c697b3812958e7d00326ee12285e0484caf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jul 2023 14:20:02 +0200 Subject: [PATCH 2/8] added back missing function --- src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp | 6 ++++++ src/fsfw/housekeeping/PeriodicHousekeepingHelper.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp index 852032fa..da3b6b8d 100644 --- a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp +++ b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp @@ -14,6 +14,10 @@ void PeriodicHousekeepingHelper::initialize(float collectionInterval, changeCollectionInterval(collectionInterval); } +float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() const { + return collectionInterval; +} + bool PeriodicHousekeepingHelper::checkOpNecessary() { if (hkGenerationCd.hasTimedOut()) { hkGenerationCd.resetTimer(); @@ -26,6 +30,8 @@ void PeriodicHousekeepingHelper::changeCollectionInterval(float newIntervalSecon uint32_t intervalMs = newIntervalSeconds * 1000; if (newIntervalSeconds <= 0) { intervalMs = minimumPeriodicInterval; + newIntervalSeconds = static_cast(minimumPeriodicInterval) / 1000.0; } + collectionInterval = newIntervalSeconds; hkGenerationCd.setTimeout(intervalMs); } diff --git a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h index 2e168c85..19418977 100644 --- a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h +++ b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h @@ -22,6 +22,7 @@ class PeriodicHousekeepingHelper { private: LocalPoolDataSetBase* owner = nullptr; Countdown hkGenerationCd; + float collectionInterval = 0.0; dur_millis_t minimumPeriodicInterval = 0; }; From 88e8665280a0381c41b724ab035a8c3eff1a23c1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jul 2023 17:45:02 +0200 Subject: [PATCH 3/8] important bugfix for PUS TM creator --- CHANGELOG.md | 2 ++ src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4e9ab8e..c8e399ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- The `PusTmCreator` API only accepted 255 bytes of source data. It can now accept source + data with a size limited only by the size of `size_t`. - Important bugfix in CFDP PDU header format: The entity length field and the transaction sequence number fields stored the actual length of the field instead of the length minus 1 like specified in the CFDP standard. diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 626d873e..19922b2f 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -40,7 +40,7 @@ struct PusTmParams { size_t dataLen) : secHeader(service, subservice, timeStamper), adapter(data, dataLen), sourceData(&adapter) {} PusTmSecHeader secHeader; - SerialBufferAdapter adapter; + SerialBufferAdapter adapter; const SerializeIF* sourceData = nullptr; }; From 988e07f0bece2f1ccf7b26c9e80965440c667409 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Jul 2023 15:40:43 +0200 Subject: [PATCH 4/8] countdown --- src/fsfw/housekeeping/PeriodicHousekeepingHelper.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h index 19418977..1586649c 100644 --- a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h +++ b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h @@ -1,11 +1,10 @@ #ifndef FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ #define FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ -#include - #include #include "fsfw/timemanager/Clock.h" +#include "fsfw/timemanager/Countdown.h" class LocalPoolDataSetBase; From a26b0c38ac2631804fac8b27eb11f749748b12dd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jul 2023 10:31:02 +0200 Subject: [PATCH 5/8] small tweak to allow immediate HK generation --- src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp index da3b6b8d..ec34330a 100644 --- a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp +++ b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp @@ -34,4 +34,6 @@ void PeriodicHousekeepingHelper::changeCollectionInterval(float newIntervalSecon } collectionInterval = newIntervalSeconds; hkGenerationCd.setTimeout(intervalMs); + // We want an immediate HK packet at the start, so time out the generation CD immediately. + hkGenerationCd.timeOut(); } From aac74fae3889cc1f5184ef81d65fd7e4c56b8caf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jul 2023 10:34:19 +0200 Subject: [PATCH 6/8] shared cmake file --- .idea/cmake.xml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .idea/cmake.xml diff --git a/.idea/cmake.xml b/.idea/cmake.xml new file mode 100644 index 00000000..b0a4921a --- /dev/null +++ b/.idea/cmake.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file From 62ace649a758aa19d510e95c3c68bb50660d299e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jul 2023 10:35:35 +0200 Subject: [PATCH 7/8] fix unittest --- unittests/CatchFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittests/CatchFactory.cpp b/unittests/CatchFactory.cpp index 37c62f94..589e6887 100644 --- a/unittests/CatchFactory.cpp +++ b/unittests/CatchFactory.cpp @@ -32,7 +32,7 @@ void Factory::produceFrameworkObjects(void* args) { setStaticFrameworkObjectIds(); new EventManager(objects::EVENT_MANAGER, 120); new HealthTable(objects::HEALTH_TABLE); - new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); + new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER, 20, false, 1.0); { PoolManager::LocalPoolConfig poolCfg = {{100, 16}, {50, 32}, {25, 64}, {15, 128}, {5, 1024}}; From 796c7a9e377fa197e7e79b9a757d1b8e97419b8f Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 9 Aug 2023 11:42:11 +0200 Subject: [PATCH 8/8] tle is too old after 30 days now --- src/fsfw/coordinates/Sgp4Propagator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw/coordinates/Sgp4Propagator.cpp b/src/fsfw/coordinates/Sgp4Propagator.cpp index e79ffef5..62c2670e 100644 --- a/src/fsfw/coordinates/Sgp4Propagator.cpp +++ b/src/fsfw/coordinates/Sgp4Propagator.cpp @@ -166,9 +166,9 @@ ReturnValue_t Sgp4Propagator::propagate(double* position, double* velocity, time timeval timeSinceEpoch = time - epoch; double minutesSinceEpoch = timeSinceEpoch.tv_sec / 60. + timeSinceEpoch.tv_usec / 60000000.; - double yearsSinceEpoch = minutesSinceEpoch / 60 / 24 / 365; + double monthsSinceEpoch = minutesSinceEpoch / 60 / 24 / 30; - if ((yearsSinceEpoch > 1) || (yearsSinceEpoch < -1)) { + if ((monthsSinceEpoch > 1) || (monthsSinceEpoch < -1)) { return TLE_TOO_OLD; }