better returnvalues etc.
This commit is contained in:
parent
3b39c6b6e2
commit
5a8647d367
@ -1,6 +1,6 @@
|
||||
#include "PoolEntry.h"
|
||||
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../globalfunctions/arrayprinter.h"
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
@ -62,14 +62,26 @@ bool PoolEntry<T>::getValid() {
|
||||
|
||||
template <typename T>
|
||||
void PoolEntry<T>::print() {
|
||||
const char* validString = nullptr;
|
||||
if(valid) {
|
||||
validString = "Valid";
|
||||
}
|
||||
else {
|
||||
validString = "Invalid";
|
||||
}
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "Pool Entry Validity: " <<
|
||||
(this->valid? " (valid) " : " (invalid) ") << std::endl;
|
||||
#endif
|
||||
arrayprinter::print(reinterpret_cast<uint8_t*>(address), length);
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << std::dec << std::endl;
|
||||
sif::info << "PoolEntry information." << std::endl;
|
||||
sif::info << "PoolEntry validity: " << validString << std::endl;
|
||||
#else
|
||||
fsfw::printInfo("PoolEntry information.\n");
|
||||
fsfw::printInfo("PoolEntry validity: %s\n", validString);
|
||||
#endif
|
||||
arrayprinter::print(reinterpret_cast<uint8_t*>(address), getByteSize());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T* PoolEntry<T>::getDataPtr() {
|
||||
return this->address;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -80,21 +80,16 @@ public:
|
||||
~PoolEntry();
|
||||
|
||||
/**
|
||||
* @brief This is the address pointing to the allocated memory.
|
||||
* Return typed pointer to start of data.
|
||||
* @return
|
||||
*/
|
||||
T* address;
|
||||
/**
|
||||
* @brief This attribute stores the length information.
|
||||
*/
|
||||
uint8_t length;
|
||||
/**
|
||||
* @brief Here, the validity information for a variable is stored.
|
||||
* Every entry (single variable or vector) has one valid flag.
|
||||
*/
|
||||
uint8_t valid;
|
||||
T* getDataPtr();
|
||||
|
||||
/**
|
||||
* @brief getSize returns the array size of the entry.
|
||||
* @details A single parameter has size 1.
|
||||
* @details
|
||||
* For non-array pool entries return type size, for vector entries
|
||||
* return type size times the number of entries.
|
||||
*/
|
||||
uint8_t getSize();
|
||||
/**
|
||||
@ -121,8 +116,22 @@ public:
|
||||
* information to the screen. It prints all array entries in a row.
|
||||
*/
|
||||
void print();
|
||||
|
||||
Type getType();
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief This attribute stores the length information.
|
||||
*/
|
||||
uint8_t length;
|
||||
/**
|
||||
* @brief Here, the validity information for a variable is stored.
|
||||
* Every entry (single variable or vector) has one valid flag.
|
||||
*/
|
||||
uint8_t valid;
|
||||
/**
|
||||
* @brief This is the address pointing to the allocated memory.
|
||||
*/
|
||||
T* address;
|
||||
};
|
||||
|
||||
#endif /* FSFW_DATAPOOL_POOLENTRY_H_ */
|
||||
|
@ -213,7 +213,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
|
||||
LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(
|
||||
receiver.dataId.localPoolId);
|
||||
if(poolObj == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return POOLOBJECT_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (not poolObj->hasChanged()) {
|
||||
@ -249,7 +249,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
|
||||
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
|
||||
receiver.dataId.sid);
|
||||
if(dataSet == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return DATASET_NOT_FOUND;
|
||||
}
|
||||
|
||||
if(not dataSet->hasChanged()) {
|
||||
@ -618,7 +618,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
||||
sif::warning << "HousekeepingManager::generateHousekeepingPacket:"
|
||||
<< " Set ID not found or dataset not assigned!" << std::endl;
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return DATASET_NOT_FOUND;
|
||||
}
|
||||
|
||||
store_address_t storeId;
|
||||
|
@ -56,11 +56,13 @@ class LocalDataPoolManager {
|
||||
public:
|
||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER;
|
||||
|
||||
static constexpr ReturnValue_t QUEUE_OR_DESTINATION_NOT_SET = MAKE_RETURN_CODE(0x0);
|
||||
static constexpr ReturnValue_t QUEUE_OR_DESTINATION_NOT_SET = MAKE_RETURN_CODE(0);
|
||||
|
||||
static constexpr ReturnValue_t WRONG_HK_PACKET_TYPE = MAKE_RETURN_CODE(0x01);
|
||||
static constexpr ReturnValue_t REPORTING_STATUS_UNCHANGED = MAKE_RETURN_CODE(0x02);
|
||||
static constexpr ReturnValue_t PERIODIC_HELPER_INVALID = MAKE_RETURN_CODE(0x03);
|
||||
static constexpr ReturnValue_t WRONG_HK_PACKET_TYPE = MAKE_RETURN_CODE(1);
|
||||
static constexpr ReturnValue_t REPORTING_STATUS_UNCHANGED = MAKE_RETURN_CODE(2);
|
||||
static constexpr ReturnValue_t PERIODIC_HELPER_INVALID = MAKE_RETURN_CODE(3);
|
||||
static constexpr ReturnValue_t POOLOBJECT_NOT_FOUND = MAKE_RETURN_CODE(4);
|
||||
static constexpr ReturnValue_t DATASET_NOT_FOUND = MAKE_RETURN_CODE(5);
|
||||
|
||||
/**
|
||||
* This constructor is used by a class which wants to implement
|
||||
|
@ -50,16 +50,16 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
|
||||
}
|
||||
|
||||
// Actually this should never happen..
|
||||
if(poolEntry->address == nullptr) {
|
||||
result = PoolVariableIF::INVALID_POOL_ENTRY;
|
||||
object_id_t ownerObjectId = hkManager->getOwner()->getObjectId();
|
||||
reportReadCommitError("LocalPoolVariable", result,
|
||||
false, ownerObjectId, localPoolId);
|
||||
return result;
|
||||
}
|
||||
// if(poolEntry->address == nullptr) {
|
||||
// result = PoolVariableIF::INVALID_POOL_ENTRY;
|
||||
// object_id_t ownerObjectId = hkManager->getOwner()->getObjectId();
|
||||
// reportReadCommitError("LocalPoolVariable", result,
|
||||
// false, ownerObjectId, localPoolId);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
this->value = *(poolEntry->address);
|
||||
this->valid = poolEntry->valid;
|
||||
this->value = *(poolEntry->getDataPtr());
|
||||
this->valid = poolEntry->getValid();
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
@ -96,8 +96,8 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
|
||||
return result;
|
||||
}
|
||||
|
||||
*(poolEntry->address) = this->value;
|
||||
poolEntry->valid = this->valid;
|
||||
*(poolEntry->getDataPtr()) = this->value;
|
||||
poolEntry->setValid(this->valid);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
|
||||
localPoolId);
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->value, poolEntry->address, poolEntry->getByteSize());
|
||||
this->valid = poolEntry->valid;
|
||||
std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize());
|
||||
this->valid = poolEntry->getValid();
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
@ -85,8 +85,8 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
|
||||
localPoolId);
|
||||
return result;
|
||||
}
|
||||
std::memcpy(poolEntry->address, this->value, poolEntry->getByteSize());
|
||||
poolEntry->valid = this->valid;
|
||||
std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize());
|
||||
poolEntry->setValid(this->valid);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "arrayprinter.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include <bitset>
|
||||
|
||||
void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
|
||||
@ -9,6 +9,8 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
|
||||
sif::info << "Printing data with size " << size << ": ";
|
||||
}
|
||||
sif::info << "[";
|
||||
#else
|
||||
fsfw::printInfo("Printing data with size %zu: [", size);
|
||||
#endif
|
||||
if(type == OutputType::HEX) {
|
||||
arrayprinter::printHex(data, size, maxCharPerLine);
|
||||
@ -37,6 +39,8 @@ void arrayprinter::printHex(const uint8_t *data, size_t size,
|
||||
}
|
||||
sif::info << std::dec;
|
||||
sif::info << "]" << std::endl;
|
||||
#else
|
||||
// how much memory to reserve for printout?
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -54,6 +58,8 @@ void arrayprinter::printDec(const uint8_t *data, size_t size,
|
||||
}
|
||||
}
|
||||
sif::info << "]" << std::endl;
|
||||
#else
|
||||
// how much memory to reserve for printout?
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -65,5 +71,7 @@ void arrayprinter::printBin(const uint8_t *data, size_t size) {
|
||||
std::bitset<8>(data[i]) << ",\n" << std::flush;
|
||||
}
|
||||
sif::info << "]" << std::endl;
|
||||
#else
|
||||
// how much memory to reserve for printout?
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user