From 8516a91524f36c43d1c4753d707850b9427c596d Mon Sep 17 00:00:00 2001 From: Dimitrios Stoupis <dimitris.apple@gmail.com> Date: Tue, 20 Nov 2018 07:18:27 +0000 Subject: [PATCH] Better compliance with the standard --- inc/Services/MemMangService.hpp | 17 ++++++++++++----- src/Services/MemMangService.cpp | 12 ++++++++++++ src/main.cpp | 4 ++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/inc/Services/MemMangService.hpp b/inc/Services/MemMangService.hpp index e58765b7..fa3f18b9 100644 --- a/inc/Services/MemMangService.hpp +++ b/inc/Services/MemMangService.hpp @@ -3,13 +3,10 @@ #include "Service.hpp" #include <memory> +#include <iostream> class MemoryManagementService : public Service { public: - MemoryManagementService() { - serviceType = 6; - } - // Memory type ID's enum MemoryID { RAM = 0, @@ -17,6 +14,15 @@ public: EXTERNAL = 2 }; + MemoryManagementService(); + + /** + * Raw data memory management subservice class + * + * @details A class defining the raw data memory management subservice functions. + * As per the ECSS manual, each memory service has to have at most one raw memory + * data management subservice + */ class RawDataMemoryManagement { private: /** @@ -28,6 +34,7 @@ public: MemoryManagementService *mainService; // Used to access main class's members public: + explicit RawDataMemoryManagement(MemoryManagementService *parent); /** * TC[6,2] load raw values to memory * @@ -45,7 +52,7 @@ public: * @param request: Provide the received message as a parameter */ void dumpRawData(Message &request); - }; + } rawDataMemorySubservice; }; #endif //ECSS_SERVICES_MEMMANGSERVICE_HPP diff --git a/src/Services/MemMangService.cpp b/src/Services/MemMangService.cpp index 1ac3df71..69fc97db 100644 --- a/src/Services/MemMangService.cpp +++ b/src/Services/MemMangService.cpp @@ -1,6 +1,17 @@ #include "Services/MemMangService.hpp" #include <iostream> +// Define the constructors for the classes +MemoryManagementService::MemoryManagementService() : rawDataMemorySubservice(this) { + serviceType = 6; + std::cout << "Constructor creation debuffing MemMeang Service" << std::endl; +} + +MemoryManagementService::RawDataMemoryManagement::RawDataMemoryManagement( + MemoryManagementService *parent) : mainService(parent) {} + + +// Function declarations for the raw data memory management subservice void MemoryManagementService::RawDataMemoryManagement::loadRawData(Message &request) { } @@ -12,6 +23,7 @@ void MemoryManagementService::RawDataMemoryManagement::dumpRawData(Message &requ uint8_t *readData = nullptr; // Pointer to store the data read from the memory uint16_t readLength = 0; // Data length to read (updated for each new iteration) uint32_t startAddress = 0; // Start address for the memory read (updated in each new iteration) + MemoryManagementService::MemoryID meId; // Read the packet's values iterationCount = request.readUint8(); diff --git a/src/main.cpp b/src/main.cpp index 9d72df8f..a9b0bbf1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,12 +29,12 @@ int main() { testService.onBoardConnection(receivedPacket); // ST[06] testing - MemoryManagementService::RawDataMemoryManagement memMangService; + MemoryManagementService memMangService; Message rcvPack = Message(6, 2, Message::TC, 1); rcvPack.appendUint8(1); // Iteration count rcvPack.appendUint32(0x45327845); // Start address rcvPack.appendUint16(0); // Data read length - memMangService.dumpRawData(rcvPack); + memMangService.rawDataMemorySubservice.dumpRawData(rcvPack); return 0; } -- GitLab