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 
15 #include <Fw/FPrimeBasicTypes.hpp>
16 #include <Os/Task.hpp>
17 
18 namespace Svc {
19 
20  void LinuxTimer::startTimer(FwSizeType interval) {
21  FW_ASSERT(std::numeric_limits<U32>::max()/1000 >= interval); // Overflow
22  while (true) {
23  Os::Task::delay(Fw::TimeInterval(static_cast<U32>(interval/1000), static_cast<U32>((interval % 1000) * 1000)));
24  this->m_mutex.lock();
25  bool quit = this->m_quit;
26  this->m_mutex.unLock();
27  if (quit) {
28  return;
29  }
30  this->m_rawTime.now();
31  this->CycleOut_out(0,this->m_rawTime);
32  }
33  }
34 
35 } // end namespace Svc
static Status delay(Fw::TimeInterval interval)
delay the current task
Definition: Task.cpp:191
PlatformSizeType FwSizeType
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:40
Status now() override
Get the current time.
Definition: RawTime.cpp:36
void CycleOut_out(FwIndexType portNum, Os::RawTime &cycleStart)
Invoke output port CycleOut.
void quit()
Quit timer.
void startTimer(FwSizeType interval)
Start timer.
RateGroupDivider component implementation.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void lock()
lock the mutex and assert success
Definition: Mutex.cpp:34