1
0
forked from fsfw/fsfw

replaced mutexIF and semaphoreIF name for timeouts

This commit is contained in:
2020-06-02 22:19:48 +02:00
parent f0a25b5e2b
commit 986dc2047e
15 changed files with 49 additions and 49 deletions

View File

@ -17,11 +17,11 @@ BinarySemaphoreUsingTask::~BinarySemaphoreUsingTask() {
}
ReturnValue_t BinarySemaphoreUsingTask::acquire(uint32_t timeoutMs) {
TickType_t timeout = SemaphoreIF::NO_TIMEOUT;
if(timeoutMs == SemaphoreIF::MAX_TIMEOUT) {
timeout = SemaphoreIF::MAX_TIMEOUT;
TickType_t timeout = SemaphoreIF::POLLING;
if(timeoutMs == SemaphoreIF::BLOCKING) {
timeout = SemaphoreIF::BLOCKING;
}
else if(timeoutMs > SemaphoreIF::NO_TIMEOUT){
else if(timeoutMs > SemaphoreIF::POLLING){
timeout = pdMS_TO_TICKS(timeoutMs);
}
return acquireWithTickTimeout(timeout);

View File

@ -26,7 +26,7 @@ public:
virtual~ BinarySemaphoreUsingTask();
ReturnValue_t acquire(uint32_t timeoutMs =
SemaphoreIF::NO_TIMEOUT) override;
SemaphoreIF::BLOCKING) override;
ReturnValue_t release() override;
uint8_t getSemaphoreCounter() const override;
static uint8_t getSemaphoreCounter(TaskHandle_t taskHandle);
@ -40,7 +40,7 @@ public:
* - @c RETURN_FAILED on failure
*/
ReturnValue_t acquireWithTickTimeout(TickType_t timeoutTicks =
SemaphoreIF::NO_TIMEOUT);
SemaphoreIF::BLOCKING);
/**
* Get handle to the task related to the semaphore.

View File

@ -36,11 +36,11 @@ BinarySemaphore& BinarySemaphore::operator =(
}
ReturnValue_t BinarySemaphore::acquire(uint32_t timeoutMs) {
TickType_t timeout = SemaphoreIF::NO_TIMEOUT;
if(timeoutMs == SemaphoreIF::MAX_TIMEOUT) {
timeout = SemaphoreIF::MAX_TIMEOUT;
TickType_t timeout = SemaphoreIF::POLLING;
if(timeoutMs == SemaphoreIF::BLOCKING) {
timeout = SemaphoreIF::BLOCKING;
}
else if(timeoutMs > SemaphoreIF::NO_TIMEOUT){
else if(timeoutMs > SemaphoreIF::POLLING){
timeout = pdMS_TO_TICKS(timeoutMs);
}
return acquireWithTickTimeout(timeout);

View File

@ -53,7 +53,7 @@ public:
* -@c SemaphoreIF::SEMAPHORE_TIMEOUT on timeout
*/
ReturnValue_t acquire(uint32_t timeoutMs =
SemaphoreIF::NO_TIMEOUT) override;
SemaphoreIF::BLOCKING) override;
/**
* Same as lockBinarySemaphore() with timeout in FreeRTOS ticks.
@ -62,7 +62,7 @@ public:
* -@c SemaphoreIF::SEMAPHORE_TIMEOUT on timeout
*/
ReturnValue_t acquireWithTickTimeout(TickType_t timeoutTicks =
BinarySemaphore::NO_TIMEOUT);
SemaphoreIF::BLOCKING);
/**
* Release the binary semaphore.

View File

@ -155,7 +155,7 @@ ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
if (checkOrCreateClockMutex() != HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_FAILED;
}
ReturnValue_t result = timeMutex->lockMutex(MutexIF::NO_TIMEOUT);
ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
@ -170,7 +170,7 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
if (timeMutex == NULL) {
return HasReturnvaluesIF::RETURN_FAILED;
}
ReturnValue_t result = timeMutex->lockMutex(MutexIF::NO_TIMEOUT);
ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}

View File

@ -38,11 +38,11 @@ CountingSemaphoreUsingTask::~CountingSemaphoreUsingTask() {
}
ReturnValue_t CountingSemaphoreUsingTask::acquire(uint32_t timeoutMs) {
TickType_t timeout = SemaphoreIF::NO_TIMEOUT;
if(timeoutMs == SemaphoreIF::MAX_TIMEOUT) {
timeout = SemaphoreIF::MAX_TIMEOUT;
TickType_t timeout = SemaphoreIF::POLLING;
if(timeoutMs == SemaphoreIF::BLOCKING) {
timeout = SemaphoreIF::BLOCKING;
}
else if(timeoutMs > SemaphoreIF::NO_TIMEOUT){
else if(timeoutMs > SemaphoreIF::POLLING){
timeout = pdMS_TO_TICKS(timeoutMs);
}
return acquireWithTickTimeout(timeout);

View File

@ -31,7 +31,7 @@ public:
* @return -@c RETURN_OK on success
* -@c SemaphoreIF::SEMAPHORE_TIMEOUT on timeout
*/
ReturnValue_t acquire(uint32_t timeoutMs = SemaphoreIF::NO_TIMEOUT) override;
ReturnValue_t acquire(uint32_t timeoutMs = SemaphoreIF::BLOCKING) override;
/**
* Release a semaphore, increasing the number of available counting
@ -61,7 +61,7 @@ public:
* -@c SemaphoreIF::SEMAPHORE_TIMEOUT on timeout
*/
ReturnValue_t acquireWithTickTimeout(
TickType_t timeoutTicks = SemaphoreIF::NO_TIMEOUT);
TickType_t timeoutTicks = SemaphoreIF::BLOCKING);
/**
* Get handle to the task related to the semaphore.

View File

@ -2,8 +2,8 @@
#include <framework/serviceinterface/ServiceInterfaceStream.h>
const uint32_t MutexIF::NO_TIMEOUT = 0;
const uint32_t MutexIF::MAX_TIMEOUT = portMAX_DELAY;
const uint32_t MutexIF::POLLING = 0;
const uint32_t MutexIF::BLOCKING = portMAX_DELAY;
Mutex::Mutex() {
handle = xSemaphoreCreateMutex();
@ -23,11 +23,11 @@ ReturnValue_t Mutex::lockMutex(uint32_t timeoutMs) {
if (handle == nullptr) {
return MutexIF::MUTEX_NOT_FOUND;
}
TickType_t timeout = MutexIF::NO_TIMEOUT;
if(timeoutMs == MutexIF::MAX_TIMEOUT) {
timeout = MutexIF::MAX_TIMEOUT;
TickType_t timeout = MutexIF::POLLING;
if(timeoutMs == MutexIF::BLOCKING) {
timeout = MutexIF::BLOCKING;
}
else if(timeoutMs > MutexIF::NO_TIMEOUT){
else if(timeoutMs > MutexIF::POLLING){
timeout = pdMS_TO_TICKS(timeoutMs);
}

View File

@ -18,7 +18,7 @@ class Mutex : public MutexIF {
public:
Mutex();
~Mutex();
ReturnValue_t lockMutex(uint32_t timeoutMs = MutexIF::MAX_TIMEOUT) override;
ReturnValue_t lockMutex(uint32_t timeoutMs = MutexIF::BLOCKING) override;
ReturnValue_t unlockMutex() override;
private:
SemaphoreHandle_t handle;

View File

@ -6,8 +6,8 @@
#include <framework/serviceinterface/ServiceInterfaceStream.h>
SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;
const uint32_t SemaphoreIF::NO_TIMEOUT = 0;
const uint32_t SemaphoreIF::MAX_TIMEOUT = portMAX_DELAY;
const uint32_t SemaphoreIF::POLLING= 0;
const uint32_t SemaphoreIF::BLOCKING = portMAX_DELAY;
static const uint32_t USE_REGULAR_SEMAPHORES = 0;
static const uint32_t USE_TASK_NOTIFICATIONS = 1;