diff --git a/osal/rtems/MultiObjectTask.cpp b/osal/rtems/MultiObjectTask.cpp index 8f969a1d1..2342c24c2 100644 --- a/osal/rtems/MultiObjectTask.cpp +++ b/osal/rtems/MultiObjectTask.cpp @@ -78,8 +78,9 @@ ReturnValue_t MultiObjectTask::addComponent(object_id_t object) { return HasReturnvaluesIF::RETURN_FAILED; } objectList.push_back(newObject); - ReturnValue_t result = newObject->initializeAfterTaskCreation(); - return result; + newObject->setTaskIF(this); + + return HasReturnvaluesIF::RETURN_OK; } uint32_t MultiObjectTask::getPeriodMs() const { diff --git a/osal/rtems/MultiObjectTask.h b/osal/rtems/MultiObjectTask.h index 28d05fb1a..736e79dd1 100644 --- a/osal/rtems/MultiObjectTask.h +++ b/osal/rtems/MultiObjectTask.h @@ -1,11 +1,5 @@ -/** - * @file MultiObjectTask.h - * @brief This file defines the MultiObjectTask class. - * @date 30.01.2014 - * @author baetz - */ -#ifndef MULTIOBJECTTASK_H_ -#define MULTIOBJECTTASK_H_ +#ifndef FSFW_OSAL_RTEMS_MULTIOBJECTTASK_H_ +#define FSFW_OSAL_RTEMS_MULTIOBJECTTASK_H_ #include "../../objectmanager/ObjectManagerIF.h" #include "../../tasks/PeriodicTaskIF.h" @@ -21,7 +15,7 @@ class ExecutableObjectIF; * @details MultiObjectTask is an extension to ObjectTask in the way that it is able to execute * multiple objects that implement the ExecutableObjectIF interface. The objects must be * added prior to starting the task. - * + * @author baetz * @ingroup task_handling */ class MultiObjectTask: public TaskBase, public PeriodicTaskIF { @@ -63,11 +57,11 @@ public: * @param object Id of the object to add. * @return RETURN_OK on success, RETURN_FAILED if the object could not be added. */ - ReturnValue_t addComponent(object_id_t object); + ReturnValue_t addComponent(object_id_t object) override; - uint32_t getPeriodMs() const; + uint32_t getPeriodMs() const override; - ReturnValue_t sleepFor(uint32_t ms); + ReturnValue_t sleepFor(uint32_t ms) override; protected: typedef std::vector ObjectList; //!< Typedef for the List of objects. /** @@ -110,4 +104,4 @@ protected: void taskFunctionality(void); }; -#endif /* MULTIOBJECTTASK_H_ */ +#endif /* FSFW_OSAL_RTEMS_MULTIOBJECTTASK_H_ */ diff --git a/osal/rtems/Mutex.cpp b/osal/rtems/Mutex.cpp index d8babcde7..9553ac79c 100644 --- a/osal/rtems/Mutex.cpp +++ b/osal/rtems/Mutex.cpp @@ -1,7 +1,6 @@ #include "Mutex.h" #include "../../serviceinterface/ServiceInterfaceStream.h" -const uint32_t MutexIF::NO_TIMEOUT = RTEMS_NO_TIMEOUT; uint8_t Mutex::count = 0; Mutex::Mutex() : @@ -24,8 +23,22 @@ Mutex::~Mutex() { } } -ReturnValue_t Mutex::lockMutex(uint32_t timeoutMs) { - rtems_status_code status = rtems_semaphore_obtain(mutexId, RTEMS_WAIT, timeoutMs); +ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType = + TimeoutType::BLOCKING, uint32_t timeoutMs) { + if(timeoutMs == MutexIF::TimeoutType::BLOCKING) { + rtems_status_code status = rtems_semaphore_obtain(mutexId, + RTEMS_WAIT, RTEMS_NO_TIMEOUT); + } + else if(timeoutMs == MutexIF::TimeoutType::POLLING) { + timeoutMs = RTEMS_NO_TIMEOUT; + rtems_status_code status = rtems_semaphore_obtain(mutexId, + RTEMS_NO_WAIT, 0); + } + else { + rtems_status_code status = rtems_semaphore_obtain(mutexId, + RTEMS_WAIT, timeoutMs); + } + switch(status){ case RTEMS_SUCCESSFUL: //semaphore obtained successfully diff --git a/osal/rtems/Mutex.h b/osal/rtems/Mutex.h index 340bb16b7..723682104 100644 --- a/osal/rtems/Mutex.h +++ b/osal/rtems/Mutex.h @@ -1,5 +1,5 @@ -#ifndef OS_RTEMS_MUTEX_H_ -#define OS_RTEMS_MUTEX_H_ +#ifndef FRAMEWORK_OSAL_RTEMS_MUTEX_H_ +#define FRAMEWORK_OSAL_RTEMS_MUTEX_H_ #include "../../ipc/MutexIF.h" #include "RtemsBasic.h" @@ -8,7 +8,7 @@ class Mutex : public MutexIF { public: Mutex(); ~Mutex(); - ReturnValue_t lockMutex(uint32_t timeoutMs); + ReturnValue_t lockMutex(TimeoutType timeoutType, uint32_t timeoutMs = 0); ReturnValue_t unlockMutex(); private: rtems_id mutexId; diff --git a/osal/rtems/PollingTask.cpp b/osal/rtems/PollingTask.cpp index efb425d97..04191515b 100644 --- a/osal/rtems/PollingTask.cpp +++ b/osal/rtems/PollingTask.cpp @@ -1,7 +1,7 @@ -#include "../../tasks/FixedSequenceSlot.h" +#include "../../devicehandlers/FixedSequenceSlot.h" #include "../../objectmanager/SystemObjectIF.h" -#include "../../osal/rtems/PollingTask.h" -#include "../../osal/rtems/RtemsBasic.h" +#include "PollingTask.h" +#include "RtemsBasic.h" #include "../../returnvalues/HasReturnvaluesIF.h" #include "../../serviceinterface/ServiceInterfaceStream.h" #include @@ -73,7 +73,7 @@ ReturnValue_t PollingTask::addSlot(object_id_t componentId, return HasReturnvaluesIF::RETURN_OK; } - sif::error << "Component " << std::hex << componentId << + error << "Component " << std::hex << componentId << " not found, not adding it to pst" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } @@ -82,7 +82,7 @@ uint32_t PollingTask::getPeriodMs() const { return pst.getLengthMs(); } -ReturnValue_t PollingTask::checkAndInitializeSequence() const { +ReturnValue_t PollingTask::checkSequence() const { return pst.checkSequence(); } diff --git a/osal/rtems/PollingTask.h b/osal/rtems/PollingTask.h index 1502f0c60..199c34e71 100644 --- a/osal/rtems/PollingTask.h +++ b/osal/rtems/PollingTask.h @@ -1,7 +1,7 @@ #ifndef POLLINGTASK_H_ #define POLLINGTASK_H_ -#include "../../tasks/FixedSlotSequence.h" +#include "../../devicehandlers/FixedSlotSequence.h" #include "../../tasks/FixedTimeslotTaskIF.h" #include "TaskBase.h" @@ -42,7 +42,7 @@ class PollingTask: public TaskBase, public FixedTimeslotTaskIF { uint32_t getPeriodMs() const; - ReturnValue_t checkAndInitializeSequence() const; + ReturnValue_t checkSequence() const; ReturnValue_t sleepFor(uint32_t ms); protected: