diff --git a/docs/ecss_overview.md b/docs/ecss_overview.md index 82e0011181d26b321d3163e2f5bb1d947e97eb54..ba95f4d2cc280dd5d5bb119d90fc4fb522380a67 100644 --- a/docs/ecss_overview.md +++ b/docs/ecss_overview.md @@ -63,6 +63,8 @@ Each service is further divided into some **subservices** that are logical group large space mission may split every subservice into different parts of the hardware. However, this implementation _makes no distinction between subservices_. +### Standard's Services + <b>`ST[01]`: Request verification</b> Provides acknowledgement or failure reports for executed commands. This service essentially informs the operators about @@ -182,7 +184,11 @@ Provides the capability of executing TCs when the spacecraft reaches a specific Provides the capability of managing on-board file systems, with functions such as *copy*, *move*, *delete*, or *create directory*. -The capability also exists to define _custom_ services and message types, if needed for each mission. +### Custom Services + +<b>`ST[128]`: Dummy Service</b> + +Provides the capability of storing log strings as ECSS Messages. ## Trivia - Version C of the standard contains 656 pages, often filled with verbose requirements and difficult definitions. Every diff --git a/inc/Platform/x86/ECSS_Configuration.hpp b/inc/Platform/x86/ECSS_Configuration.hpp index 6dbedb3a135a1eba0f72b7d4f6c2e30c0569506f..1871be15d8593871f00866fb9b167262d55948f9 100644 --- a/inc/Platform/x86/ECSS_Configuration.hpp +++ b/inc/Platform/x86/ECSS_Configuration.hpp @@ -19,6 +19,7 @@ */ #define SERVICE_ALL ///< Enables compilation of all the ECSS services +#define SERVICE_DUMMY ///< Compile ST[128] dummy service #define SERVICE_EVENTACTION ///< Compile ST[19] event-action #define SERVICE_EVENTREPORT ///< Compile ST[05] event reporting #define SERVICE_FUNCTION ///< Compile ST[08] function management diff --git a/inc/ServicePool.hpp b/inc/ServicePool.hpp index 47ff8595a6c909500d7aa9491f304054845a6d63..b93a7dbae7cdc3a439c5da17694f06fc08064ff3 100644 --- a/inc/ServicePool.hpp +++ b/inc/ServicePool.hpp @@ -2,20 +2,21 @@ #define ECSS_SERVICES_SERVICEPOOL_HPP #include "ECSS_Configuration.hpp" -#include "Services/TimeBasedSchedulingService.hpp" -#include "Services/LargePacketTransferService.hpp" -#include "Services/RequestVerificationService.hpp" -#include "Services/EventReportService.hpp" +#include "Services/DummyService.hpp" #include "Services/EventActionService.hpp" -#include "Services/ParameterService.hpp" -#include "Services/TestService.hpp" -#include "Services/MemoryManagementService.hpp" +#include "Services/EventReportService.hpp" #include "Services/FunctionManagementService.hpp" -#include "Services/StorageAndRetrievalService.hpp" #include "Services/HousekeepingService.hpp" +#include "Services/LargePacketTransferService.hpp" +#include "Services/MemoryManagementService.hpp" +#include "Services/OnBoardMonitoringService.hpp" +#include "Services/ParameterService.hpp" #include "Services/ParameterStatisticsService.hpp" #include "Services/RealTimeForwardingControlService.hpp" -#include "Services/OnBoardMonitoringService.hpp" +#include "Services/RequestVerificationService.hpp" +#include "Services/StorageAndRetrievalService.hpp" +#include "Services/TestService.hpp" +#include "Services/TimeBasedSchedulingService.hpp" /** * Defines a class that contains instances of all Services. @@ -39,6 +40,10 @@ class ServicePool { uint16_t packetSequenceCounter = 0; public: +#ifdef SERVICE_DUMMY + DummyService dummyService; +#endif + #ifdef SERVICE_EVENTACTION EventActionService eventAction; #endif diff --git a/inc/Services/DummyService.hpp b/inc/Services/DummyService.hpp new file mode 100644 index 0000000000000000000000000000000000000000..605825d70ab1e015a075713643126d8b382ab15d --- /dev/null +++ b/inc/Services/DummyService.hpp @@ -0,0 +1,34 @@ +#ifndef ECSS_SERVICES_DUMMYSERVICE_HPP +#define ECSS_SERVICES_DUMMYSERVICE_HPP + +#include "Logger_Definitions.hpp" +#include "Service.hpp" + +/** + * This is a dummy Service used during testing. Its functionality is to contain LOG_ data but be sent through CAN bus. + * During the environmental tests, we will use both CAN and UART to send data from the MCU to the PC. However, the + * current CAN protocol does not accommodate random data strings. Therefore, we will use this dummy service to send such + * messages. + * + * Per the ECSS-E-ST-70-41C standard, p. 27-28, custom Services and Messages should start above 127. + */ +class DummyService : public Service { + +public: + inline static const uint8_t ServiceType = 128; + enum MessageType : uint8_t { + LogString = 128, + }; + + /** + * Send data as a part of a custom ECSS Message + * Creates a TM[128, 128] + */ + void logAsECSSMessage(const etl::string<LOGGER_MAX_MESSAGE_SIZE>& data) { + Message log(ServiceType, MessageType::LogString, Message::TM, 1); + log.appendString(data); + storeMessage(log); + } +}; + +#endif //ECSS_SERVICES_DUMMYSERVICE_HPP diff --git a/test/Services/DummyService.cpp b/test/Services/DummyService.cpp new file mode 100644 index 0000000000000000000000000000000000000000..188d1899c5d0877a4fac14d62f1ab77206b75226 --- /dev/null +++ b/test/Services/DummyService.cpp @@ -0,0 +1,17 @@ +#include "Services/DummyService.hpp" +#include <catch2/catch_all.hpp> +#include "ServicePool.hpp" +#include "ServiceTests.hpp" + +DummyService& dummyService = Services.dummyService; + +TEST_CASE("Log string as message TM[128, 128]", "[service][st128]") { + etl::string<LOGGER_MAX_MESSAGE_SIZE> log = "An amazing log that is very informative"; + dummyService.logAsECSSMessage(log); + Message report = ServiceTests::get(0); + CHECK(report.serviceType == DummyService::ServiceType); + CHECK(report.messageType == DummyService::MessageType::LogString); + char logOutput[39]; + report.readString(logOutput, 39); + CHECK(strcmp(logOutput, "An amazing log that is very informative") == 0); +}