switched to new tmtc stack API
This commit is contained in:
@ -14,14 +14,15 @@
|
||||
* overriding the #addTimeStamp function.
|
||||
* @ingroup utility
|
||||
*/
|
||||
class TimeStamper : public TimeStamperIF, public SystemObject {
|
||||
class CdsShortTimeStamper : public TimeStamperIF, public SystemObject {
|
||||
public:
|
||||
static constexpr size_t TIMESTAMP_LEN = 7;
|
||||
/**
|
||||
* @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);
|
||||
explicit CdsShortTimeStamper(object_id_t objectId);
|
||||
|
||||
/**
|
||||
* Adds a CCSDS CDC short 8 byte timestamp to the given buffer.
|
||||
@ -30,7 +31,13 @@ class TimeStamper : public TimeStamperIF, public SystemObject {
|
||||
* @param maxSize
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t addTimeStamp(uint8_t* buffer, const uint8_t maxSize);
|
||||
ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override;
|
||||
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const override;
|
||||
size_t getSerializedSize() const override;
|
||||
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) override;
|
||||
size_t getTimestampSize() const override;
|
||||
};
|
||||
|
||||
#endif /* FSFW_TIMEMANAGER_TIMESTAMPER_H_ */
|
@ -1,23 +1,35 @@
|
||||
#include "fsfw/timemanager/TimeStamper.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/timemanager/CdsShortTimeStamper.h"
|
||||
#include "fsfw/timemanager/Clock.h"
|
||||
|
||||
TimeStamper::TimeStamper(object_id_t objectId) : SystemObject(objectId) {}
|
||||
CdsShortTimeStamper::CdsShortTimeStamper(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;
|
||||
ReturnValue_t CdsShortTimeStamper::addTimeStamp(uint8_t *buffer, const uint8_t maxSize) {
|
||||
size_t serLen = 0;
|
||||
return serialize(&buffer, &serLen, maxSize, SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
|
||||
ReturnValue_t CdsShortTimeStamper::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const {
|
||||
if (*size + getSerializedSize() > maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
|
||||
timeval now;
|
||||
timeval now{};
|
||||
Clock::getClock_timeval(&now);
|
||||
CCSDSTime::CDS_short cds;
|
||||
CCSDSTime::CDS_short cds{};
|
||||
ReturnValue_t result = CCSDSTime::convertToCcsds(&cds, &now);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(buffer, &cds, sizeof(cds));
|
||||
std::memcpy(*buffer, &cds, sizeof(cds));
|
||||
*buffer += getSerializedSize();
|
||||
*size += getSerializedSize();
|
||||
return result;
|
||||
}
|
||||
size_t CdsShortTimeStamper::getSerializedSize() const { return getTimestampSize(); }
|
||||
ReturnValue_t CdsShortTimeStamper::deSerialize(const uint8_t **buffer, size_t *size,
|
||||
SerializeIF::Endianness streamEndianness) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
size_t CdsShortTimeStamper::getTimestampSize() const { return TIMESTAMP_LEN; }
|
||||
|
@ -1,9 +1,8 @@
|
||||
#ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||
#define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/serialize/SerializeIF.h"
|
||||
|
||||
/**
|
||||
* A class implementing this IF provides facilities to add a time stamp to the
|
||||
@ -11,17 +10,21 @@
|
||||
* Implementors need to ensure that calling the method is thread-safe, i.e.
|
||||
* addTimeStamp may be called in parallel from a different context.
|
||||
*/
|
||||
class TimeStamperIF {
|
||||
class TimeStamperIF : public SerializeIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::TIME_STAMPER_IF;
|
||||
static const ReturnValue_t BAD_TIMESTAMP = MAKE_RETURN_CODE(1);
|
||||
|
||||
// I am going to assume there are no larger timestamps
|
||||
static constexpr size_t MAXIMUM_TIMESTAMP_LEN = 16;
|
||||
|
||||
//! This is a mission-specific constant and determines the total
|
||||
//! size reserved for timestamps.
|
||||
static const uint8_t MISSION_TIMESTAMP_SIZE = fsfwconfig::FSFW_MISSION_TIMESTAMP_SIZE;
|
||||
// static const uint8_t MISSION_TIMESTAMP_SIZE = fsfwconfig::FSFW_MISSION_TIMESTAMP_SIZE;
|
||||
|
||||
virtual ReturnValue_t addTimeStamp(uint8_t* buffer, const uint8_t maxSize) = 0;
|
||||
virtual ~TimeStamperIF() {}
|
||||
[[nodiscard]] virtual size_t getTimestampSize() const = 0;
|
||||
virtual ReturnValue_t addTimeStamp(uint8_t* buffer, uint8_t maxSize) = 0;
|
||||
~TimeStamperIF() override = default;
|
||||
};
|
||||
|
||||
#endif /* FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ */
|
||||
|
Reference in New Issue
Block a user