updating code from Flying Laptop

This is the framework of Flying Laptop OBSW version A.13.0.
This commit is contained in:
2018-07-12 16:29:32 +02:00
parent 1d22a6c97e
commit 575f70ba03
395 changed files with 12807 additions and 8404 deletions

View File

@ -11,8 +11,9 @@
#define POOLMANAGER_H_
#include <framework/osal/OSAL.h>
#include <framework/storagemanager/LocalPool.h>
#include <framework/ipc/MutexIF.h>
#include <framework/ipc/MutexFactory.h>
/**
* @brief The PoolManager class provides an intermediate data storage with
@ -27,12 +28,13 @@ protected:
* Overwritten for thread safety.
* Locks during execution.
*/
ReturnValue_t findEmpty( uint16_t pool_index, uint16_t* element );
virtual ReturnValue_t reserveSpace(const uint32_t size, store_address_t* address, bool ignoreFault);
/**
* \brief The mutex is created in the constructor and makes access mutual exclusive.
* \details Locking and unlocking is done during searching for free slots and deleting existing slots.
*/
MutexId_t* mutex;
MutexIF* mutex;
public:
PoolManager( object_id_t setObjectId, const uint16_t element_sizes[NUMBER_OF_POOLS], const uint16_t n_elements[NUMBER_OF_POOLS] );
/**
@ -47,16 +49,15 @@ public:
};
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::findEmpty(uint16_t pool_index,
uint16_t* element) {
ReturnValue_t mutexStatus = OSAL::lockMutex( mutex, OSAL::NO_TIMEOUT );
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::reserveSpace(const uint32_t size, store_address_t* address, bool ignoreFault) {
ReturnValue_t mutexStatus = mutex->lockMutex(MutexIF::NO_TIMEOUT);
ReturnValue_t status = this->DATA_STORAGE_FULL;
if ( mutexStatus == this->RETURN_OK ) {
status = LocalPool<NUMBER_OF_POOLS>::findEmpty(pool_index, element);
status = LocalPool<NUMBER_OF_POOLS>::reserveSpace(size,address,ignoreFault);
} else {
error << "PoolManager::findEmpty: Mutex could not be acquired. Error code: " << status << std::endl;
error << "PoolManager::findEmpty: Mutex could not be acquired. Error code: " << mutexStatus << std::endl;
}
mutexStatus = OSAL::unlockMutex( mutex );
mutexStatus = mutex->lockMutex(MutexIF::NO_TIMEOUT);
if (mutexStatus != this->RETURN_OK) {
return mutexStatus;
} else {
@ -68,31 +69,26 @@ template<uint8_t NUMBER_OF_POOLS>
inline PoolManager<NUMBER_OF_POOLS>::PoolManager(object_id_t setObjectId,
const uint16_t element_sizes[NUMBER_OF_POOLS],
const uint16_t n_elements[NUMBER_OF_POOLS]) : LocalPool<NUMBER_OF_POOLS>(setObjectId, element_sizes, n_elements, true) {
mutex = new MutexId_t;
ReturnValue_t result = OSAL::createMutex( OSAL::buildName('M','T','X','1'), ( mutex ) );
if (result != this->RETURN_OK) {
error << "PoolManager( " << std::hex << this->getObjectId() << std::dec << " )::ctor: Creating mutex failed." << std::endl;
}
mutex = MutexFactory::instance()->createMutex();
}
template<uint8_t NUMBER_OF_POOLS>
inline PoolManager<NUMBER_OF_POOLS>::~PoolManager(void) {
OSAL::deleteMutex( mutex );
delete mutex;
MutexFactory::instance()->deleteMutex(mutex);
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(
store_address_t packet_id) {
// debug << "PoolManager( " << translateObject(getObjectId()) << " )::deleteData from store " << packet_id.pool_index << ". id is " << packet_id.packet_index << std::endl;
ReturnValue_t mutexStatus = OSAL::lockMutex( mutex, OSAL::NO_TIMEOUT );
ReturnValue_t mutexStatus = mutex->lockMutex(MutexIF::NO_TIMEOUT);
ReturnValue_t status = this->RETURN_OK;
if ( mutexStatus == this->RETURN_OK ) {
LocalPool<NUMBER_OF_POOLS>::deleteData(packet_id);
} else {
error << "PoolManager:deleteData: Mutex could not be acquired. Error code: " << status << std::endl;
}
mutexStatus = OSAL::unlockMutex( mutex );
mutexStatus = mutex->lockMutex(MutexIF::NO_TIMEOUT);
if (mutexStatus != this->RETURN_OK) {
return mutexStatus;
} else {
@ -103,14 +99,14 @@ inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(uint8_t* buffer, uint32_t size,
store_address_t* storeId) {
ReturnValue_t mutexStatus = OSAL::lockMutex( mutex, OSAL::NO_TIMEOUT );
ReturnValue_t mutexStatus = mutex->lockMutex(MutexIF::NO_TIMEOUT);
ReturnValue_t status = this->RETURN_OK;
if ( mutexStatus == this->RETURN_OK ) {
LocalPool<NUMBER_OF_POOLS>::deleteData(buffer, size, storeId);
} else {
error << "PoolManager:deleteData: Mutex could not be acquired. Error code: " << status << std::endl;
}
mutexStatus = OSAL::unlockMutex( mutex );
mutexStatus = mutex->lockMutex(MutexIF::NO_TIMEOUT);
if (mutexStatus != this->RETURN_OK) {
return mutexStatus;
} else {