From a229748aa4c1ff8e2b9f7e268259b857fb8f9051 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Apr 2024 10:57:00 +0200 Subject: [PATCH] distinct clock dump events --- src/fsfw/pus/Service9TimeManagement.cpp | 23 +++++++++-------------- src/fsfw/pus/Service9TimeManagement.h | 6 ++++-- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index cbc9bd55..e8e24f42 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -18,18 +18,13 @@ ReturnValue_t Service9TimeManagement::performService() { return returnvalue::OK; ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { switch (subservice) { case Subservice::SET_TIME: { - reportCurrentTime(); + reportCurrentTime(CLOCK_DUMP_BEFORE_SETTING_TIME); ReturnValue_t result = setTime(); - reportCurrentTime(); + reportCurrentTime(CLOCK_DUMP_AFTER_SETTING_TIME); return result; } case Subservice::DUMP_TIME: { - timeval newTime; - ReturnValue_t result = Clock::getClock_timeval(&newTime); - if (result != returnvalue::OK) { - return result; - } - triggerEvent(CLOCK_DUMP, newTime.tv_sec, newTime.tv_usec); + reportCurrentTime(); return returnvalue::OK; } case Subservice::RELATIVE_TIMESHIFT: { @@ -38,7 +33,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { if (result != returnvalue::OK) { return result; } - reportTime(currentTime); + reportTime(CLOCK_DUMP_BEFORE_SETTING_TIME, currentTime); if (currentPacket.getUserDataLen() != 8) { return AcceptsTelecommandsIF::ILLEGAL_APPLICATION_DATA; @@ -66,7 +61,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { } result = Clock::setClock(&newTime); if (result == returnvalue::OK) { - reportTime(newTime); + reportTime(CLOCK_DUMP_AFTER_SETTING_TIME, newTime); } return result; } @@ -93,12 +88,12 @@ ReturnValue_t Service9TimeManagement::setTime() { return result; } -void Service9TimeManagement::reportCurrentTime() { +void Service9TimeManagement::reportCurrentTime(Event event) { timeval currentTime{}; Clock::getClock(¤tTime); - triggerEvent(CLOCK_DUMP, currentTime.tv_sec, currentTime.tv_usec); + triggerEvent(event, currentTime.tv_sec, currentTime.tv_usec); } -void Service9TimeManagement::reportTime(timeval time) { - triggerEvent(CLOCK_DUMP, time.tv_sec, time.tv_usec); +void Service9TimeManagement::reportTime(Event event, timeval time) { + triggerEvent(event, time.tv_sec, time.tv_usec); } diff --git a/src/fsfw/pus/Service9TimeManagement.h b/src/fsfw/pus/Service9TimeManagement.h index 75328bf4..502136c2 100644 --- a/src/fsfw/pus/Service9TimeManagement.h +++ b/src/fsfw/pus/Service9TimeManagement.h @@ -18,6 +18,8 @@ class Service9TimeManagement : public PusServiceBase { static constexpr Event CLOCK_SET_FAILURE = MAKE_EVENT(2, severity::LOW); //!< [EXPORT] : [COMMENT] Clock dump event. P1: timeval seconds P2: timeval microseconds. static constexpr Event CLOCK_DUMP = MAKE_EVENT(3, severity::INFO); + static constexpr Event CLOCK_DUMP_BEFORE_SETTING_TIME = MAKE_EVENT(4, severity::INFO); + static constexpr Event CLOCK_DUMP_AFTER_SETTING_TIME = MAKE_EVENT(5, severity::INFO); static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_9; @@ -35,8 +37,8 @@ class Service9TimeManagement : public PusServiceBase { */ ReturnValue_t handleRequest(uint8_t subservice) override; - void reportCurrentTime(); - void reportTime(timeval time); + void reportCurrentTime(Event eventType = CLOCK_DUMP); + void reportTime(Event event, timeval time); virtual ReturnValue_t setTime();