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

Initial code for TC[6,9] and TM[6,10]

parent aadc2556
No related branches found
No related tags found
No related merge requests found
......@@ -18,11 +18,11 @@ add_executable(ecss_services src/main.cpp src/Message.cpp src/Service.cpp
src/Services/TestService.cpp src/Services/MemoryManagementService.cpp
src/Services/RequestVerificationService.cpp)
IF(EXISTS "${PROJECT_SOURCE_DIR}/lib/Catch2/CMakeLists.txt")
IF (EXISTS "${PROJECT_SOURCE_DIR}/lib/Catch2/CMakeLists.txt")
add_subdirectory(lib/Catch2)
add_executable(tests src/Message.cpp src/Services/TestService.cpp
src/Services/RequestVerificationService.cpp src/Services/MemoryManagementService.cpp
test/tests.cpp test/Message.cpp test/TestPlatform.cpp test/Services/TestService.cpp
test/Services/MemoryManagementService.cpp test/Services/RequestVerificationService.cpp)
src/Services/RequestVerificationService.cpp src/Services/MemoryManagementService.cpp
test/tests.cpp test/Message.cpp test/TestPlatform.cpp test/Services/TestService.cpp
test/Services/MemoryManagementService.cpp test/Services/RequestVerificationService.cpp)
target_link_libraries(tests Catch2::Catch2)
ENDIF()
ENDIF ()
#ifndef ECSS_SERVICES_MEMMANGSERVICE_HPP
#define ECSS_SERVICES_MEMMANGSERVICE_HPP
// Memory limits definitions
#define FIRST_ADRESS_FLASH 0x08000000
#define LAST_ADDRESS_FLASH 0x0801FFFF // todo: Define the last memory address based on the MCU
#define FIRST_ADDRESS_SRAM 0x20000000
#define SRAM_MEMORY_SIZE 16 // Specify the RAM size in kBytes
#include "Service.hpp"
#include <memory>
#include <iostream>
......@@ -36,6 +43,7 @@ public:
* @details This function loads new values to memory data areas
* specified in the request
* @param request: Provide the received message as a parameter
* @todo Only allow aligned memory address to be start addresses
*/
void loadRawData(Message &request);
......@@ -47,8 +55,21 @@ public:
* @param request: Provide the received message as a parameter
* @todo In later embedded version, implement error checking for address validity for
* different memory types
* @todo Only allow aligned memory address to be start addresses
*/
void dumpRawData(Message &request);
/**
* TC[6,9] check raw memory data
*
* @details This function reads the raw data from the specified memory and
* triggers a TM[6,10] report
* @param request: Provide the received message as a parameter
* @todo In later embedded version, implement error checking for address validity for
* different memory types
* @todo Only allow aligned memory address to be start addresses
*/
void checkRawData(Message &request);
} rawDataMemorySubservice;
};
......
......@@ -86,3 +86,45 @@ void MemoryManagementService::RawDataMemoryManagement::dumpRawData(Message &requ
mainService.storeMessage(report); // Save the report message
request.resetRead(); // Reset the reading count
}
void MemoryManagementService::RawDataMemoryManagement::checkRawData(Message &request) {
// Check if we have the correct packet
assert(request.serviceType == 6);
assert(request.messageType == 9);
// Create the report message object of telemetry message subtype 10
Message report = mainService.createTM(10);
// Variable declaration
uint8_t readData[ECSS_MAX_STRING_SIZE]; // Preallocate the array
uint8_t memoryID = request.readEnum8(); // Read the memory ID from the request
// todo: Add checks depending on the memory type
uint16_t iterationCount = request.readUint16(); // Get the iteration count
// Append the data to report message
report.appendEnum8(memoryID); // Memory ID
report.appendUint16(iterationCount); // Iteration count
// Iterate N times, as specified in the command message
for (std::size_t j = 0; j < iterationCount; j++) {
uint64_t startAddress = request.readUint64(); // Data length to read
uint16_t readLength = request.readUint16(); // Start address for the memory read
// Read memory data and save them for checksum calculation
for (std::size_t i = 0; i < readLength; i++) {
readData[i] = *(reinterpret_cast<uint8_t *>(startAddress) + i);
}
// This part is repeated N-times (N = iteration count)
report.appendUint64(startAddress); // Start address
report.appendUint16(readLength); // Save the read data
// todo: Calculate and append checksum in the report
//report.appendBits(16, /* checksum bits */);
}
// todo: implement and append the checksum part of the reporting packet
mainService.storeMessage(report); // Save the report message
request.resetRead(); // Reset the reading count
}
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