some more bugfixes
This commit is contained in:
parent
22e4e464c7
commit
95924dd55b
@ -210,9 +210,9 @@ ReturnValue_t DataPoolAdmin::handleParameterCommand(CommandMessage* command) {
|
|||||||
|
|
||||||
uint8_t domain = HasParametersIF::getDomain(
|
uint8_t domain = HasParametersIF::getDomain(
|
||||||
ParameterMessage::getParameterId(command));
|
ParameterMessage::getParameterId(command));
|
||||||
uint16_t parameterId = HasParametersIF::getUniqueIdentifierId(
|
uint8_t parameterId = HasParametersIF::getUniqueIdentifierId(
|
||||||
ParameterMessage::getParameterId(command));
|
ParameterMessage::getParameterId(command));
|
||||||
uint8_t index = HasParametersIF::getIndex(
|
uint16_t index = HasParametersIF::getIndex(
|
||||||
ParameterMessage::getParameterId(command));
|
ParameterMessage::getParameterId(command));
|
||||||
|
|
||||||
const uint8_t *storedStream;
|
const uint8_t *storedStream;
|
||||||
|
@ -10,6 +10,7 @@ ParameterHelper::~ParameterHelper() {
|
|||||||
|
|
||||||
ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) {
|
ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) {
|
||||||
if(storage == nullptr) {
|
if(storage == nullptr) {
|
||||||
|
// ParameterHelper was not initialized
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,48 +31,48 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ParameterMessage::CMD_PARAMETER_LOAD: {
|
case ParameterMessage::CMD_PARAMETER_LOAD: {
|
||||||
ParameterId_t parameterId = ParameterMessage::getParameterId(message);
|
ParameterId_t parameterId = 0;
|
||||||
|
uint8_t ptc = 0;
|
||||||
|
uint8_t pfc = 0;
|
||||||
|
uint8_t rows = 0;
|
||||||
|
uint8_t columns = 0;
|
||||||
|
store_address_t storeId = ParameterMessage::getParameterLoadCommand(
|
||||||
|
message, ¶meterId, &ptc, &pfc, &rows, &columns);
|
||||||
|
Type type(Type::getActualType(ptc, pfc));
|
||||||
|
|
||||||
uint8_t domain = HasParametersIF::getDomain(parameterId);
|
uint8_t domain = HasParametersIF::getDomain(parameterId);
|
||||||
uint8_t uniqueIdentifier = HasParametersIF::getUniqueIdentifierId(
|
uint8_t uniqueIdentifier = HasParametersIF::getUniqueIdentifierId(
|
||||||
parameterId);
|
parameterId);
|
||||||
uint16_t linearIndex = HasParametersIF::getIndex(parameterId);
|
uint16_t linearIndex = HasParametersIF::getIndex(parameterId);
|
||||||
|
|
||||||
const uint8_t *storedStream = nullptr;
|
ConstStorageAccessor accessor(storeId);
|
||||||
size_t storedStreamSize = 0;
|
result = storage->getData(storeId, accessor);
|
||||||
result = storage->getData(
|
|
||||||
ParameterMessage::getStoreId(message), &storedStream,
|
|
||||||
&storedStreamSize);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
sif::error << "ParameterHelper::handleParameterMessage: Getting"
|
sif::error << "ParameterHelper::handleParameterMessage: Getting"
|
||||||
" store data failed for load command." << std::endl;
|
<< " store data failed for load command." << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParameterWrapper streamWrapper;
|
ParameterWrapper streamWrapper;
|
||||||
result = streamWrapper.set(storedStream, storedStreamSize);
|
result = streamWrapper.set(type, rows, columns, accessor.data(),
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
accessor.size());
|
||||||
storage->deleteData(ParameterMessage::getStoreId(message));
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
break;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParameterWrapper ownerWrapper;
|
ParameterWrapper ownerWrapper;
|
||||||
result = owner->getParameter(domain, uniqueIdentifier, &ownerWrapper,
|
result = owner->getParameter(domain, uniqueIdentifier, &ownerWrapper,
|
||||||
&streamWrapper, linearIndex);
|
&streamWrapper, linearIndex);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
storage->deleteData(ParameterMessage::getStoreId(message));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = ownerWrapper.copyFrom(&streamWrapper, linearIndex);
|
result = ownerWrapper.copyFrom(&streamWrapper, linearIndex);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
storage->deleteData(ParameterMessage::getStoreId(message));
|
|
||||||
|
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
result = sendParameter(message->getSender(),
|
result = sendParameter(message->getSender(),
|
||||||
ParameterMessage::getParameterId(message), &ownerWrapper);
|
ParameterMessage::getParameterId(message), &ownerWrapper);
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,18 @@ void ParameterMessage::setParameterLoadCommand(CommandMessage* message,
|
|||||||
message->setParameter3(packedParameterSettings);
|
message->setParameter3(packedParameterSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
store_address_t ParameterMessage::getParameterLoadCommand(
|
||||||
|
const CommandMessage *message, ParameterId_t* parameterId, uint8_t *ptc,
|
||||||
|
uint8_t *pfc, uint8_t *rows, uint8_t *columns) {
|
||||||
|
*parameterId = message->getParameter2();
|
||||||
|
uint32_t packedParamSettings = message->getParameter3();
|
||||||
|
*ptc = packedParamSettings >> 24 & 0xff;
|
||||||
|
*pfc = packedParamSettings >> 16 & 0xff;
|
||||||
|
*rows = packedParamSettings >> 8 & 0xff;
|
||||||
|
*columns = packedParamSettings & 0xff;
|
||||||
|
return message->getParameter2();
|
||||||
|
}
|
||||||
|
|
||||||
void ParameterMessage::clear(CommandMessage* message) {
|
void ParameterMessage::clear(CommandMessage* message) {
|
||||||
switch (message->getCommand()) {
|
switch (message->getCommand()) {
|
||||||
case CMD_PARAMETER_LOAD:
|
case CMD_PARAMETER_LOAD:
|
||||||
|
@ -5,6 +5,20 @@
|
|||||||
#include "../ipc/CommandMessage.h"
|
#include "../ipc/CommandMessage.h"
|
||||||
#include "../storagemanager/StorageManagerIF.h"
|
#include "../storagemanager/StorageManagerIF.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ParameterMessage interface
|
||||||
|
* @details
|
||||||
|
* General structure of a parameter message:
|
||||||
|
* 1. 4-byte Object ID
|
||||||
|
* 2. 4-byte Parameter ID, first byte is Domain ID, second byte is unique
|
||||||
|
* identifier, third and fourth byte is linear index to start from
|
||||||
|
* 3. 4-byte Parameter Settings. First byte and second byte are the PTC and PFC
|
||||||
|
* ECSS type identifiers (see ECSS-E-ST-70-41C15 p.428 or Type class in
|
||||||
|
* globalfunctions). Third byte is the number of rows and fourth byte
|
||||||
|
* is the number of columns. For single variable parameters, this will
|
||||||
|
* be [1, 1].
|
||||||
|
*
|
||||||
|
*/
|
||||||
class ParameterMessage {
|
class ParameterMessage {
|
||||||
private:
|
private:
|
||||||
ParameterMessage();
|
ParameterMessage();
|
||||||
@ -36,6 +50,11 @@ public:
|
|||||||
static void setParameterLoadCommand(CommandMessage* message,
|
static void setParameterLoadCommand(CommandMessage* message,
|
||||||
ParameterId_t id, store_address_t storeId, uint8_t ptc,
|
ParameterId_t id, store_address_t storeId, uint8_t ptc,
|
||||||
uint8_t pfc, uint8_t rows, uint8_t columns);
|
uint8_t pfc, uint8_t rows, uint8_t columns);
|
||||||
|
|
||||||
|
static store_address_t getParameterLoadCommand(
|
||||||
|
const CommandMessage* message, ParameterId_t* parameterId,
|
||||||
|
uint8_t* ptc, uint8_t* pfc, uint8_t* rows, uint8_t* columns) ;
|
||||||
|
|
||||||
static void clear(CommandMessage* message);
|
static void clear(CommandMessage* message);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -159,6 +159,23 @@ ReturnValue_t ParameterWrapper::deSerialize(const uint8_t **buffer,
|
|||||||
return copyFrom(&streamDescription, startWritingAtIndex);
|
return copyFrom(&streamDescription, startWritingAtIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t ParameterWrapper::set(Type type, uint8_t rows, uint8_t columns,
|
||||||
|
const void *data, size_t dataSize) {
|
||||||
|
this->type = type;
|
||||||
|
this->rows = rows;
|
||||||
|
this->columns = columns;
|
||||||
|
|
||||||
|
size_t expectedSize = type.getSize() * rows * columns;
|
||||||
|
if (expectedSize < dataSize) {
|
||||||
|
return SerializeIF::STREAM_TOO_SHORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->data = nullptr;
|
||||||
|
this->readonlyData = data;
|
||||||
|
pointsToStream = true;
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t ParameterWrapper::set(const uint8_t *stream, size_t streamSize,
|
ReturnValue_t ParameterWrapper::set(const uint8_t *stream, size_t streamSize,
|
||||||
const uint8_t **remainingStream, size_t *remainingSize) {
|
const uint8_t **remainingStream, size_t *remainingSize) {
|
||||||
ReturnValue_t result = SerializeAdapter::deSerialize(&type, &stream,
|
ReturnValue_t result = SerializeAdapter::deSerialize(&type, &stream,
|
||||||
@ -289,11 +306,12 @@ ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParameterWrapper::convertLinearIndexToRowAndColumn(uint16_t index, uint8_t *row,
|
void ParameterWrapper::convertLinearIndexToRowAndColumn(uint16_t index,
|
||||||
uint8_t *column) {
|
uint8_t *row, uint8_t *column) {
|
||||||
if(row == nullptr or column == nullptr) {
|
if(row == nullptr or column == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Integer division.
|
||||||
*row = index / columns;
|
*row = index / columns;
|
||||||
*column = index % columns;
|
*column = index % columns;
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,9 @@ public:
|
|||||||
sizeof(member[0])/sizeof(member[0][0]));
|
sizeof(member[0])/sizeof(member[0][0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t set(Type type, uint8_t rows, uint8_t columns,
|
||||||
|
const void *data, size_t dataSize);
|
||||||
|
|
||||||
ReturnValue_t set(const uint8_t *stream, size_t streamSize,
|
ReturnValue_t set(const uint8_t *stream, size_t streamSize,
|
||||||
const uint8_t **remainingStream = nullptr,
|
const uint8_t **remainingStream = nullptr,
|
||||||
size_t *remainingSize = nullptr);
|
size_t *remainingSize = nullptr);
|
||||||
@ -158,9 +161,9 @@ inline ReturnValue_t ParameterWrapper::getElement(T *value, uint8_t row,
|
|||||||
if (pointsToStream) {
|
if (pointsToStream) {
|
||||||
const uint8_t *streamWithType = static_cast<const uint8_t*>(readonlyData);
|
const uint8_t *streamWithType = static_cast<const uint8_t*>(readonlyData);
|
||||||
streamWithType += (row * columns + column) * type.getSize();
|
streamWithType += (row * columns + column) * type.getSize();
|
||||||
int32_t size = type.getSize();
|
size_t size = type.getSize();
|
||||||
return SerializeAdapter::deSerialize(value, &streamWithType,
|
return SerializeAdapter::deSerialize(value, &streamWithType,
|
||||||
&size, true);
|
&size, SerializeIF::Endianness::BIG);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const T *dataWithType = static_cast<const T*>(readonlyData);
|
const T *dataWithType = static_cast<const T*>(readonlyData);
|
||||||
|
Loading…
Reference in New Issue
Block a user