Skip to content
Snippets Groups Projects
Unverified Commit 8eb0a44b authored by Dimitrios Stoupis's avatar Dimitrios Stoupis
Browse files

Implement the service in a better way

parent d834dc4c
No related branches found
No related tags found
No related merge requests found
...@@ -2,18 +2,50 @@ ...@@ -2,18 +2,50 @@
#define ECSS_SERVICES_MEMMANGSERVICE_HPP #define ECSS_SERVICES_MEMMANGSERVICE_HPP
#include "Service.hpp" #include "Service.hpp"
#include <memory>
class MemMangService : public Service { class MemoryManagementService : public Service {
public: public:
MemMangService() { MemoryManagementService() {
serviceType = 6; serviceType = 6;
} }
void loadRawMemData(Message &requset); // Memory type ID's
enum MemoryID {
RAM = 0,
FLASH = 1,
EXTERNAL = 2
};
void dumpRawMemData(Message &request); class RawDataMemoryManagement {
private:
/**
* TM[6,6] dumped raw memory data report
*
* @details This report is triggered through TC[6,5]
*/
void dumpedRawDataReport();
MemoryManagementService *mainService; // Used to access main class's members
uint32_t dumpedRawMemData(); public:
/**
* TC[6,2] load raw values to memory
*
* @details This function loads new values to memory data areas
* specified in the request
* @param request: Provide the received message as a parameter
*/
void loadRawData(Message &request);
/**
* TC[6,5] read raw memory values
*
* @details This function reads the raw data from the RAM memory and
* triggers a TM[6,6] report
* @param request: Provide the received message as a parameter
*/
void dumpRawData(Message &request);
};
}; };
#endif //ECSS_SERVICES_MEMMANGSERVICE_HPP #endif //ECSS_SERVICES_MEMMANGSERVICE_HPP
#include "Services/MemMangService.hpp" #include "Services/MemMangService.hpp"
#include <iostream>
void MemMangService::loadRawMemData(Message &requset) { void MemoryManagementService::RawDataMemoryManagement::loadRawData(Message &request) {
} }
void MemMangService::dumpRawMemData(Message &request) { void MemoryManagementService::RawDataMemoryManagement::dumpRawData(Message &request) {
Message report = mainService->createTM(6); // Create the report message object of telemetry message subtype 6
uint8_t iterationCount = 0; // Get the iteration count
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)
// Read the packet's values
iterationCount = request.readUint8();
startAddress = request.readUint32();
readLength = request.readUint16();
readData = (uint8_t *)malloc(static_cast<std::size_t >(readLength + 1));
for (std::size_t i = 0; i < readLength; i++) {
readData[i] = *(uint8_t *)(startAddress + i);
}
readData[readLength] = '\0';
report.appendUint8(iterationCount); // Iteration count
report.appendUint32(startAddress); // Start address
report.appendUint16(readLength); // Data read length
//report.appendString(readLength, static_cast<const char *>(readData));
// todo: add the rest of data fields
// todo: complete the function and fully specify it
mainService->storeMessage(report);
} }
uint32_t MemMangService::dumpedRawMemData() { void MemoryManagementService::RawDataMemoryManagement::dumpedRawDataReport() {
} }
\ No newline at end of file
#include <iostream> #include <iostream>
#include <Services/TestService.hpp> #include <Services/TestService.hpp>
#include "Message.hpp" #include "Message.hpp"
#include "Services/MemMangService.hpp"
int main() { int main() {
Message packet = Message(0, 0, Message::TC, 1); Message packet = Message(0, 0, Message::TC, 1);
...@@ -27,5 +28,13 @@ int main() { ...@@ -27,5 +28,13 @@ int main() {
receivedPacket.appendUint16(7); receivedPacket.appendUint16(7);
testService.onBoardConnection(receivedPacket); testService.onBoardConnection(receivedPacket);
// ST[06] testing
MemoryManagementService::RawDataMemoryManagement 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);
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment