diff --git a/misc/archive/MgmRM3100Handler.h b/misc/archive/MgmRM3100Handler.h index c118bcd5..ec75c5be 100644 --- a/misc/archive/MgmRM3100Handler.h +++ b/misc/archive/MgmRM3100Handler.h @@ -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(); //! [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(); MgmRM3100Handler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, uint32_t transitionDelay); diff --git a/src/fsfw/cfdp/handler/defs.h b/src/fsfw/cfdp/handler/defs.h index 6a668602..e1d88247 100644 --- a/src/fsfw/cfdp/handler/defs.h +++ b/src/fsfw/cfdp/handler/defs.h @@ -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(); +static constexpr Event SERIALIZATION_ERROR = event::makeEvent(); +static constexpr Event FILESTORE_ERROR = event::makeEvent(); //! [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(); //! [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(); } // namespace events static constexpr ReturnValue_t SOURCE_TRANSACTION_PENDING = returnvalue::makeCode(CID, 0); diff --git a/src/fsfw/datapool/PoolVariable.h b/src/fsfw/datapool/PoolVariable.h index a6b82174..38bbd9ea 100644 --- a/src/fsfw/datapool/PoolVariable.h +++ b/src/fsfw/datapool/PoolVariable.h @@ -210,6 +210,7 @@ inline ReturnValue_t PoolVariable::readWithoutLock() { } this->value = *(poolEntry->getDataPtr()); + this->valid = poolEntry->getValid(); return returnvalue::OK; } @@ -241,6 +242,7 @@ ReturnValue_t PoolVariable::commitWithoutLock() { } *(poolEntry->getDataPtr()) = this->value; + poolEntry->setValid(this->valid); return returnvalue::OK; } diff --git a/src/fsfw/events/Event.h b/src/fsfw/events/Event.h index e48736bf..73a5fbbf 100644 --- a/src/fsfw/events/Event.h +++ b/src/fsfw/events/Event.h @@ -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 +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(); + #endif /* EVENTOBJECT_EVENT_H_ */ diff --git a/src/fsfw/housekeeping/Dataset.h b/src/fsfw/housekeeping/Dataset.h index a1788843..d48129c3 100644 --- a/src/fsfw/housekeeping/Dataset.h +++ b/src/fsfw/housekeeping/Dataset.h @@ -91,7 +91,7 @@ class Dataset : public SerializeIF { void setChildrenValidity(bool valid) { for (auto &serializable : serializables) { - serializable.get().setValid(true); + serializable.get().setValid(valid); } } diff --git a/src/fsfw/pus/Service11TelecommandScheduling.h b/src/fsfw/pus/Service11TelecommandScheduling.h index fd9cf733..84d91aca 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.h +++ b/src/fsfw/pus/Service11TelecommandScheduling.h @@ -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(); // The types of PUS-11 subservices enum Subservice : uint8_t { diff --git a/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp b/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp index 78d12a56..b83eda3c 100644 --- a/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp @@ -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); diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index 4f62a889..87fcfebf 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -79,22 +79,36 @@ void SubsystemBase::executeTable(HybridIterator tableIter, Submod } if (healthHelper.healthTable->hasHealth(object)) { - if (healthHelper.healthTable->isFaulty(object)) { - ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND, HasModesIF::MODE_OFF, - SUBMODE_NONE); - } else { - if (modeHelper.isForced()) { - ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND_FORCED, - tableIter.value->getMode(), submodeToCommand); - } else { - if (healthHelper.healthTable->isCommandable(object)) { + + switch (healthHelper.healthTable->getHealth(object)) { + case NEEDS_RECOVERY: + case FAULTY: + case PERMANENT_FAULTY: + ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND, HasModesIF::MODE_OFF, + SUBMODE_NONE); + break; + case HEALTHY: + if (modeHelper.isForced()) { + ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND_FORCED, + tableIter.value->getMode(), submodeToCommand); + } else { 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); diff --git a/src/fsfw/tcdistribution/definitions.h b/src/fsfw/tcdistribution/definitions.h index 04a7a4a5..d01e5e7e 100644 --- a/src/fsfw/tcdistribution/definitions.h +++ b/src/fsfw/tcdistribution/definitions.h @@ -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(); }; // namespace tmtcdistrib #endif // FSFW_TMTCPACKET_DEFINITIONS_H diff --git a/src/fsfw/thermal/TemperatureSensor.h b/src/fsfw/thermal/TemperatureSensor.h index 4cb2a083..cab44f4c 100644 --- a/src/fsfw/thermal/TemperatureSensor.h +++ b/src/fsfw/thermal/TemperatureSensor.h @@ -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(); }