added time stamper to framework

This commit is contained in:
Robin Müller 2020-09-16 19:36:15 +02:00
parent 42bfedd36c
commit 963015513f
2 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,23 @@
#include <fsfw/timemanager/Clock.h>
#include <fsfw/timemanager/TimeStamper.h>
#include <cstring>
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;
}

36
timemanager/TimeStamper.h Normal file
View File

@ -0,0 +1,36 @@
#ifndef FSFW_TIMEMANAGER_TIMESTAMPER_H_
#define FSFW_TIMEMANAGER_TIMESTAMPER_H_
#include <fsfw/timemanager/TimeStamperIF.h>
#include <fsfw/timemanager/CCSDSTime.h>
#include <fsfw/objectmanager/SystemObject.h>
/**
* @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_ */