Compare commits

..

46 Commits

Author SHA1 Message Date
49eaeae42b Merge pull request 'Adaptions to make shared power lines possible' (#57) from spahr/shared into main
Reviewed-on: #57
Reviewed-by: Robin Müller <muellerr@irs.uni-stuttgart.de>
2025-04-28 13:50:31 +02:00
7bfc536cf6 Merge branch 'main' into spahr/shared 2025-04-28 13:50:23 +02:00
1da7f7f122 Merge pull request 'Added STOP_DOWNLINK_STORE_CONTENT for Service [15,17]' (#58) from hoffmann/TmStoreMessage into main
Reviewed-on: #58
2025-04-21 19:21:40 +02:00
aa443e6aa6 Added STOP_DOWNLINK_STORE_CONTENT for Service [15,17] 2025-04-21 17:05:58 +02:00
b13b5b456d Give AssemblyBase more functionality: Support one-by-one commanding for childrend instead of sending all mode messages on one shot 2025-04-14 00:06:34 +02:00
297ec261ce make the recovery timeout accessable to the user 2025-04-04 10:11:11 +02:00
95520d7d0c Check if objectId exists in childrednmap first; this will prevent a hardfault 2025-04-02 22:18:31 +02:00
b665b2effe add an adaption point which a user can use to convert a objectId of a shared power switch into a objectId of a device handler 2025-04-02 22:13:50 +02:00
7ae58f8125 Merge pull request 'Send HK One Parameter Report back to Sender' (#56) from meier/hk-report-reply-queue into main
Reviewed-on: #56
Reviewed-by: Robin Müller <muellerr@irs.uni-stuttgart.de>
2025-04-02 14:04:46 +02:00
7784a26a10 Merge branch 'main' into meier/hk-report-reply-queue 2025-04-02 14:04:37 +02:00
3afd0c8d3c updated changelog 2025-04-01 17:25:02 +02:00
71623d5314 Merge commit 'f01e58a7' into meier/hk-report-reply-queue 2025-04-01 14:18:07 +02:00
daac5ea727 Merge pull request 'spahr/handleRecoveryEvents' (#54) from spahr/handleRecoveryEvents into main
Reviewed-on: #54
Reviewed-by: Robin Müller <muellerr@irs.uni-stuttgart.de>
2025-04-01 14:07:10 +02:00
2c01b83b75 Merge branch 'main' into spahr/handleRecoveryEvents 2025-04-01 14:06:36 +02:00
f01e58a757 Merge pull request 'seems like this should set the serializables to .get().setValid(valid) instead of true' (#55) from mdemke/hotfix_hk__setChildrenValidity into main
Reviewed-on: #55
Reviewed-by: Robin Müller <muellerr@irs.uni-stuttgart.de>
2025-03-31 12:25:06 +02:00
40be8ebef5 seems like this should set the serializables to .get().setValid(valid) instead of true 2025-03-28 00:41:40 +01:00
2af6e85f87 send hk report back to sender instead of default destination 2025-03-23 12:35:40 +01:00
d8ac312e85 remove event because it's no longer needed. 2025-03-22 10:01:01 +01:00
1e12753533 add device object id to event 2025-03-22 09:49:44 +01:00
b7699b327b add two new events for the recovery process, to make debug and output more clear. This also makes a recovery process more clear for OPS. 2025-03-22 09:48:30 +01:00
9945f72eaf improve documentation for event 2025-03-22 09:40:31 +01:00
55b8d01b93 Merge pull request 'Compile time const event definitions and compile error for unique IDs above limit' (#53) from baumgartl/events into main
Reviewed-on: #53
Reviewed-by: Robin Müller <muellerr@irs.uni-stuttgart.de>
2025-03-18 14:39:34 +01:00
8cb1d84c58 fixed event definition for archive/mgm and pus 11 2025-03-12 22:18:55 +01:00
8801dfa31d implemented event limit. TODO: adjust generator parsing and usage in src-obsw 2025-03-12 21:46:48 +01:00
b8979d8f90 Merge pull request 'Improve readability of SubsystemBase::executeTable' (#49) from spahr/SubsystemBase into main
Reviewed-on: #49
2025-02-19 11:26:36 +01:00
9557db7036 Merge branch 'main' into spahr/SubsystemBase 2025-02-19 11:26:26 +01:00
c9fcabccd6 Merge pull request 'Missing valid flag update in readWithoutLock and commitWithoutLock' (#48) from bugfix-poolvariable into main
Reviewed-on: #48
2025-02-19 11:26:04 +01:00
ecd36f5e52 Merge branch 'main' into bugfix-poolvariable 2025-02-19 11:25:52 +01:00
fc19c0838e Merge pull request 'Formatting of debug printout' (#50) from spahr/formattingForDebugPrintout into main
Reviewed-on: #50
2025-02-19 11:24:39 +01:00
8c3f366d1a formatting for time prinout 2025-02-16 17:36:22 +01:00
6efb2641a7 Re-write the logic in executeTable() to improve the readabilty of the code. This gets rid of the usage of isFaulty() (which is misleading), and removes nexted if-statements 2025-02-16 17:07:40 +01:00
260bbad9a0 Modify the hard-coded strings which are printed to into the debug session to enforce alignment of all printouts, regardless of their printlevel (info, debug, warning, error). 2025-02-14 19:02:57 +01:00
9edd6221f8 Missing valid flag update in readWithoutLock and commitWithoutLock 2025-02-11 15:16:27 +01:00
735e341aab Merge pull request 'temperaturesensor-bugfix' (#47) from temperaturesensor-bugfix into main
Reviewed-on: #47
2025-01-21 14:33:29 +01:00
921bfb1e99 Merge branch 'main' into temperaturesensor-bugfix 2025-01-21 14:31:59 +01:00
5b1651e1a6 Merge pull request 'Update HK and datapool handling' (#45) from update-hk-handling-datapools into main
Reviewed-on: #45
2025-01-08 10:38:34 +01:00
e916b9b096 fix for CMakeLists.txt 2025-01-07 10:50:37 +01:00
b14e761bad small typo 2025-01-07 10:50:37 +01:00
33f3ae2434 Update and clean up HK and Local Pool Modules 2025-01-07 10:50:37 +01:00
f0087d5b0d Merge pull request 'FreeRTOS Monotonic Clock' (#46) from meier/freertos-monotonic-clock into main
Reviewed-on: #46
Reviewed-by: Robin Müller <muellerr@irs.uni-stuttgart.de>
2025-01-07 10:33:29 +01:00
69c33587e8 Merge remote-tracking branch 'origin/main' into temperaturesensor-bugfix 2024-12-31 10:51:11 +01:00
d1bf04cc29 Merge branch 'main' into meier/freertos-monotonic-clock 2024-12-25 10:20:22 +01:00
8e3bc1b8aa updated changelog 2024-12-23 12:07:54 +01:00
64f97fc3ba implemented freertos monotonic clock 2024-12-23 12:02:29 +01:00
1427fbd2fe added monotonic clock which is independend of clock jumps in the system clock 2024-12-22 18:37:44 +01:00
81cd8bd290 did not build before 2024-12-15 23:52:32 +01:00
35 changed files with 216 additions and 102 deletions

View File

@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## Added
- FreeRTOS monotonic clock which is not subjected to time jumps of the system clock
- add CFDP subsystem ID
https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/742
- `PusTmZcWriter` now exposes API to set message counter field.
@ -34,8 +35,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## Changed
- Complete refactoring of HK subsystem. Replaced local data pool manager by periodic HK
- send HK one-parameter-report back to sender instead of default hk queue
- Complete overhaul of HK subsystem. Replaced local data pool manager by periodic HK
helper. The shared pool and the periodic HK generation are now distinct concepts.
- The local HK manager was replaced by a periodic HK helper which has reduced responsibilities.
It takes care of tracking the HK generation using a set specification provided by the user.n
However, it leaves serialization of the HK data completely to the developer. This removes a major
constraint on the format of the HK data, which was previously constrained to implementors of a
certain base class.
- The former set classes and pool objects are still available for HK set specification and
generation. The API has changed, but the general usage and their architecture has not.
- A new set of set classes and helper objects to specify HK sets and data which does not need to be
shared was added as well. The majority of datasets do not need to be shared anyway.
- The non-shared API retain the capability of appending of a validity blob for each piece of set
data at the end of the HK data. For both non-shared and shared data, this capability can be
specified in the constructor, and defaults to true.
- Improved File System Abstraction to be more in line with normal filesystems.
- CFDP implementation was improved, has now even less dependencies on other FSFW components
and allows one inserted packet per state machine call.

View File

@ -142,7 +142,7 @@ if(FSFW_BUILD_TESTS)
configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h)
project(${FSFW_TEST_TGT} CXX C)
add_executable(${FSFW_TEST_TGT} unittests/datapool/testDataset.cpp)
add_executable(${FSFW_TEST_TGT})
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION
TRUE)

View File

@ -18,13 +18,13 @@ class MgmRM3100Handler : public DeviceHandlerBase {
static const uint8_t INTERFACE_ID = CLASS_ID::MGM_RM3100;
//! [EXPORT] : [COMMENT] P1: TMRC value which was set, P2: 0
static constexpr Event tmrcSet = event::makeEvent(SUBSYSTEM_ID::MGM_RM3100, 0x00, severity::INFO);
static constexpr Event tmrcSet = event::makeEvent<SUBSYSTEM_ID::MGM_RM3100, 0x00, severity::INFO>();
//! [EXPORT] : [COMMENT] Cycle counter set. P1: First two bytes new Cycle Count X
//! P1: Second two bytes new Cycle Count Y
//! P2: New cycle count Z
static constexpr Event cycleCountersSet =
event::makeEvent(SUBSYSTEM_ID::MGM_RM3100, 0x01, severity::INFO);
event::makeEvent<SUBSYSTEM_ID::MGM_RM3100, 0x01, severity::INFO>();
MgmRM3100Handler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie,
uint32_t transitionDelay);

View File

@ -19,13 +19,13 @@ struct FsfwParams {
};
namespace events {
static constexpr Event PDU_SEND_ERROR = event::makeEvent(SSID, 1, severity::LOW);
static constexpr Event SERIALIZATION_ERROR = event::makeEvent(SSID, 2, severity::LOW);
static constexpr Event FILESTORE_ERROR = event::makeEvent(SSID, 3, severity::LOW);
static constexpr Event PDU_SEND_ERROR = event::makeEvent<SSID, 1, severity::LOW>();
static constexpr Event SERIALIZATION_ERROR = event::makeEvent<SSID, 2, severity::LOW>();
static constexpr Event FILESTORE_ERROR = event::makeEvent<SSID, 3, severity::LOW>();
//! [EXPORT] : [COMMENT] P1: Transaction step ID, P2: 0 for source file name, 1 for dest file name
static constexpr Event FILENAME_TOO_LARGE_ERROR = event::makeEvent(SSID, 4, severity::LOW);
static constexpr Event FILENAME_TOO_LARGE_ERROR = event::makeEvent<SSID, 4, severity::LOW>();
//! [EXPORT] : [COMMENT] CFDP request handling failed. P2: Returncode.
static constexpr Event HANDLING_CFDP_REQUEST_FAILED = event::makeEvent(SSID, 5, severity::LOW);
static constexpr Event HANDLING_CFDP_REQUEST_FAILED = event::makeEvent<SSID, 5, severity::LOW>();
} // namespace events
static constexpr ReturnValue_t SOURCE_TRANSACTION_PENDING = returnvalue::makeCode(CID, 0);

View File

@ -34,11 +34,12 @@ class ExtendedControllerBase : public ControllerBase,
ActionHelper actionHelper;
// Periodic HK methods, default method assumes that no shared pool is required.
virtual datapool::SharedPool* getOptionalSharedPool() override;
datapool::SharedPool* getOptionalSharedPool() override = 0;
// Periodic HK abstract methods.
ReturnValue_t serializeHkDataset(dp::sid_t structureId, uint8_t* buf, size_t maxSize) = 0;
ReturnValue_t specifyHkDatasets(std::vector<hk::SetSpecification>& setList) = 0;
ReturnValue_t serializeHkDataset(dp::sid_t structureId, uint8_t* buf,
size_t maxSize) override = 0;
ReturnValue_t specifyHkDatasets(std::vector<hk::SetSpecification>& setList) override = 0;
/**
* Implemented by child class. Handle all command messages which are

View File

@ -48,6 +48,14 @@ PoolObjectBase::PoolObjectBase(object_id_t poolOwner, id_t poolId, DataSetIF* da
return;
}
sharedPool = hkOwner->getOptionalSharedPool();
if (sharedPool == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PoolObjectBase: HK owner 0x" << std::hex << poolOwner << std::dec
<< "does not have a shared pool " << std::endl;
#else
sif::printError("PoolObjectBase: HK owner 0x%08x does not have a shared pool\n", poolOwner);
#endif
}
if (dataSet != nullptr) {
dataSet->registerVariable(this);

View File

@ -9,9 +9,9 @@
PoolDataSetBase::PoolDataSetBase(PoolVariableIF** registeredVariablesArray,
const size_t maxFillCount, bool serializeWithValidityBlob)
: registeredVariables(registeredVariablesArray),
maxFillCount(maxFillCount),
serializeWithValidityBlob(serializeWithValidityBlob) {}
: serializeWithValidityBlob(serializeWithValidityBlob),
registeredVariables(registeredVariablesArray),
maxFillCount(maxFillCount) {}
PoolDataSetBase::~PoolDataSetBase() = default;
@ -251,6 +251,9 @@ size_t PoolDataSetBase::getSerializedSize() const {
for (uint16_t count = 0; count < fillCount; count++) {
size += registeredVariables[count]->getSerializedSize();
}
if (serializeWithValidityBlob) {
size += std::ceil(static_cast<float>(fillCount) / 8.0);
}
return size;
}

View File

@ -139,6 +139,8 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF {
*/
void setChildrenValidity(bool valid);
bool serializeWithValidityBlob = false;
protected:
/**
* @brief The fill_count attribute ensures that the variables
@ -166,7 +168,6 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF {
*/
PoolVariableIF** registeredVariables = nullptr;
const size_t maxFillCount = 0;
bool serializeWithValidityBlob = false;
void setContainer(PoolVariableIF** variablesContainer);
PoolVariableIF** getContainer() const;

View File

@ -20,9 +20,9 @@ class PoolReadGuard {
if (readResult != returnvalue::OK) {
#if FSFW_VERBOSE_LEVEL == 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PoolReadHelper: Read failed!" << std::endl;
sif::error << "PoolReadGuard: Read failed!" << std::endl;
#else
sif::printError("PoolReadHelper: Read failed!\n");
sif::printError("PoolReadGuard: Read failed!\n");
#endif /* FSFW_PRINT_VERBOSITY_LEVEL == 1 */
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
}

View File

@ -210,6 +210,7 @@ inline ReturnValue_t PoolVariable<T>::readWithoutLock() {
}
this->value = *(poolEntry->getDataPtr());
this->valid = poolEntry->getValid();
return returnvalue::OK;
}
@ -241,6 +242,7 @@ ReturnValue_t PoolVariable<T>::commitWithoutLock() {
}
*(poolEntry->getDataPtr()) = this->value;
poolEntry->setValid(this->valid);
return returnvalue::OK;
}

View File

@ -3,7 +3,7 @@
using namespace dp;
SharedSet::SharedSet(dp::SharedPool& sharedPool, uint32_t setId, const size_t maxNumberOfVariables,
bool serializeWithValídityBlob)
bool serializeWithValidityBlob)
: SharedSetBase(sharedPool, setId, nullptr, maxNumberOfVariables, serializeWithValidityBlob),
poolVarList(maxNumberOfVariables) {
this->setContainer(poolVarList.data());

View File

@ -105,9 +105,6 @@ ReturnValue_t SharedSetBase::deSerialize(const uint8_t **buffer, size_t *size,
ReturnValue_t SharedSetBase::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const {
if (serializeWithValidityBlob) {
return base.doSerializeWithValidityBlob(buffer, size, maxSize, streamEndianness);
}
return base.serialize(buffer, size, maxSize, streamEndianness);
}
@ -143,10 +140,17 @@ void SharedSetBase::setAllVariablesReadOnly() {
void SharedSetBase::printSet() { return; }
ReturnValue_t SharedSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
return base.read(timeoutType, timeoutMs);
lockDataPool(timeoutType, timeoutMs);
ReturnValue_t result = base.read(timeoutType, timeoutMs);
unlockDataPool();
return result;
}
ReturnValue_t SharedSetBase::commit(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
return base.commit(timeoutType, timeoutMs);
lockDataPool(timeoutType, timeoutMs);
ReturnValue_t result = base.commit(timeoutType, timeoutMs);
unlockDataPool();
return result;
}
uint16_t SharedSetBase::getFillCount() const { return base.getFillCount(); }
@ -158,3 +162,8 @@ void SharedSetBase::setContainer(PoolVariableIF **variablesContainer) {
return base.setContainer(variablesContainer);
}
PoolVariableIF **SharedSetBase::getContainer() const { return base.getContainer(); }
void SharedSetBase::updateValidityBlobSerialization(bool enable) {
base.serializeWithValidityBlob = enable;
}
bool SharedSetBase::getValidityBlobSerialization() const { return base.serializeWithValidityBlob; }

View File

@ -159,11 +159,8 @@ class SharedSetBase : public SerializeIF, public PoolDataSetIF {
*/
void setChildrenValidity(bool valid);
/**
* If the valid state of a dataset is always relevant to the whole
* data set we can use this flag.
*/
bool serializeWithValidityBlob = false;
void updateValidityBlobSerialization(bool enable);
bool getValidityBlobSerialization() const;
protected:
PoolDataSetBase base;

View File

@ -71,7 +71,7 @@ bool AssemblyBase::handleChildrenChangedHealth() {
if (iter == childrenMap.end()) {
return false;
}
HealthState healthState = healthHelper.healthTable->getHealth(iter->first);
HealthState healthState = healthHelper.healthTable->getHealth(convertToDeviceObjectId(iter->first));
if (healthState == HasHealthIF::NEEDS_RECOVERY) {
triggerEvent(TRYING_RECOVERY, iter->first, 0);
recoveryState = RECOVERY_STARTED;
@ -92,9 +92,14 @@ void AssemblyBase::handleChildrenTransition() {
if (commandsOutstanding <= 0) {
switch (internalState) {
case STATE_NEED_SECOND_STEP:
{
internalState = STATE_SECOND_STEP;
commandChildren(targetMode, targetSubmode);
ReturnValue_t result = commandChildren(targetMode, targetSubmode);
if(result == NEED_SECOND_STEP) {
internalState = STATE_NEED_SECOND_STEP;
}
return;
}
case STATE_OVERWRITE_HEALTH: {
internalState = STATE_SINGLE_STEP;
ReturnValue_t result = commandChildren(mode, submode);
@ -170,7 +175,7 @@ ReturnValue_t AssemblyBase::checkChildrenStateOff() {
ReturnValue_t AssemblyBase::checkChildOff(uint32_t objectId) {
ChildInfo childInfo = childrenMap.find(objectId)->second;
if (healthHelper.healthTable->isCommandable(objectId)) {
if (healthHelper.healthTable->isCommandable(convertToDeviceObjectId(objectId))) {
if (childInfo.submode != SUBMODE_NONE) {
return returnvalue::FAILED;
} else {
@ -227,7 +232,7 @@ bool AssemblyBase::checkAndHandleRecovery() {
case RECOVERY_STARTED:
// The recovery was already start in #handleChildrenChangedHealth and we just need
// to wait for an off time period.
// TODO: make time period configurable
// The timeout can be defined by #setRecoveryWaitTimer
recoveryState = RECOVERY_WAIT;
recoveryOffTimer.resetTimer();
return true;
@ -235,14 +240,14 @@ bool AssemblyBase::checkAndHandleRecovery() {
if (recoveryOffTimer.isBusy()) {
return true;
}
triggerEvent(RECOVERY_STEP, 0);
triggerEvent(RECOVERY_WAITING, recoveringDevice->first);
sendHealthCommand(recoveringDevice->second.commandQueue, HEALTHY);
internalState = STATE_NONE;
recoveryState = RECOVERY_ONGOING;
// Don't check state!
return true;
case RECOVERY_ONGOING:
triggerEvent(RECOVERY_STEP, 1);
triggerEvent(RECOVERY_RESTARTING, recoveringDevice->first);
recoveryState = RECOVERY_ONGOING_2;
recoveringDevice->second.healthChanged = false;
// Device should be healthy again, so restart a transition.
@ -250,7 +255,7 @@ bool AssemblyBase::checkAndHandleRecovery() {
doStartTransition(targetMode, targetSubmode);
return true;
case RECOVERY_ONGOING_2:
triggerEvent(RECOVERY_DONE);
triggerEvent(RECOVERY_DONE, recoveringDevice->first);
// Now we're through, but not sure if it was successful.
recoveryState = RECOVERY_IDLE;
return false;
@ -264,7 +269,15 @@ void AssemblyBase::overwriteDeviceHealth(object_id_t objectId, HasHealthIF::Heal
triggerEvent(OVERWRITING_HEALTH, objectId, oldHealth);
internalState = STATE_OVERWRITE_HEALTH;
modeHelper.setForced(true);
sendHealthCommand(childrenMap[objectId].commandQueue, EXTERNAL_CONTROL);
if(childrenMap.find(objectId) != childrenMap.end()) {
sendHealthCommand(childrenMap.at(objectId).commandQueue, EXTERNAL_CONTROL);
} else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << std::hex << SystemObject::getObjectId() << ": invalid mode table entry"
<< std::endl;
#endif
}
}
void AssemblyBase::triggerModeHelperEvents(Mode_t mode, Submode_t submode) {
@ -274,3 +287,7 @@ void AssemblyBase::triggerModeHelperEvents(Mode_t mode, Submode_t submode) {
triggerEvent(CHANGING_MODE, mode, submode);
}
}
void AssemblyBase::setRecoveryWaitTimer(uint32_t timeoutMS) {
recoveryOffTimer.setTimeout(timeoutMS);
}

View File

@ -206,6 +206,8 @@ class AssemblyBase : public SubsystemBase {
void overwriteDeviceHealth(object_id_t objectId, HasHealthIF::HealthState oldHealth);
void triggerModeHelperEvents(Mode_t mode, Submode_t submode);
void setRecoveryWaitTimer(uint32_t timeoutMS);
};
#endif /* FSFW_DEVICEHANDLERS_ASSEMBLYBASE_H_ */

View File

@ -148,20 +148,24 @@ class FreshDeviceHandlerBase : public SystemObject,
// System Object overrides.
ReturnValue_t initialize() override;
// Default implementation assumes that no optional shared pool is required.
datapool::SharedPool* getOptionalSharedPool() override;
/**
* This function is implemented to serialize a housekeeping packet when a HK message to
* generate the packet is received, or periodic generation is necessary. The user should serialize the HK
* set into the provided buffer, which will have the size specified in the set specification.
* generate the packet is received, or periodic generation is necessary. The user should serialize
* the HK set into the provided buffer, which will have the size specified in the set
* specification.
*/
ReturnValue_t serializeHkDataset(dp::sid_t structureId, uint8_t* buf, size_t maxSize) override = 0;
ReturnValue_t serializeHkDataset(dp::sid_t structureId, uint8_t* buf,
size_t maxSize) override = 0;
/**
* This function is implemented by the user to specify the available housekeeping sets.
*/
ReturnValue_t specifyHkDatasets(std::vector<hk::SetSpecification>& setList) override = 0;
/*
* If this device handler has an optional pool, return it. Otherwise, nullptr can be returned.
*/
datapool::SharedPool* getOptionalSharedPool() override = 0;
/**
* Implemented by child class. Handle all command messages which are
* not health, mode, action or housekeeping messages.
@ -202,7 +206,6 @@ class FreshDeviceHandlerBase : public SystemObject,
* @return
*/
virtual ReturnValue_t performOperation(uint8_t opCode) override;
ReturnValue_t initializeAfterTaskCreation() override;
/**
* This calls the FDIR instance event trigger function.

View File

@ -14,8 +14,6 @@ enum Severity : EventSeverity_t { INFO = 1, LOW = 2, MEDIUM = 3, HIGH = 4 };
} // namespace severity
#define MAKE_EVENT(id, severity) (((severity) << 16) + (SUBSYSTEM_ID * 100) + (id))
typedef uint32_t Event;
namespace event {
@ -24,11 +22,14 @@ constexpr EventId_t getEventId(Event event) { return (event & 0xFFFF); }
constexpr EventSeverity_t getSeverity(Event event) { return ((event >> 16) & 0xFF); }
constexpr Event makeEvent(uint8_t subsystemId, UniqueEventId_t uniqueEventId,
EventSeverity_t eventSeverity) {
template<uint8_t subsystemId, UniqueEventId_t uniqueEventId, EventSeverity_t eventSeverity>
constexpr Event makeEvent() {
static_assert(uniqueEventId < 100, "The unique event ID must be smaller than 100!");
return (eventSeverity << 16) + (subsystemId * 100) + uniqueEventId;
}
} // namespace event
#define MAKE_EVENT(id, severity) event::makeEvent<SUBSYSTEM_ID, id, severity>();
#endif /* EVENTOBJECT_EVENT_H_ */

View File

@ -27,13 +27,19 @@ class HasHealthIF {
static const Event CHILD_PROBLEMS = MAKE_EVENT(8, severity::LOW);
//! Assembly overwrites health information of children to keep satellite alive.
static const Event OVERWRITING_HEALTH = MAKE_EVENT(9, severity::LOW);
//! Someone starts a recovery of a component (typically power-cycle). No parameters.
//! Someone starts a recovery of a component (typically power-cycle).
//! P1: Object Id of the recovering device.
static const Event TRYING_RECOVERY = MAKE_EVENT(10, severity::MEDIUM);
//! Recovery is ongoing. Comes twice during recovery.
//! P1: 0 for the first, 1 for the second event. P2: 0
static const Event RECOVERY_STEP = MAKE_EVENT(11, severity::MEDIUM);
//! Recovery was completed. Not necessarily successful. No parameters.
//! P1: Object Id of the recovering device.
static const Event RECOVERY_DONE = MAKE_EVENT(12, severity::MEDIUM);
//! Recovery is ongoing. The recovering device is currently OFF, waiting for restart.
//! P1: Object Id of the recovering device.
static const Event RECOVERY_WAITING = MAKE_EVENT(13, severity::MEDIUM);
//! Recovery is ongoing. Restarting the recovering device.
//! P1: Object Id of the recovering device.
static const Event RECOVERY_RESTARTING = MAKE_EVENT(14, severity::MEDIUM);
virtual ~HasHealthIF() {}
virtual MessageQueueId_t getCommandQueue() const = 0;

View File

@ -1,9 +1,4 @@
#ifndef FSFW_INC_FSFW_HOUSEKEEPING_H_
#define FSFW_INC_FSFW_HOUSEKEEPING_H_
#pragma once
#include "src/core/housekeeping/HousekeepingMessage.h"
#include "src/core/housekeeping/HousekeepingPacketDownlink.h"
#include "src/core/housekeeping/HousekeepingSetPacket.h"
#include "src/core/housekeeping/HousekeepingSnapshot.h"
#endif /* FSFW_INC_FSFW_HOUSEKEEPING_H_ */
#include "fsfw/housekeeping/Dataset.h"
#include "fsfw/housekeeping/DatasetElement.h"

View File

@ -17,12 +17,6 @@ class Dataset : public SerializeIF {
[[nodiscard]] dp::structure_id_t getStructureId() const { return sid; }
void setAllChildrenValidity(bool valid) {
for (auto &serializable : serializables) {
serializable.get().setValid(valid);
}
}
void addSerializable(const std::reference_wrapper<SerializableWithValidityIF> serializable) {
serializables.push_back(serializable);
}
@ -95,11 +89,20 @@ class Dataset : public SerializeIF {
return SerializeIF::serialize(buffer, serSize, maxSize, streamEndianness);
}
void setChildrenValidity(bool valid) {
for (auto &serializable : serializables) {
serializable.get().setValid(valid);
}
}
[[nodiscard]] size_t getSerializedSize() const override {
size_t size = 0;
for (auto &serializable : serializables) {
size += serializable.get().getSerializedSize();
}
if (serializeWithValidityBlob) {
size += std::ceil(static_cast<float>(serializables.size()) / 8.0);
}
return size;
}

View File

@ -9,7 +9,6 @@
#include "fsfw/housekeeping/HousekeepingSnapshot.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/timemanager/CCSDSTime.h"
using namespace hk;
@ -17,7 +16,7 @@ PeriodicHelper::PeriodicHelper(GeneratesPeriodicHkIF* owner, MessageQueueIF* que
MessageQueueId_t hkDestQueue)
: hkDestinationId(hkDestQueue) {
if (owner == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "LocalDataPoolManager", returnvalue::FAILED,
printWarningOrError(sif::OutputTypes::OUT_WARNING, "PeriodicHkHelper", returnvalue::FAILED,
"Invalid supplied owner");
return;
}
@ -84,6 +83,7 @@ ReturnValue_t PeriodicHelper::performHkOperation() {
ReturnValue_t PeriodicHelper::handleHousekeepingMessage(CommandMessage* message) {
Command_t command = message->getCommand();
MessageQueueId_t sender = message->getSender();
dp::sid_t sid = HousekeepingMessage::getStructureId(message);
ReturnValue_t result = returnvalue::OK;
switch (command) {
@ -113,7 +113,7 @@ ReturnValue_t PeriodicHelper::handleHousekeepingMessage(CommandMessage* message)
}
case (HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT): {
return generateHousekeepingPacket(HousekeepingMessage::getStructureId(message));
return generateHousekeepingPacket(HousekeepingMessage::getStructureId(message), sender);
}
default:
@ -200,11 +200,10 @@ void PeriodicHelper::performPeriodicHkGeneration(SetSpecification& setSpec, time
if (result != returnvalue::OK) {
// Configuration error
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalDataPoolManager::performPeriodicHkOperation: HK generation failed."
sif::warning << "hk::PeriodicHelper::performPeriodicHkOperation: HK generation failed."
<< std::endl;
#else
sif::printWarning(
"LocalDataPoolManager::performPeriodicHkOperation: HK generation failed.\n");
sif::printWarning("hk::PeriodicHelper::performPeriodicHkOperation: HK generation failed.\n");
#endif
return;
}

View File

@ -5,6 +5,7 @@
#include "FreeRTOS.h"
#include "fsfw/globalfunctions/timevalOperations.h"
#include "fsfw/serviceinterface/ServiceInterfacePrinter.h"
#include "fsfw/osal/freertos/Timekeeper.h"
#include "task.h"
@ -47,8 +48,8 @@ ReturnValue_t Clock::getClock(timeval* time) {
}
ReturnValue_t Clock::getClockMonotonic(timeval* time) {
// TODO: I don't actually know if the timekeeper is monotonic..
return getClock_timeval(time);
*time = Timekeeper::instance()->getMonotonicClockOffset() + getUptime();
return returnvalue::OK;
}
ReturnValue_t Clock::getUptime(timeval* uptime) {
@ -58,7 +59,7 @@ ReturnValue_t Clock::getUptime(timeval* uptime) {
}
timeval Clock::getUptime() {
TickType_t ticksSinceStart = xTaskGetTickCount();
TickType_t ticksSinceStart = Timekeeper::instance()->getTicks();
return Timekeeper::ticksToTimeval(ticksSinceStart);
}

View File

@ -17,7 +17,13 @@ Timekeeper* Timekeeper::instance() {
return myinstance;
}
void Timekeeper::setOffset(const timeval& offset) { this->offset = offset; }
void Timekeeper::setOffset(const timeval& offset) {
if (not monotonicClockInitialized) {
this->monotonicClockOffset = offset;
monotonicClockInitialized = true;
}
this->offset = offset;
}
timeval Timekeeper::ticksToTimeval(TickType_t ticks) {
timeval uptime;
@ -33,3 +39,7 @@ timeval Timekeeper::ticksToTimeval(TickType_t ticks) {
}
TickType_t Timekeeper::getTicks() { return xTaskGetTickCount(); }
const timeval Timekeeper::getMonotonicClockOffset() const {
return monotonicClockOffset;
}

View File

@ -18,9 +18,14 @@ class Timekeeper {
Timekeeper();
timeval offset;
// Set when offset is initialized the first time
timeval monotonicClockOffset;
bool monotonicClockInitialized = false;
static Timekeeper* myinstance;
void setMonotonicClockOffset(const timeval& monotonicClockOffset);
public:
static Timekeeper* instance();
virtual ~Timekeeper();
@ -34,6 +39,7 @@ class Timekeeper {
const timeval& getOffset() const;
void setOffset(const timeval& offset);
const timeval getMonotonicClockOffset() const;
};
#endif /* FRAMEWORK_OSAL_FREERTOS_TIMEKEEPER_H_ */

View File

@ -49,7 +49,7 @@ class Service11TelecommandScheduling final : public PusServiceBase {
//! [EXPORT] : [COMMENT] Deletion of a TC from the map failed.
//! P1: First 32 bit of request ID, P2. Last 32 bit of Request ID
static constexpr Event TC_DELETION_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
static constexpr Event TC_DELETION_FAILED = event::makeEvent<SUBSYSTEM_ID, 0, severity::MEDIUM>();
// The types of PUS-11 subservices
enum Subservice : uint8_t {

View File

@ -53,17 +53,17 @@ void fsfwPrint(sif::PrintLevel printType, const char *fmt, va_list arg) {
#endif
if (printType == sif::PrintLevel::INFO_LEVEL) {
len += sprintf(bufferPosition + len, "INFO");
len += sprintf(bufferPosition + len, "INFO ");
}
if (printType == sif::PrintLevel::DEBUG_LEVEL) {
len += sprintf(bufferPosition + len, "DEBUG");
len += sprintf(bufferPosition + len, "DEBUG ");
}
if (printType == sif::PrintLevel::WARNING_LEVEL) {
len += sprintf(bufferPosition + len, "WARNING");
}
if (printType == sif::PrintLevel::ERROR_LEVEL) {
len += sprintf(bufferPosition + len, "ERROR");
len += sprintf(bufferPosition + len, "ERROR ");
}
#if FSFW_COLORED_OUTPUT == 1
@ -75,7 +75,7 @@ void fsfwPrint(sif::PrintLevel printType, const char *fmt, va_list arg) {
/*
* Log current time to terminal if desired.
*/
len += sprintf(bufferPosition + len, " | %lu:%02lu:%02lu.%03lu | ", (unsigned long)now.hour,
len += sprintf(bufferPosition + len, " | %02lu:%02lu:%02lu.%03lu | ", (unsigned long)now.hour,
(unsigned long)now.minute, (unsigned long)now.second,
(unsigned long)now.usecond / 1000);

View File

@ -78,23 +78,37 @@ void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter, Submod
submodeToCommand = targetSubmode;
}
if (healthHelper.healthTable->hasHealth(object)) {
if (healthHelper.healthTable->isFaulty(object)) {
if (healthHelper.healthTable->hasHealth(convertToDeviceObjectId(object))) {
switch (healthHelper.healthTable->getHealth(convertToDeviceObjectId(object))) {
case NEEDS_RECOVERY:
case FAULTY:
case PERMANENT_FAULTY:
ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND, HasModesIF::MODE_OFF,
SUBMODE_NONE);
} else {
break;
case HEALTHY:
if (modeHelper.isForced()) {
ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND_FORCED,
tableIter.value->getMode(), submodeToCommand);
} else {
if (healthHelper.healthTable->isCommandable(object)) {
ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND,
tableIter.value->getMode(), submodeToCommand);
}
break;
case EXTERNAL_CONTROL:
if (modeHelper.isForced()) {
ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND_FORCED,
tableIter.value->getMode(), submodeToCommand);
} else {
continue;
}
break;
default:
// This never happens
break;
}
}
} else {
ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND,
tableIter.value->getMode(), submodeToCommand);
@ -339,3 +353,7 @@ ReturnValue_t SubsystemBase::registerChild(object_id_t childObjectId, MessageQue
}
return returnvalue::OK;
}
object_id_t SubsystemBase::convertToDeviceObjectId(object_id_t id) {
return id;
}

View File

@ -153,6 +153,12 @@ class SubsystemBase : public SystemObject,
virtual void announceMode(bool recursive) override;
virtual void modeChanged();
/**
* @brief Provides an adaptation point for the user to change an objectId into
* a different objectId.
*/
virtual object_id_t convertToDeviceObjectId(object_id_t id);
};
#endif /* FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_ */

View File

@ -25,7 +25,7 @@ static constexpr ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE(11)
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TMTC_DISTRIBUTION;
//! P1: Returnvalue, P2: 0 for TM issues, 1 for TC issues
static constexpr Event HANDLE_PACKET_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW);
static constexpr Event HANDLE_PACKET_FAILED = event::makeEvent<SUBSYSTEM_ID, 0, severity::LOW>();
}; // namespace tmtcdistrib
#endif // FSFW_TMTCPACKET_DEFINITIONS_H

View File

@ -142,7 +142,7 @@ class TemperatureSensor : public AbstractTemperatureSensor {
deltaTime = (uptime.tv_sec + uptime.tv_usec / 1000000.) -
(uptimeOfOldTemperature.tv_sec + uptimeOfOldTemperature.tv_usec / 1000000.);
deltaTemp = oldTemperature - outputTemperature;
deltaTemp = oldTemperature - outputTemperature.value;
if (deltaTemp < 0) {
deltaTemp = -deltaTemp;
}
@ -160,13 +160,13 @@ class TemperatureSensor : public AbstractTemperatureSensor {
outputTemperature.setValid(PoolVariableIF::INVALID);
outputTemperature = thermal::INVALID_TEMPERATURE;
} else {
oldTemperature = outputTemperature;
oldTemperature = outputTemperature.value;
uptimeOfOldTemperature = uptime;
}
}
public:
float getTemperature() { return outputTemperature; }
float getTemperature() { return outputTemperature.value; }
bool isValid() { return outputTemperature.isValid(); }

View File

@ -192,6 +192,8 @@ class Clock {
static MutexIF *timeMutex;
static uint16_t leapSeconds;
static bool leapSecondsSet;
static bool monotonicClockInitialized;
static timeval monotonicClockOffset;
};
#endif /* FSFW_TIMEMANAGER_CLOCK_H_ */

View File

@ -114,6 +114,11 @@ void TmStoreMessage::setDownlinkContentTimeMessage(CommandMessage* cmd, store_ad
cmd->setParameter2(storeId.raw);
}
void TmStoreMessage::setStopDownlinkContentMessage(CommandMessage* cmd, store_address_t storeId) {
cmd->setCommand(STOP_DOWNLINK_STORE_CONTENT);
cmd->setParameter2(storeId.raw);
}
uint32_t TmStoreMessage::getAddressLow(CommandMessage* cmd) { return cmd->getParameter(); }
uint32_t TmStoreMessage::getAddressHigh(CommandMessage* cmd) { return cmd->getParameter2(); }

View File

@ -21,6 +21,7 @@ class TmStoreMessage {
static void setStoreCatalogueReportMessage(CommandMessage* cmd, object_id_t objectId,
store_address_t storeId);
static void setDownlinkContentTimeMessage(CommandMessage* cmd, store_address_t storeId);
static void setStopDownlinkContentMessage(CommandMessage* cmd, store_address_t storeId);
static void setIndexReportMessage(CommandMessage* cmd, store_address_t storeId);
static ReturnValue_t setDeleteBlocksMessage(CommandMessage* cmd, uint32_t addressLow,
uint32_t addressHigh);
@ -54,6 +55,7 @@ class TmStoreMessage {
static const Command_t DOWNLINK_STORE_CONTENT_BLOCKS = MAKE_COMMAND_ID(12);
static const Command_t REPORT_INDEX_REQUEST = MAKE_COMMAND_ID(13);
static const Command_t INDEX_REPORT = MAKE_COMMAND_ID(14);
static const Command_t STOP_DOWNLINK_STORE_CONTENT = MAKE_COMMAND_ID(15);
private:
TmStoreMessage();

View File

@ -62,6 +62,7 @@ TEST_CASE("Pool Dataset Test", "[datapool]") {
size_t serLen = 0;
uint8_t* dataPtr = buf;
dataset.serializeWithValidityBlob = true;
CHECK(dataset.getSerializedSize() == 6);
CHECK(dataset.serialize(&dataPtr, &serLen, sizeof(buf), SerializeIF::Endianness::NETWORK) ==
returnvalue::OK);
CHECK(buf[5] == 0b11000000);
@ -70,7 +71,7 @@ TEST_CASE("Pool Dataset Test", "[datapool]") {
SECTION("Larger Pool Dataset Serialization With Validity") {
uint8_t buf[64]{};
TestDatasetLarger datasetLarge;
datasetLarge.setAllChildrenValidity(true);
datasetLarge.setChildrenValidity(true);
size_t serLen = 0;
uint8_t* dataPtr = buf;
datasetLarge.serializeWithValidityBlob = true;

View File

@ -23,6 +23,7 @@ TEST_CASE("DataSetTest", "[datapool]") {
SECTION("BasicTest") {
/* Test some basic functions */
CHECK(localSet.getReportingEnabled() == false);
CHECK(localSet.getSerializedSize() == 11);
CHECK(localSet.getLocalPoolIdsSerializedSize() == 3 * sizeof(dp::id_t));
CHECK(localSet.getStructureId() == lpool::testSid1);
CHECK(localSet.getCreatorObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE);
@ -156,7 +157,7 @@ TEST_CASE("DataSetTest", "[datapool]") {
}
SECTION("Serialize with Validity Blob") {
localSet.serializeWithValidityBlob = true;
localSet.updateValidityBlobSerialization(true);
CHECK(!localSet.localPoolVarUint8.isValid());
CHECK(!localSet.localPoolUint16Vec.isValid());
CHECK(!localSet.localPoolVarFloat.isValid());
@ -168,6 +169,7 @@ TEST_CASE("DataSetTest", "[datapool]") {
// Already reserve additional space for validity buffer, will be needed later
uint8_t buffer[128]{};
uint8_t* buffPtr = buffer;
CHECK(localSet.getSerializedSize() == 12);
CHECK(localSet.serialize(&buffPtr, &serSize, sizeof(buffer),
SerializeIF::Endianness::MACHINE) == returnvalue::OK);
CHECK(serSize == 12);