| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * PosixTime.cpp | ||
| 3 | * | ||
| 4 | * Created on: Mar 28, 2014 | ||
| 5 | * Author: tcanham | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include <Fw/Time/Time.hpp> | ||
| 9 | #include <Svc/PosixTime/PosixTime.hpp> | ||
| 10 | #include <ctime> | ||
| 11 | |||
| 12 | namespace Svc { | ||
| 13 | |||
| 14 | 2 | PosixTime::PosixTime(const char* name) : PosixTimeComponentBase(name), m_timeContext(0) {} | |
| 15 | |||
| 16 | 4 | PosixTime::~PosixTime() {} | |
| 17 | |||
| 18 | 1 | void PosixTime::setTimeContext(FwTimeContextStoreType timeContext) { | |
| 19 | 1 | this->m_timeContext = timeContext; | |
| 20 | 1 | } | |
| 21 | |||
| 22 | 2 | void PosixTime::timeGetPort_handler(FwIndexType portNum, /*!< The port number*/ | |
| 23 | Fw::Time& time /*!< The U32 cmd argument*/ | ||
| 24 | ) { | ||
| 25 | 2 | timespec stime = {}; | |
| 26 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
|
2 | if (clock_gettime(CLOCK_REALTIME, &stime) != 0) { |
| 27 | // report zero time rather than uninitialized garbage | ||
| 28 | ✗ | stime.tv_sec = 0; | |
| 29 | ✗ | stime.tv_nsec = 0; | |
| 30 | } | ||
| 31 |
2/2✓ Branch 8 taken 2 times.
✓ Branch 11 taken 2 times.
|
4 | time.set(TimeBase::TB_WORKSTATION_TIME, this->m_timeContext, static_cast<U32>(stime.tv_sec), |
| 32 | 2 | static_cast<U32>(stime.tv_nsec / 1000)); | |
| 33 | 2 | } | |
| 34 | } // namespace Svc | ||
| 35 |