diff --git a/inc/Message.hpp b/inc/Message.hpp index d77a1e990c1c6e5e00096062dee641322c6ee248..be03a417e01d4843b721842bdd81982aabe953c1 100644 --- a/inc/Message.hpp +++ b/inc/Message.hpp @@ -535,6 +535,16 @@ public: return reinterpret_cast<double&>(value); } + /** + * Fetches a timestamp in a custom CUC format consisting of 8 bytes from the current position in the message + */ + Time::CustomCUC_t readCustomCUCTimeStamp() { + Time::CustomCUC_t customCUC_t; + + customCUC_t.elapsed100msTicks = readUint64(); + return customCUC_t; + } + /** * Fetches a N-byte string from the current position in the message * @@ -744,5 +754,9 @@ template <> inline double Message::read() { return readDouble(); } +template <> +inline Time::CustomCUC_t Message::read() { + return readCustomCUCTimeStamp(); +} #endif // ECSS_SERVICES_PACKET_H diff --git a/test/Message.cpp b/test/Message.cpp index 619b6be89c410649c20fed6a0f5af4ca2511021d..43cabf15d673b76fd040cbae7fb8281705a99750 100644 --- a/test/Message.cpp +++ b/test/Message.cpp @@ -188,6 +188,21 @@ TEST_CASE("Append a CUC timestamp") { } } +TEST_CASE("Read a CUC timestamp") { + /** + * Append a custom CUC Time Stamp to a message object and check if is it read corretly + */ + Time::CustomCUC_t timeCUC; + timeCUC.elapsed100msTicks = 34511; + + Message message(0, 0, Message::TC, 0); + message.appendCustomCUCTimeStamp(timeCUC); + + auto returnTimeCUC = message.readCustomCUCTimeStamp(); + + REQUIRE(returnTimeCUC.elapsed100msTicks == 34511); +} + TEST_CASE("Requirement 7.3.8 (Octet-string)", "[message][ecss]") { Message message(0, 0, Message::TC, 0);