new f unctions for read error reporting, bugfix

This commit is contained in:
Robin Müller 2021-01-07 19:10:07 +01:00
parent 8aaf45049f
commit 007526c050
4 changed files with 48 additions and 23 deletions

View File

@ -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;

View File

@ -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<T>* >(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;
}

View File

@ -181,6 +181,7 @@ protected:
#endif
private:
void reportReadCommitError(bool read, object_id_t objectId, lp_id_t lpId);
};
#include "LocalPoolVariable.tpp"

View File

@ -46,18 +46,17 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
PoolEntry<T>* 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<T>::commitWithoutLock() {
}
PoolEntry<T>* 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<T>::operator >(const T &other) const {
return not (*this < other);
}
template<typename T>
inline void LocalPoolVariable<T>::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_ */