printout, doc, bugfixes..

This commit is contained in:
Robin Müller 2021-01-31 17:40:20 +01:00
parent 503de9ba89
commit f067695353
4 changed files with 74 additions and 13 deletions

View File

@ -1,4 +1,6 @@
#include "ParameterWrapper.h"
#include <FSFWConfig.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
ParameterWrapper::ParameterWrapper() :
pointsToStream(false), type(Type::UNKNOWN_TYPE) {
@ -75,7 +77,7 @@ ReturnValue_t ParameterWrapper::serialize(uint8_t **buffer, size_t *size,
result = serializeData<double>(buffer, size, maxSize, streamEndianness);
break;
default:
result = UNKNOW_DATATYPE;
result = UNKNOWN_DATATYPE;
break;
}
return result;
@ -220,22 +222,48 @@ ReturnValue_t ParameterWrapper::set(const uint8_t *stream, size_t streamSize,
ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from,
uint16_t startWritingAtIndex) {
// TODO: Optional diagnostic output (which can be disabled in FSFWConfig)
// to determined faulty implementations and configuration errors quickly.
if (data == nullptr) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "ParameterWrapper::copyFrom: Called on read-only variable!" << std::endl;
#else
sif::printWarning("ParameterWrapper::copyFrom: Called on read-only variable!\n");
#endif
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
return READONLY;
}
if (from->readonlyData == nullptr) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "ParameterWrapper::copyFrom: Source not set!" << std::endl;
#else
sif::printWarning("ParameterWrapper::copyFrom: Source not set!\n");
#endif
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
return SOURCE_NOT_SET;
}
if (type != from->type) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "ParameterWrapper::copyFrom: Datatype missmatch!" << std::endl;
#else
sif::printWarning("ParameterWrapper::copyFrom: Datatype missmatch!\n");
#endif
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
return DATATYPE_MISSMATCH;
}
// The smallest allowed value for rows and columns is one.
if(rows == 0 or columns == 0) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "ParameterWrapper::copyFrom: Columns or rows zero!" << std::endl;
#else
sif::printWarning("ParameterWrapper::copyFrom: Columns or rows zero!\n");
#endif
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
return COLUMN_OR_ROWS_ZERO;
}
@ -289,7 +317,7 @@ ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from,
from->readonlyData, from->rows, from->columns);
break;
default:
result = UNKNOW_DATATYPE;
result = UNKNOWN_DATATYPE;
break;
}
}

View File

@ -8,14 +8,23 @@
#include <cstddef>
/**
* @brief
* @brief This wrapper encapsulates the access to parameters provided by HasParametersIF.
* @details
* This wrapper is used by the ParameterHelper to interface with the on-board parameters
* exposed by the software via the HasParametersIF. A handle of this wrapper is passed
* to the user which then can be used to set or dump the parameters.
*
* The wrapper provides a set of setter functions. The user should call those setter functions,
* supplying an address to the local parameters. The user can also deserialize or
* serialize the parameter data. Please note that this will also serialize and deserialize
* the parameter information field (4 bytes) containing the ECSS PTC, PFC and rows and columns
* number.
*/
class ParameterWrapper: public SerializeIF {
friend class DataPoolParameterWrapper;
public:
static const uint8_t INTERFACE_ID = CLASS_ID::PARAMETER_WRAPPER;
static const ReturnValue_t UNKNOW_DATATYPE = MAKE_RETURN_CODE(0x01);
static const ReturnValue_t UNKNOWN_DATATYPE = MAKE_RETURN_CODE(0x01);
static const ReturnValue_t DATATYPE_MISSMATCH = MAKE_RETURN_CODE(0x02);
static const ReturnValue_t READONLY = MAKE_RETURN_CODE(0x03);
static const ReturnValue_t TOO_BIG = MAKE_RETURN_CODE(0x04);
@ -26,8 +35,7 @@ public:
ParameterWrapper();
ParameterWrapper(Type type, uint8_t rows, uint8_t columns, void *data);
ParameterWrapper(Type type, uint8_t rows, uint8_t columns,
const void *data);
ParameterWrapper(Type type, uint8_t rows, uint8_t columns, const void *data);
virtual ~ParameterWrapper();
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
@ -77,11 +85,23 @@ public:
this->pointsToStream = false;
}
/**
* Setter function for scalar non-const entries
* @tparam T
* @param member
*/
template<typename T>
void set(T& member) {
this->set(&member, 1, 1);
}
/**
* Setter function for scalar const entries.
* TODO: This is confusing, it should not be called set. Maybe we should call all functions
* assign instead?
* @tparam T
* @param readonlyMember
*/
template<typename T>
void set(const T& readonlyMember) {
this->set(&readonlyMember, 1, 1);
@ -89,12 +109,16 @@ public:
template<typename T>
void setVector(T& member) {
this->set(member, sizeof(member)/sizeof(member[0]), 1);
/* For a vector entry, the number of rows will be one
(left to right, top to bottom indexing) */
this->set(member, 1, sizeof(member) / sizeof(member[0]));
}
template<typename T>
void setVector(const T& member) {
this->set(member, 1, sizeof(member)/sizeof(member[0]));
/* For a vector entry, the number of rows will be one
(left to right, top to bottom indexing) */
this->set(member, 1, sizeof(member) / sizeof(member[0]));
}
template<typename T>
void setMatrix(T& member) {

View File

@ -105,8 +105,8 @@ ReturnValue_t Service20ParameterManagement::prepareCommand(
ReturnValue_t Service20ParameterManagement::prepareDumpCommand(
CommandMessage* message, const uint8_t* tcData, size_t tcDataLen) {
//the first part is the objectId, but we have extracted that earlier
//and only need the parameterId
/* the first part is the objectId, but we have extracted that earlier
and only need the parameterId */
tcData += sizeof(object_id_t);
tcDataLen -= sizeof(object_id_t);
ParameterId_t parameterId;
@ -114,7 +114,7 @@ ReturnValue_t Service20ParameterManagement::prepareDumpCommand(
SerializeIF::Endianness::BIG) != HasReturnvaluesIF::RETURN_OK) {
return CommandingServiceBase::INVALID_TC;
}
//Autodeserialize should have decremented size to 0 by this point
/* The length should have been decremented to 0 by this point */
if(tcDataLen != 0) {
return CommandingServiceBase::INVALID_TC;
}
@ -140,6 +140,13 @@ ReturnValue_t Service20ParameterManagement::prepareLoadCommand(
return result;
}
/* Following format is expected: The first 4 bytes in the TC data are the 4 byte
parameter ID (ParameterId_t). The second 4 bytes are the parameter information field,
containing the following 1 byte fields:
1. ECSS PTC field
2. ECSS PFC field
3. Number of rows
4. Number of columns */
ParameterLoadCommand command(storePointer, parameterDataLen);
result = command.deSerialize(&tcData, &tcDataLen,
SerializeIF::Endianness::BIG);

View File

@ -6,6 +6,8 @@
/**
* @brief PUS Service 20 Parameter Service implementation
* @details
* This service handles PUS service requests related to parameter management and forwards
* them to the internal software bus.
* @author J. Gerhards
*
*/