diff --git a/datapool/PoolVariableIF.h b/datapool/PoolVariableIF.h index 9740fc12..444e19d0 100644 --- a/datapool/PoolVariableIF.h +++ b/datapool/PoolVariableIF.h @@ -25,6 +25,7 @@ class PoolVariableIF : public SerializeIF, public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::POOL_VARIABLE_IF; static constexpr ReturnValue_t INVALID_READ_WRITE_MODE = MAKE_RETURN_CODE(0xA0); + static constexpr ReturnValue_t INVALID_POOL_ENTRY = MAKE_RETURN_CODE(0xA1); static constexpr bool VALID = 1; static constexpr bool INVALID = 0; diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 0e98b90c..bcb8f0af 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -3,6 +3,7 @@ #include "HasLocalDataPoolIF.h" +#include "../serviceinterface/ServiceInterface.h" #include "../housekeeping/HousekeepingPacketDownlink.h" #include "../housekeeping/HousekeepingMessage.h" #include "../housekeeping/PeriodicHousekeepingHelper.h" @@ -378,6 +379,9 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "HousekeepingManager::fechPoolEntry: Pool entry " "not found." << std::endl; +#else + fsfw::printWarning("HousekeepingManager::fechPoolEntry: Pool entry " + "not found."); #endif return HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND; } @@ -385,8 +389,11 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, *poolEntry = dynamic_cast< PoolEntry* >(poolIter->second); if(*poolEntry == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "HousekeepingManager::fetchPoolEntry:" - " Pool entry not found." << std::endl; + sif::warning << "HousekeepingManager::fetchPoolEntry:" + " Pool entry type conflict." << std::endl; +#else + fsfw::printWarning("HousekeepingManager::fetchPoolEntry:" + " Pool entry type conflict."); #endif return HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT; } diff --git a/datapoollocal/LocalPoolVariable.h b/datapoollocal/LocalPoolVariable.h index c81967a1..ca0aede9 100644 --- a/datapoollocal/LocalPoolVariable.h +++ b/datapoollocal/LocalPoolVariable.h @@ -181,6 +181,7 @@ protected: #endif private: + void reportReadCommitError(bool read, object_id_t objectId, lp_id_t lpId); }; #include "LocalPoolVariable.tpp" diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index 9387acc5..c20e9230 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -46,18 +46,17 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK or poolEntry == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PoolPoolVariable: Read of local pool variable of object " - << std::hex << std::setw(8) << std::setfill('0') - << hkManager->getOwner() << " and lp ID 0x" << localPoolId - << std::dec << " failed." << std::setfill(' ') << std::endl; -#else - fsfw::printError("LocalPoolVariable: Read of local pool variable of " - "object 0x%08x and lp ID 0x%08x failed.\n\r", - hkManager->getOwner(), localPoolId); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + object_id_t ownerObjectId = hkManager->getOwner()->getObjectId(); + reportReadCommitError(true, ownerObjectId, localPoolId); return result; } + + if(poolEntry->address == nullptr) { + object_id_t ownerObjectId = hkManager->getOwner()->getObjectId(); + reportReadCommitError(true, ownerObjectId, localPoolId); + return PoolVariableIF::INVALID_POOL_ENTRY; + } + this->value = *(poolEntry->address); this->valid = poolEntry->valid; return RETURN_OK; @@ -91,19 +90,12 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { } PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); - if(result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PoolPoolVariable: Read of local pool variable of " - << "object " << std::hex << std::setw(8) << std::setfill('0') - << hkManager->getOwner() << " and lp ID 0x" << localPoolId - << std::dec << " failed." << std::endl; -#else - fsfw::printError("LocalPoolVariable: Read of local pool variable of " - "object 0x%08x and lp ID 0x%08x failed.\n\r", - hkManager->getOwner(), localPoolId); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + if(result != RETURN_OK or poolEntry == nullptr) { + object_id_t ownerObjectId = hkManager->getOwner()->getObjectId(); + reportReadCommitError(false, ownerObjectId, localPoolId); return result; } + *(poolEntry->address) = this->value; poolEntry->valid = this->valid; return RETURN_OK; @@ -203,4 +195,28 @@ inline bool LocalPoolVariable::operator >(const T &other) const { return not (*this < other); } +template +inline void LocalPoolVariable::reportReadCommitError(bool read, + object_id_t objectId, lp_id_t lpId) { + const char* type = nullptr; + if(read) { + type = "read"; + } + else { + type = "commit"; + } + +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "PoolPoolVariable: " << type << " of local pool " + <<"variable of object " << std::hex << std::setw(8) + << std::setfill('0') << objectId << " and lp ID 0x" << lpId + << std::dec << " failed." << std::endl; +#else + fsfw::printWarning("LocalPoolVariable: %s of local pool variable of " + "object 0x%08x and lp ID 0x%08x failed.\n\r", + type, objectId, lpId); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ +} + + #endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ */