From 58b6baffa694a9d1ae301050fc5aee9698fbbb4a Mon Sep 17 00:00:00 2001 From: kongr45gpen <electrovesta@gmail.com> Date: Fri, 9 Aug 2019 15:01:08 +0300 Subject: [PATCH] Move some definitions from source files into ECSS_Definitions.hpp Update documentation for the ECSS definitions Group Services and ECSS Definitions into a doxygen page --- inc/ECSS_Definitions.hpp | 34 ++++++++++++++++++++- inc/Service.hpp | 6 ++++ inc/Services/EventActionService.hpp | 1 + inc/Services/EventReportService.hpp | 1 + inc/Services/FunctionManagementService.hpp | 11 +++---- inc/Services/LargePacketTransferService.hpp | 2 ++ inc/Services/MemoryManagementService.hpp | 3 ++ inc/Services/ParameterService.hpp | 7 ++--- inc/Services/RequestVerificationService.hpp | 2 ++ inc/Services/TestService.hpp | 2 ++ inc/Services/TimeBasedSchedulingService.hpp | 2 ++ inc/Services/TimeManagementService.hpp | 1 + src/Services/FunctionManagementService.cpp | 19 ++++++------ test/Services/FunctionManagementService.cpp | 18 +++++------ 14 files changed, 79 insertions(+), 30 deletions(-) diff --git a/inc/ECSS_Definitions.hpp b/inc/ECSS_Definitions.hpp index bd877915..05ab25c7 100644 --- a/inc/ECSS_Definitions.hpp +++ b/inc/ECSS_Definitions.hpp @@ -2,11 +2,20 @@ #define ECSS_SERVICES_ECSS_DEFINITIONS_H /** - * @file + * @defgroup ECSSDefinitions ECSS Defined Constants + * * This file contains constant definitions that are used throughout the ECSS services. They often refer to maximum * values and upper limits for the storage of data in the services. * * @todo All these constants need to be redefined and revised after the design and the requirements are finalized. + * + * @{ + */ + +/** + * @file + * This file contains constant definitions that are used throughout the ECSS services. + * @see ECSSDefinitions */ /** @@ -91,6 +100,29 @@ */ #define ECSS_MAX_DELTA_OF_RELEASE_TIME 60 +/** + * The maximum number of stored parameters in the \ref ParameterService + */ +#define ECSS_MAX_PARAMETERS 5 + +/** + * The number of functions supported by the \ref FunctionManagementService + */ +#define ECSS_FUNCTION_MAP_SIZE 5 + +/** + * The maximum length of a function name, in bytes + * @see FunctionManagementService + */ +#define ECSS_FUNCTION_NAME_LENGTH 32 + +/** + * The maximum length of the argument of a function + * @see FunctionManagementService + */ +#define ECSS_FUNCTION_MAX_ARG_LENGTH 32 + +/** @} */ /** * @brief The maximum size of a log message diff --git a/inc/Service.hpp b/inc/Service.hpp index d7a8ee43..e28620ff 100644 --- a/inc/Service.hpp +++ b/inc/Service.hpp @@ -6,6 +6,12 @@ class ServicePool; +/** + * @defgroup Services Services + * ECSS Services implementations, as defined in ECSS-E-ST-70-41C. These services receive TC Messages, and output TM + * Messages. + */ + /** * A spacecraft service, as defined in ECSS-E-ST-70-41C * diff --git a/inc/Services/EventActionService.hpp b/inc/Services/EventActionService.hpp index aac524c0..799ae996 100644 --- a/inc/Services/EventActionService.hpp +++ b/inc/Services/EventActionService.hpp @@ -11,6 +11,7 @@ * * ECSS 8.19 && 6.19 * + * @ingroup Services * @note: Make sure to check the note in the addEventActionDefinition() * @note: A third variable was added, the eventActionDefinitionID. This was added for the purpose of identifying * various eventActionDefinitions that correspond to the same eventDefinitionID. The goal is to have multiple actions diff --git a/inc/Services/EventReportService.hpp b/inc/Services/EventReportService.hpp index d1eac70f..f9b01634 100644 --- a/inc/Services/EventReportService.hpp +++ b/inc/Services/EventReportService.hpp @@ -7,6 +7,7 @@ /** * Implementation of ST[05] event reporting service * + * @ingroup Services * @todo: add more enums event IDs * @todo: Make sure there isn't an event ID == 0, because there's a confliction with another service * Note: enum IDs are these just for test purposes diff --git a/inc/Services/FunctionManagementService.hpp b/inc/Services/FunctionManagementService.hpp index 512ce3e3..401591ef 100644 --- a/inc/Services/FunctionManagementService.hpp +++ b/inc/Services/FunctionManagementService.hpp @@ -7,10 +7,6 @@ #include "Service.hpp" #include "ErrorHandler.hpp" -#define FUNC_MAP_SIZE 5 // size of the function map (number of elements) -#define FUNC_NAME_LENGTH 32 // max length of the function name -#define MAX_ARG_LENGTH 32 // maximum argument byte string length - /** * Implementation of the ST[08] function management service * @@ -25,6 +21,7 @@ * * You have been warned. * + * @ingroup Services * @author Grigoris Pavlakis <grigpavl@ece.auth.gr> */ @@ -51,8 +48,8 @@ * } */ -typedef String<FUNC_NAME_LENGTH> functionName; -typedef etl::map<functionName, void (*)(String<MAX_ARG_LENGTH>), FUNC_MAP_SIZE> FunctionMap; +typedef String<ECSS_FUNCTION_NAME_LENGTH> functionName; +typedef etl::map<functionName, void (*)(String<ECSS_FUNCTION_MAX_ARG_LENGTH>), ECSS_FUNCTION_MAP_SIZE> FunctionMap; class FunctionManagementService : public Service { /** @@ -85,7 +82,7 @@ public: * @param ptr pointer to a function of void return type and a MAX_ARG_LENGTH-lengthed byte * string as argument (which contains the actual arguments of the function) */ - void include(String<FUNC_NAME_LENGTH> funcName, void (*ptr)(String<MAX_ARG_LENGTH>)); + void include(String<ECSS_FUNCTION_NAME_LENGTH> funcName, void (*ptr)(String<ECSS_FUNCTION_MAX_ARG_LENGTH>)); int getMapSize() { return funcPtrIndex.size(); diff --git a/inc/Services/LargePacketTransferService.hpp b/inc/Services/LargePacketTransferService.hpp index 533a3ba0..cbd74f8e 100644 --- a/inc/Services/LargePacketTransferService.hpp +++ b/inc/Services/LargePacketTransferService.hpp @@ -10,6 +10,8 @@ * maximum data size * * Note: More information can be found in the standards' manual, in p. 526-528 and in p. 229-236 + * + * @ingroup Services */ class LargePacketTransferService : public Service { diff --git a/inc/Services/MemoryManagementService.hpp b/inc/Services/MemoryManagementService.hpp index f61ebad7..f5c1770e 100644 --- a/inc/Services/MemoryManagementService.hpp +++ b/inc/Services/MemoryManagementService.hpp @@ -8,6 +8,9 @@ #include "ErrorHandler.hpp" #include "Platform/STM32F7/MemoryAddressLimits.hpp" +/** + * @ingroup Services + */ class MemoryManagementService : public Service { public: // Memory type ID's diff --git a/inc/Services/ParameterService.hpp b/inc/Services/ParameterService.hpp index 73879332..6b2a7af7 100644 --- a/inc/Services/ParameterService.hpp +++ b/inc/Services/ParameterService.hpp @@ -5,9 +5,6 @@ #include "ErrorHandler.hpp" #include "etl/map.h" -// Number of stored parameters. MAX_PARAMS is just a dummy number for now. -#define MAX_PARAMS 5 - /** * Implementation of the ST[20] parameter management service, * as defined in ECSS-E-ST-70-41C @@ -39,11 +36,13 @@ struct Parameter { * * The parameter list is stored in a map with the parameter IDs as keys and values * corresponding Parameter structs containing the PTC, PFC and the parameter's value. + * + * @ingroup Services */ class ParameterService : public Service { private: - etl::map<ParamId, Parameter, MAX_PARAMS> paramsList; + etl::map<ParamId, Parameter, ECSS_MAX_PARAMETERS> paramsList; uint16_t numOfValidIds(Message idMsg); // count the valid ids in a given TC[20, 1] public: diff --git a/inc/Services/RequestVerificationService.hpp b/inc/Services/RequestVerificationService.hpp index 2d091de4..c790029a 100644 --- a/inc/Services/RequestVerificationService.hpp +++ b/inc/Services/RequestVerificationService.hpp @@ -15,6 +15,8 @@ * * @todo See if the deduced data defined from the standard should still be ignored. This deduced * data exists only in reports that send failure signs(for example the TM[1,2]) + * + * @ingroup Services */ class RequestVerificationService : public Service { public: diff --git a/inc/Services/TestService.hpp b/inc/Services/TestService.hpp index 8ed5d917..bb344af8 100644 --- a/inc/Services/TestService.hpp +++ b/inc/Services/TestService.hpp @@ -5,6 +5,8 @@ /** * Implementation of the ST[17] test service + * + * @ingroup Services */ class TestService : public Service { public: diff --git a/inc/Services/TimeBasedSchedulingService.hpp b/inc/Services/TimeBasedSchedulingService.hpp index 14581131..cc7e119a 100644 --- a/inc/Services/TimeBasedSchedulingService.hpp +++ b/inc/Services/TimeBasedSchedulingService.hpp @@ -41,6 +41,8 @@ struct Tester; * ground. * @todo Define whether the parsed absolute release time is saved in the scheduled activity as an * uint32_t or in the time format specified by the time management service. + * + * @ingroup Services */ class TimeBasedSchedulingService : public Service { private: diff --git a/inc/Services/TimeManagementService.hpp b/inc/Services/TimeManagementService.hpp index 4b6663c1..22e2aefb 100644 --- a/inc/Services/TimeManagementService.hpp +++ b/inc/Services/TimeManagementService.hpp @@ -7,6 +7,7 @@ /** * Implementation of the ST[09] time management. * + * @ingroup Services * @notes * There is a noticeable difference between setting the time using GPS and setting the time * using space packets from the ground segment. The GPS module sends the actual time of UTC (123519 diff --git a/src/Services/FunctionManagementService.cpp b/src/Services/FunctionManagementService.cpp index c3831872..cefd9702 100644 --- a/src/Services/FunctionManagementService.cpp +++ b/src/Services/FunctionManagementService.cpp @@ -7,13 +7,13 @@ void FunctionManagementService::call(Message& msg) { ErrorHandler::assertRequest(msg.messageType == 1, msg, ErrorHandler::AcceptanceErrorType::UnacceptableMessage); ErrorHandler::assertRequest(msg.serviceType == 8, msg, ErrorHandler::AcceptanceErrorType::UnacceptableMessage); - uint8_t funcName[FUNC_NAME_LENGTH] = { 0 }; // the function's name - uint8_t funcArgs[MAX_ARG_LENGTH] = { 0 }; // arguments for the function + uint8_t funcName[ECSS_FUNCTION_NAME_LENGTH] = { 0 }; // the function's name + uint8_t funcArgs[ECSS_FUNCTION_MAX_ARG_LENGTH] = { 0 }; // arguments for the function - msg.readString(funcName, FUNC_NAME_LENGTH); - msg.readString(funcArgs, MAX_ARG_LENGTH); + msg.readString(funcName, ECSS_FUNCTION_NAME_LENGTH); + msg.readString(funcArgs, ECSS_FUNCTION_MAX_ARG_LENGTH); - if (msg.dataSize > (FUNC_NAME_LENGTH + MAX_ARG_LENGTH)) { + if (msg.dataSize > (ECSS_FUNCTION_NAME_LENGTH + ECSS_FUNCTION_MAX_ARG_LENGTH)) { ErrorHandler::reportError(msg, ErrorHandler::ExecutionStartErrorType::UnknownExecutionStartError); // report failed // start of execution as requested by the standard @@ -21,9 +21,9 @@ void FunctionManagementService::call(Message& msg) { } // locate the appropriate function pointer - String<FUNC_NAME_LENGTH> name(funcName); + String<ECSS_FUNCTION_NAME_LENGTH> name(funcName); FunctionMap::iterator iter = funcPtrIndex.find(name); - void (*selected)(String<MAX_ARG_LENGTH>); + void (*selected)(String<ECSS_FUNCTION_MAX_ARG_LENGTH>); if (iter != funcPtrIndex.end()) { selected = *iter->second; @@ -36,10 +36,11 @@ void FunctionManagementService::call(Message& msg) { selected(funcArgs); } -void FunctionManagementService::include(String<FUNC_NAME_LENGTH> funcName, void (*ptr)(String<MAX_ARG_LENGTH>)) { +void FunctionManagementService::include(String<ECSS_FUNCTION_NAME_LENGTH> funcName, + void (* ptr)(String<ECSS_FUNCTION_MAX_ARG_LENGTH>)) { if (not funcPtrIndex.full()) { // CAUTION: etl::map won't check by itself if it's full // before attempting to insert a key-value pair, causing segmentation faults. Check first! - funcName.append(FUNC_NAME_LENGTH - funcName.length(), 0); + funcName.append(ECSS_FUNCTION_NAME_LENGTH - funcName.length(), 0); funcPtrIndex.insert(std::make_pair(funcName, ptr)); } else { ErrorHandler::reportInternalError(ErrorHandler::InternalErrorType::FunctionMapFull); diff --git a/test/Services/FunctionManagementService.cpp b/test/Services/FunctionManagementService.cpp index 45088a86..92cd24c4 100644 --- a/test/Services/FunctionManagementService.cpp +++ b/test/Services/FunctionManagementService.cpp @@ -8,7 +8,7 @@ FunctionManagementService& fms = Services.functionManagement; uint8_t globalVariable = 10; -void test(String<MAX_ARG_LENGTH> a) { +void test(String<ECSS_FUNCTION_MAX_ARG_LENGTH> a) { globalVariable = a[0]; } @@ -17,10 +17,10 @@ TEST_CASE("ST[08] - Call Tests") { ServiceTests::reset(); globalVariable = 10; - fms.include(String<FUNC_NAME_LENGTH>("test"), &test); + fms.include(String<ECSS_FUNCTION_NAME_LENGTH>("test"), &test); Message msg(8, 1, Message::TC, 1); - msg.appendFixedString(String<FUNC_NAME_LENGTH>("test")); + msg.appendFixedString(String<ECSS_FUNCTION_NAME_LENGTH>("test")); msg.appendByte(199); MessageParser::execute(msg); @@ -32,9 +32,9 @@ TEST_CASE("ST[08] - Call Tests") { ServiceTests::reset(); globalVariable = 10; - fms.include(String<FUNC_NAME_LENGTH>("test"), &test); + fms.include(String<ECSS_FUNCTION_NAME_LENGTH>("test"), &test); Message msg(8, 1, Message::TC, 1); - msg.appendFixedString(String<FUNC_NAME_LENGTH>("t3st")); + msg.appendFixedString(String<ECSS_FUNCTION_NAME_LENGTH>("t3st")); MessageParser::execute(msg); CHECK(ServiceTests::get(0).messageType == 4); @@ -47,9 +47,9 @@ TEST_CASE("ST[08] - Call Tests") { ServiceTests::reset(); globalVariable = 10; - fms.include(String<FUNC_NAME_LENGTH>("test"), &test); + fms.include(String<ECSS_FUNCTION_NAME_LENGTH>("test"), &test); Message msg(8, 1, Message::TC, 1); - msg.appendFixedString(String<FUNC_NAME_LENGTH>("test")); + msg.appendFixedString(String<ECSS_FUNCTION_NAME_LENGTH>("test")); msg.appendString(String<65> ("eqrhjweghjhwqgthjkrghthjkdsfhgsdfhjsdjsfdhgkjdfsghfjdgkdfsgdfgsgd")); MessageParser::execute(msg); @@ -67,9 +67,9 @@ TEST_CASE("ST[08] - Insert Tests") { ServiceTests::reset(); std::string name = "test"; // FOR TESTING ONLY! - for (int i = 0; i < FUNC_MAP_SIZE + 1; i++) { + for (int i = 0; i < ECSS_FUNCTION_MAP_SIZE + 1; i++) { name += std::to_string(i); // different names to fill up the map - fms.include(String<FUNC_NAME_LENGTH>(name.c_str()), &test); + fms.include(String<ECSS_FUNCTION_NAME_LENGTH>(name.c_str()), &test); } CHECK(ServiceTests::thrownError(ErrorHandler::InternalErrorType::FunctionMapFull)); } -- GitLab