From f067695353b77ccde7e33f17f0687df6838ce519 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 31 Jan 2021 17:40:20 +0100 Subject: [PATCH] printout, doc, bugfixes.. --- parameters/ParameterWrapper.cpp | 36 ++++++++++++++++++++++++---- parameters/ParameterWrapper.h | 36 +++++++++++++++++++++++----- pus/Service20ParameterManagement.cpp | 13 +++++++--- pus/Service20ParameterManagement.h | 2 ++ 4 files changed, 74 insertions(+), 13 deletions(-) diff --git a/parameters/ParameterWrapper.cpp b/parameters/ParameterWrapper.cpp index d9f1ef68..124f2eda 100644 --- a/parameters/ParameterWrapper.cpp +++ b/parameters/ParameterWrapper.cpp @@ -1,4 +1,6 @@ #include "ParameterWrapper.h" +#include +#include ParameterWrapper::ParameterWrapper() : pointsToStream(false), type(Type::UNKNOWN_TYPE) { @@ -75,7 +77,7 @@ ReturnValue_t ParameterWrapper::serialize(uint8_t **buffer, size_t *size, result = serializeData(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; } } diff --git a/parameters/ParameterWrapper.h b/parameters/ParameterWrapper.h index 168a535f..b0ca210d 100644 --- a/parameters/ParameterWrapper.h +++ b/parameters/ParameterWrapper.h @@ -8,14 +8,23 @@ #include /** - * @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 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 void set(const T& readonlyMember) { this->set(&readonlyMember, 1, 1); @@ -89,12 +109,16 @@ public: template 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 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 void setMatrix(T& member) { diff --git a/pus/Service20ParameterManagement.cpp b/pus/Service20ParameterManagement.cpp index 302b69b7..2d69f77a 100644 --- a/pus/Service20ParameterManagement.cpp +++ b/pus/Service20ParameterManagement.cpp @@ -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); diff --git a/pus/Service20ParameterManagement.h b/pus/Service20ParameterManagement.h index 3e62bc14..488edfb5 100644 --- a/pus/Service20ParameterManagement.h +++ b/pus/Service20ParameterManagement.h @@ -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 * */