From ddac936a2cc33b83792e14c73bf680256fff3720 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 16 Aug 2021 10:59:28 +0200 Subject: [PATCH 1/2] adds some utility to linux timer --- src/fsfw/osal/linux/Timer.cpp | 12 ++++++++++++ src/fsfw/osal/linux/Timer.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/fsfw/osal/linux/Timer.cpp b/src/fsfw/osal/linux/Timer.cpp index dca3112d..899ca4a5 100644 --- a/src/fsfw/osal/linux/Timer.cpp +++ b/src/fsfw/osal/linux/Timer.cpp @@ -27,6 +27,7 @@ int Timer::setTimer(uint32_t intervalMs) { timer.it_value.tv_nsec = (intervalMs * 1000000) % (1000000000); timer.it_interval.tv_sec = 0; timer.it_interval.tv_nsec = 0; + set = true; return timer_settime(timerId, 0, &timer, NULL); } @@ -43,3 +44,14 @@ int Timer::getTimer(uint32_t* remainingTimeMs){ return status; } + +bool Timer::isSet() const { + return this->set; +} + +void Timer::resetTimer() { + if(not this->set) { + set = false; + } + setTimer(0); +} diff --git a/src/fsfw/osal/linux/Timer.h b/src/fsfw/osal/linux/Timer.h index f94bca59..6d8c1b9e 100644 --- a/src/fsfw/osal/linux/Timer.h +++ b/src/fsfw/osal/linux/Timer.h @@ -38,7 +38,11 @@ public: */ int getTimer(uint32_t* remainingTimeMs); + bool isSet() const; + void resetTimer(); + private: + bool set = true; timer_t timerId; }; From 9e36bbc11ddb7a548a2b8705d87226f4a6d1c44c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 16 Aug 2021 11:02:36 +0200 Subject: [PATCH 2/2] small bugfix --- src/fsfw/osal/linux/Timer.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/fsfw/osal/linux/Timer.cpp b/src/fsfw/osal/linux/Timer.cpp index 899ca4a5..7b11e7d3 100644 --- a/src/fsfw/osal/linux/Timer.cpp +++ b/src/fsfw/osal/linux/Timer.cpp @@ -50,8 +50,6 @@ bool Timer::isSet() const { } void Timer::resetTimer() { - if(not this->set) { - set = false; - } + set = false; setTimer(0); }