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/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/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