diff --git a/CHANGELOG.md b/CHANGELOG.md index b4e9ab8e..9f5bb9bb 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. @@ -28,6 +30,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..da3b6b8d 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,27 @@ 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; + changeCollectionInterval(collectionInterval); } float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() const { - return intervalTicksToSeconds(collectionIntervalTicks); + return 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; + 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 1ec0febf..1586649c 100644 --- a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h +++ b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h @@ -4,6 +4,7 @@ #include #include "fsfw/timemanager/Clock.h" +#include "fsfw/timemanager/Countdown.h" class LocalPoolDataSetBase; @@ -19,13 +20,10 @@ class PeriodicHousekeepingHelper { private: LocalPoolDataSetBase* owner = nullptr; - - uint32_t intervalSecondsToIntervalTicks(float collectionIntervalSeconds); - float intervalTicksToSeconds(uint32_t collectionInterval) const; + Countdown hkGenerationCd; + float collectionInterval = 0.0; dur_millis_t minimumPeriodicInterval = 0; - uint32_t internalTickCounter = 1; - uint32_t collectionIntervalTicks = 0; }; #endif /* FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ */ 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; };