linux update

This commit is contained in:
Robin Müller 2020-12-14 21:46:33 +01:00
parent e06b15cb9c
commit 336b43572f
11 changed files with 32 additions and 24 deletions

View File

@ -1,5 +1,5 @@
#ifndef FRAMEWORK_IPC_MUTEXFACTORY_H_ #ifndef FSFW_IPC_MUTEXFACTORY_H_
#define FRAMEWORK_IPC_MUTEXFACTORY_H_ #define FSFW_IPC_MUTEXFACTORY_H_
#include "MutexIF.h" #include "MutexIF.h"
/** /**
@ -31,4 +31,4 @@ private:
#endif /* FRAMEWORK_IPC_MUTEXFACTORY_H_ */ #endif /* FSFW_IPC_MUTEXFACTORY_H_ */

View File

@ -1,4 +1,4 @@
#include "../../osal/linux/BinarySemaphore.h" #include "BinarySemaphore.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
extern "C" { extern "C" {

View File

@ -76,25 +76,25 @@ timeval Clock::getUptime() {
ReturnValue_t Clock::getUptime(timeval* uptime) { ReturnValue_t Clock::getUptime(timeval* uptime) {
//TODO This is not posix compatible and delivers only seconds precision //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; double uptimeSeconds;
if(std::ifstream("/proc/uptime",std::ios::in) >> uptimeSeconds){ if(std::ifstream("/proc/uptime",std::ios::in) >> uptimeSeconds){
uptime->tv_sec = uptimeSeconds; uptime->tv_sec = uptimeSeconds;
uptime->tv_usec = uptimeSeconds *(double) 1e6 - (uptime->tv_sec *1e6); 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 // Wait for new FSFW Clock function delivering seconds uptime.
// I suggest this is moved into another clock function which will //uint32_t Clock::getUptimeSeconds() {
// deliver second precision later. // //TODO This is not posix compatible and delivers only seconds precision
// struct sysinfo sysInfo; // struct sysinfo sysInfo;
// int result = sysinfo(&sysInfo); // int result = sysinfo(&sysInfo);
// if(result != 0){ // if(result != 0){
// return HasReturnvaluesIF::RETURN_FAILED; // return HasReturnvaluesIF::RETURN_FAILED;
// } // }
// return sysInfo.uptime; // return sysInfo.uptime;
return HasReturnvaluesIF::RETURN_OK; //}
}
ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) {
timeval uptime; timeval uptime;

View File

@ -3,6 +3,7 @@
#include "../../objectmanager/ObjectManagerIF.h" #include "../../objectmanager/ObjectManagerIF.h"
#include <fstream> #include <fstream>
#include <fcntl.h> /* For O_* constants */ #include <fcntl.h> /* For O_* constants */
#include <sys/stat.h> /* For mode constants */ #include <sys/stat.h> /* For mode constants */
#include <cstring> #include <cstring>

View File

@ -1,10 +1,9 @@
#ifndef OS_LINUX_MUTEX_H_ #ifndef FSFW_OSAL_LINUX_MUTEX_H_
#define OS_LINUX_MUTEX_H_ #define FSFW_OSAL_LINUX_MUTEX_H_
#include "../../ipc/MutexIF.h" #include "../../ipc/MutexIF.h"
#include <pthread.h> #include <pthread.h>
class Mutex : public MutexIF { class Mutex : public MutexIF {
public: public:
Mutex(); Mutex();

View File

@ -1,6 +1,7 @@
#include "../../ipc/MutexFactory.h"
#include "Mutex.h" #include "Mutex.h"
#include "../../ipc/MutexFactory.h"
//TODO: Different variant than the lazy loading in QueueFactory. What's better and why? //TODO: Different variant than the lazy loading in QueueFactory. What's better and why?
MutexFactory* MutexFactory::factoryInstance = new MutexFactory(); MutexFactory* MutexFactory::factoryInstance = new MutexFactory();

View File

@ -1,5 +1,7 @@
#include "../../serviceinterface/ServiceInterfaceStream.h"
#include "PosixThread.h" #include "PosixThread.h"
#include "../../serviceinterface/ServiceInterfaceStream.h"
#include <cstring> #include <cstring>
#include <errno.h> #include <errno.h>
@ -149,8 +151,10 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
status = pthread_attr_setstack(&attributes, stackPointer, stackSize); status = pthread_attr_setstack(&attributes, stackPointer, stackSize);
if(status != 0){ if(status != 0){
sif::error << "Posix Thread attribute setStack failed with: " << sif::error << "PosixThread::createTask: pthread_attr_setstack "
strerror(status) << std::endl; " 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); status = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED);

View File

@ -1,6 +1,7 @@
#include "../../tasks/SemaphoreFactory.h"
#include "BinarySemaphore.h" #include "BinarySemaphore.h"
#include "CountingSemaphore.h" #include "CountingSemaphore.h"
#include "../../tasks/SemaphoreFactory.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr; SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;

View File

@ -1,5 +1,6 @@
#include "FixedTimeslotTask.h" #include "FixedTimeslotTask.h"
#include "PeriodicPosixTask.h" #include "PeriodicPosixTask.h"
#include "../../tasks/TaskFactory.h" #include "../../tasks/TaskFactory.h"
#include "../../returnvalues/HasReturnvaluesIF.h" #include "../../returnvalues/HasReturnvaluesIF.h"

View File

@ -1,6 +1,7 @@
#include "Timer.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
#include <errno.h> #include <errno.h>
#include "Timer.h"
Timer::Timer() { Timer::Timer() {
sigevent sigEvent; sigevent sigEvent;

View File

@ -1,9 +1,9 @@
#ifndef FRAMEWORK_TASKS_TASKFACTORY_H_ #ifndef FSFW_TASKS_TASKFACTORY_H_
#define FRAMEWORK_TASKS_TASKFACTORY_H_ #define FSFW_TASKS_TASKFACTORY_H_
#include <stdlib.h>
#include "FixedTimeslotTaskIF.h" #include "FixedTimeslotTaskIF.h"
#include "Typedef.h" #include "Typedef.h"
#include <cstdlib>
/** /**
* Singleton Class that produces Tasks. * Singleton Class that produces Tasks.
@ -69,4 +69,4 @@ private:
}; };
#endif /* FRAMEWORK_TASKS_TASKFACTORY_H_ */ #endif /* FSFW_TASKS_TASKFACTORY_H_ */