From 336b43572f1bb928be5475c2eabebdfa6d53a587 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Dec 2020 21:46:33 +0100 Subject: [PATCH 1/2] linux update --- ipc/MutexFactory.h | 6 +++--- osal/linux/BinarySemaphore.cpp | 2 +- osal/linux/Clock.cpp | 14 +++++++------- osal/linux/MessageQueue.cpp | 1 + osal/linux/Mutex.h | 5 ++--- osal/linux/MutexFactory.cpp | 3 ++- osal/linux/PosixThread.cpp | 10 +++++++--- osal/linux/SemaphoreFactory.cpp | 3 ++- osal/linux/TaskFactory.cpp | 1 + osal/linux/Timer.cpp | 3 ++- tasks/TaskFactory.h | 8 ++++---- 11 files changed, 32 insertions(+), 24 deletions(-) diff --git a/ipc/MutexFactory.h b/ipc/MutexFactory.h index f8133d81..db505ff9 100644 --- a/ipc/MutexFactory.h +++ b/ipc/MutexFactory.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_IPC_MUTEXFACTORY_H_ -#define FRAMEWORK_IPC_MUTEXFACTORY_H_ +#ifndef FSFW_IPC_MUTEXFACTORY_H_ +#define FSFW_IPC_MUTEXFACTORY_H_ #include "MutexIF.h" /** @@ -31,4 +31,4 @@ private: -#endif /* FRAMEWORK_IPC_MUTEXFACTORY_H_ */ +#endif /* FSFW_IPC_MUTEXFACTORY_H_ */ diff --git a/osal/linux/BinarySemaphore.cpp b/osal/linux/BinarySemaphore.cpp index 8c0eeae7..b81fa109 100644 --- a/osal/linux/BinarySemaphore.cpp +++ b/osal/linux/BinarySemaphore.cpp @@ -1,4 +1,4 @@ -#include "../../osal/linux/BinarySemaphore.h" +#include "BinarySemaphore.h" #include "../../serviceinterface/ServiceInterfaceStream.h" extern "C" { diff --git a/osal/linux/Clock.cpp b/osal/linux/Clock.cpp index 4de18f83..6cddda35 100644 --- a/osal/linux/Clock.cpp +++ b/osal/linux/Clock.cpp @@ -76,25 +76,25 @@ timeval Clock::getUptime() { ReturnValue_t Clock::getUptime(timeval* uptime) { //TODO This is not posix compatible and delivers only seconds precision - // is the OS not called Linux? - //Linux specific file read but more precise + // Linux specific file read but more precise. double uptimeSeconds; if(std::ifstream("/proc/uptime",std::ios::in) >> uptimeSeconds){ uptime->tv_sec = uptimeSeconds; uptime->tv_usec = uptimeSeconds *(double) 1e6 - (uptime->tv_sec *1e6); } + return HasReturnvaluesIF::RETURN_OK; +} - //TODO This is not posix compatible and delivers only seconds precision - // I suggest this is moved into another clock function which will - // deliver second precision later. +// Wait for new FSFW Clock function delivering seconds uptime. +//uint32_t Clock::getUptimeSeconds() { +// //TODO This is not posix compatible and delivers only seconds precision // struct sysinfo sysInfo; // int result = sysinfo(&sysInfo); // if(result != 0){ // return HasReturnvaluesIF::RETURN_FAILED; // } // return sysInfo.uptime; - return HasReturnvaluesIF::RETURN_OK; -} +//} ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { timeval uptime; diff --git a/osal/linux/MessageQueue.cpp b/osal/linux/MessageQueue.cpp index bc14374a..cfadb793 100644 --- a/osal/linux/MessageQueue.cpp +++ b/osal/linux/MessageQueue.cpp @@ -3,6 +3,7 @@ #include "../../objectmanager/ObjectManagerIF.h" #include + #include /* For O_* constants */ #include /* For mode constants */ #include diff --git a/osal/linux/Mutex.h b/osal/linux/Mutex.h index ecb47a33..cfce407f 100644 --- a/osal/linux/Mutex.h +++ b/osal/linux/Mutex.h @@ -1,10 +1,9 @@ -#ifndef OS_LINUX_MUTEX_H_ -#define OS_LINUX_MUTEX_H_ +#ifndef FSFW_OSAL_LINUX_MUTEX_H_ +#define FSFW_OSAL_LINUX_MUTEX_H_ #include "../../ipc/MutexIF.h" #include - class Mutex : public MutexIF { public: Mutex(); diff --git a/osal/linux/MutexFactory.cpp b/osal/linux/MutexFactory.cpp index 8c2faf88..80211f8b 100644 --- a/osal/linux/MutexFactory.cpp +++ b/osal/linux/MutexFactory.cpp @@ -1,6 +1,7 @@ -#include "../../ipc/MutexFactory.h" #include "Mutex.h" +#include "../../ipc/MutexFactory.h" + //TODO: Different variant than the lazy loading in QueueFactory. What's better and why? MutexFactory* MutexFactory::factoryInstance = new MutexFactory(); diff --git a/osal/linux/PosixThread.cpp b/osal/linux/PosixThread.cpp index ddb1f74f..55d74de3 100644 --- a/osal/linux/PosixThread.cpp +++ b/osal/linux/PosixThread.cpp @@ -1,5 +1,7 @@ -#include "../../serviceinterface/ServiceInterfaceStream.h" #include "PosixThread.h" + +#include "../../serviceinterface/ServiceInterfaceStream.h" + #include #include @@ -149,8 +151,10 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { status = pthread_attr_setstack(&attributes, stackPointer, stackSize); if(status != 0){ - sif::error << "Posix Thread attribute setStack failed with: " << - strerror(status) << std::endl; + sif::error << "PosixThread::createTask: pthread_attr_setstack " + " failed with: " << strerror(status) << std::endl; + sif::error << "Make sure the specified stack size is valid and is " + "larger than the minimum allowed stack size." << std::endl; } status = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED); diff --git a/osal/linux/SemaphoreFactory.cpp b/osal/linux/SemaphoreFactory.cpp index e4710933..cfb5f12d 100644 --- a/osal/linux/SemaphoreFactory.cpp +++ b/osal/linux/SemaphoreFactory.cpp @@ -1,6 +1,7 @@ -#include "../../tasks/SemaphoreFactory.h" #include "BinarySemaphore.h" #include "CountingSemaphore.h" + +#include "../../tasks/SemaphoreFactory.h" #include "../../serviceinterface/ServiceInterfaceStream.h" SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr; diff --git a/osal/linux/TaskFactory.cpp b/osal/linux/TaskFactory.cpp index f507c767..d18a0316 100644 --- a/osal/linux/TaskFactory.cpp +++ b/osal/linux/TaskFactory.cpp @@ -1,5 +1,6 @@ #include "FixedTimeslotTask.h" #include "PeriodicPosixTask.h" + #include "../../tasks/TaskFactory.h" #include "../../returnvalues/HasReturnvaluesIF.h" diff --git a/osal/linux/Timer.cpp b/osal/linux/Timer.cpp index ee964baa..bae631d7 100644 --- a/osal/linux/Timer.cpp +++ b/osal/linux/Timer.cpp @@ -1,6 +1,7 @@ +#include "Timer.h" #include "../../serviceinterface/ServiceInterfaceStream.h" #include -#include "Timer.h" + Timer::Timer() { sigevent sigEvent; diff --git a/tasks/TaskFactory.h b/tasks/TaskFactory.h index cbf2272c..404dd2a8 100644 --- a/tasks/TaskFactory.h +++ b/tasks/TaskFactory.h @@ -1,9 +1,9 @@ -#ifndef FRAMEWORK_TASKS_TASKFACTORY_H_ -#define FRAMEWORK_TASKS_TASKFACTORY_H_ +#ifndef FSFW_TASKS_TASKFACTORY_H_ +#define FSFW_TASKS_TASKFACTORY_H_ -#include #include "FixedTimeslotTaskIF.h" #include "Typedef.h" +#include /** * Singleton Class that produces Tasks. @@ -69,4 +69,4 @@ private: }; -#endif /* FRAMEWORK_TASKS_TASKFACTORY_H_ */ +#endif /* FSFW_TASKS_TASKFACTORY_H_ */ From 4f2470b93f8947fafb4e5f2ea4323a30ed3fd5ff Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Dec 2020 21:48:12 +0100 Subject: [PATCH 2/2] task factory --- tasks/TaskFactory.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tasks/TaskFactory.h b/tasks/TaskFactory.h index 404dd2a8..85cdda90 100644 --- a/tasks/TaskFactory.h +++ b/tasks/TaskFactory.h @@ -3,6 +3,7 @@ #include "FixedTimeslotTaskIF.h" #include "Typedef.h" + #include /** @@ -48,10 +49,11 @@ public: /** * Function to be called to delete a task - * @param task The pointer to the task that shall be deleted, NULL specifies current Task + * @param task The pointer to the task that shall be deleted, + * nullptr specifies current Task * @return Success of deletion */ - static ReturnValue_t deleteTask(PeriodicTaskIF* task = NULL); + static ReturnValue_t deleteTask(PeriodicTaskIF* task = nullptr); /** * Function to be called to delay current task