F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
LinuxTimerTaskDelay.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title LinuxTimerImpl.cpp
3 // \author tim
4 // \brief cpp file for LinuxTimer component implementation class
5 //
6 // \copyright
7 // Copyright 2009-2015, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
13 #include <Fw/FPrimeBasicTypes.hpp>
14 #include <Fw/Logger/Logger.hpp>
15 #include <Os/Task.hpp>
17 
18 namespace Svc {
19 
20 void LinuxTimer::startTimer(const Fw::TimeInterval& interval) {
21  while (true) {
22  Os::Task::delay(interval);
23  this->m_mutex.lock();
24  bool quit = this->m_quit;
25  this->m_mutex.unLock();
26  if (quit) {
27  return;
28  }
29  Os::RawTime::Status status = this->m_rawTime.now();
30  if ((status != Os::RawTime::OP_OK) && !this->m_rawTimeErrorLogged) {
31  // Latch the report so a persistent failure does not flood the console at the timer rate
32  this->m_rawTimeErrorLogged = true;
33  Fw::Logger::log("[ERROR] LinuxTimer failed to read raw time: %d\n", static_cast<I32>(status));
34  }
35  this->CycleOut_out(0, this->m_rawTime);
36  }
37 }
38 
39 } // end namespace Svc
void startTimer(const Fw::TimeInterval &interval)
Start timer.
Operation was successful.
Status now() override
Get the current time.
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:41
static void log(const char *format,...)
log a formated string with supplied arguments
Definition: Logger.cpp:21
void quit()
Quit timer.
static Status delay(const Fw::TimeInterval &interval)
delay the current task
Definition: Task.cpp:204
RateGroupDivider component implementation.
void CycleOut_out(FwIndexType portNum, Os::RawTime &cycleStart) const
Invoke output port CycleOut.
void lock()
lock the mutex and assert success
Definition: Mutex.cpp:34