From 963015513f8e8825deaa95a7cabafd878d4811f4 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 16 Sep 2020 19:36:15 +0200 Subject: [PATCH 1/2] added time stamper to framework --- timemanager/TimeStamper.cpp | 23 +++++++++++++++++++++++ timemanager/TimeStamper.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 timemanager/TimeStamper.cpp create mode 100644 timemanager/TimeStamper.h diff --git a/timemanager/TimeStamper.cpp b/timemanager/TimeStamper.cpp new file mode 100644 index 00000000..07c3530c --- /dev/null +++ b/timemanager/TimeStamper.cpp @@ -0,0 +1,23 @@ +#include +#include +#include + +TimeStamper::TimeStamper(object_id_t objectId): SystemObject(objectId) {} + + +ReturnValue_t TimeStamper::addTimeStamp(uint8_t* buffer, + const uint8_t maxSize) { + if(maxSize < TimeStamperIF::MISSION_TIMESTAMP_SIZE){ + return HasReturnvaluesIF::RETURN_FAILED; + } + + timeval now; + Clock::getClock_timeval(&now); + CCSDSTime::CDS_short cds; + ReturnValue_t result = CCSDSTime::convertToCcsds(&cds,&now); + if(result != HasReturnvaluesIF::RETURN_OK){ + return result; + } + memcpy(buffer,&cds,sizeof(cds)); + return result; +} diff --git a/timemanager/TimeStamper.h b/timemanager/TimeStamper.h new file mode 100644 index 00000000..80139c50 --- /dev/null +++ b/timemanager/TimeStamper.h @@ -0,0 +1,36 @@ +#ifndef FSFW_TIMEMANAGER_TIMESTAMPER_H_ +#define FSFW_TIMEMANAGER_TIMESTAMPER_H_ + +#include +#include +#include + +/** + * @brief Time stamper which can be used to add any timestamp to a + * given buffer. + * @details + * This time stamper uses the CCSDS CDC short timestamp as a fault timestamp. + * This timestamp has a size of 8 bytes. A custom timestamp can be used by + * overriding the #addTimeStamp function. + * @ingroup utility + */ +class TimeStamper: public TimeStamperIF, public SystemObject { +public: + /** + * @brief Default constructor which also registers the time stamper as a + * system object so it can be found with the #objectManager. + * @param objectId + */ + TimeStamper(object_id_t objectId); + + /** + * Adds a CCSDS CDC short 8 byte timestamp to the given buffer. + * This function can be overriden to use a custom timestamp. + * @param buffer + * @param maxSize + * @return + */ + virtual ReturnValue_t addTimeStamp(uint8_t* buffer, const uint8_t maxSize); +}; + +#endif /* FSFW_TIMEMANAGER_TIMESTAMPER_H_ */ From b0a816490e89c639e34849587eb4bc11d619b99f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 16 Sep 2020 19:37:17 +0200 Subject: [PATCH 2/2] fixed includes --- timemanager/TimeStamper.cpp | 6 +++--- timemanager/TimeStamper.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/timemanager/TimeStamper.cpp b/timemanager/TimeStamper.cpp index 07c3530c..d9f0f2f3 100644 --- a/timemanager/TimeStamper.cpp +++ b/timemanager/TimeStamper.cpp @@ -1,5 +1,5 @@ -#include -#include +#include "TimeStamper.h" +#include "Clock.h" #include TimeStamper::TimeStamper(object_id_t objectId): SystemObject(objectId) {} @@ -18,6 +18,6 @@ ReturnValue_t TimeStamper::addTimeStamp(uint8_t* buffer, if(result != HasReturnvaluesIF::RETURN_OK){ return result; } - memcpy(buffer,&cds,sizeof(cds)); + std::memcpy(buffer,&cds,sizeof(cds)); return result; } diff --git a/timemanager/TimeStamper.h b/timemanager/TimeStamper.h index 80139c50..6895c14b 100644 --- a/timemanager/TimeStamper.h +++ b/timemanager/TimeStamper.h @@ -1,9 +1,9 @@ #ifndef FSFW_TIMEMANAGER_TIMESTAMPER_H_ #define FSFW_TIMEMANAGER_TIMESTAMPER_H_ -#include -#include -#include +#include "TimeStamperIF.h" +#include "CCSDSTime.h" +#include "../objectmanager/SystemObject.h" /** * @brief Time stamper which can be used to add any timestamp to a