GCC Code Coverage Report


Directory: lib/fprime-samd/fprime-samd/
File: Drv/RtcDriver/RawTime.cpp
Date: 2026-09-26 00:05:09
Exec Total Coverage
Lines: 0 34 0.0%
Functions: 0 6 0.0%
Branches: 0 16 0.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title Samd21/Drv/RtcDriver/RawTime.cpp
3 // \brief Realtime clock implementation for Os::RawTime
4 // ======================================================================
5 #include "fprime-samd/Drv/RtcDriver/RawTime.hpp"
6 namespace Os {
7 namespace Samd21 {
8
9 //! \brief check is a is newer than b
10 ✗ bool isNewer(const Samd21RawTimeHandle& a, const Samd21RawTimeHandle& b) {
11 ✗ if (a.m_seconds > b.m_seconds) {
12 ✗ return true;
13 ✗ } else if (a.m_seconds == b.m_seconds) {
14 ✗ return a.m_micros > b.m_micros;
15 } else {
16 ✗ return false;
17 }
18 }
19
20 ✗ RawTimeHandle* Samd21RawTime::getHandle() {
21 ✗ return &this->m_handle;
22 }
23
24 ✗ RawTime::Status Samd21RawTime::now() {
25 ✗ auto now = timeNow();
26 ✗ this->m_handle = now;
27 ✗ return Status::OP_OK;
28 }
29
30 ✗ RawTime::Status Samd21RawTime::getTimeInterval(const Os::RawTime& other, Fw::TimeInterval& interval) const {
31 ✗ interval.set(0, 0);
32 ✗ const Samd21RawTimeHandle& my_handle = this->m_handle;
33 const Samd21RawTimeHandle& other_handle =
34 ✗ static_cast<const Samd21RawTimeHandle&>(*const_cast<Os::RawTime&>(other).getHandle());
35
36 ✗ const Samd21RawTimeHandle& newer = isNewer(my_handle, other_handle) ? my_handle : other_handle;
37 ✗ const Samd21RawTimeHandle& older = isNewer(my_handle, other_handle) ? other_handle : my_handle;
38
39 ✗ if (newer.m_micros < older.m_micros) {
40 ✗ interval.set(newer.m_seconds - older.m_seconds - 1, 1000000 + newer.m_micros - older.m_micros);
41 } else {
42 ✗ interval.set(newer.m_seconds - older.m_seconds, newer.m_micros - older.m_micros);
43 }
44
45 ✗ return Status::OP_OK;
46 }
47
48 ✗ Fw::SerializeStatus Samd21RawTime::serializeTo(Fw::SerialBufferBase& buffer, Fw::Endianness mode) const {
49 ✗ Fw::SerializeStatus status = Fw::SerializeStatus::FW_SERIALIZE_OK;
50 ✗ status = buffer.serializeFrom(this->m_handle.m_seconds, mode);
51 ✗ if (status == Fw::FW_SERIALIZE_OK) {
52 ✗ status = buffer.serializeFrom(this->m_handle.m_micros, mode);
53 }
54 ✗ return status;
55 }
56
57 ✗ Fw::SerializeStatus Samd21RawTime::deserializeFrom(Fw::SerialBufferBase& buffer, Fw::Endianness mode) {
58 ✗ Fw::SerializeStatus status = Fw::SerializeStatus::FW_SERIALIZE_OK;
59 ✗ status = buffer.deserializeTo(this->m_handle.m_seconds, mode);
60 ✗ if (status == Fw::FW_SERIALIZE_OK) {
61 ✗ status = buffer.deserializeTo(this->m_handle.m_micros, mode);
62 }
63 ✗ return status;
64 }
65 } // namespace Samd21
66 } // namespace Os
67