From 53588aad704d6dcdde9a55fb18054abc5946650a Mon Sep 17 00:00:00 2001 From: thodkatz <thodkatz@gmail.com> Date: Sun, 18 Nov 2018 07:45:40 +0200 Subject: [PATCH] Implement ST[01] request vertification --- .idea/codeStyles/Project.xml | 19 ++++++ CMakeLists.txt | 2 +- inc/Services/ReqVerifService.hpp | 56 +++++++++++++++++ src/Service.cpp | 3 +- src/Services/ReqVerifService.cpp | 105 +++++++++++++++++++++++++++++++ src/Services/TestService.cpp | 2 +- src/main.cpp | 15 +++++ 7 files changed, 199 insertions(+), 3 deletions(-) create mode 100644 inc/Services/ReqVerifService.hpp create mode 100644 src/Services/ReqVerifService.cpp diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index c566bef1..efd791e8 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -2,6 +2,25 @@ <code_scheme name="Project" version="173"> <option name="RIGHT_MARGIN" value="100" /> <Objective-C-extensions> + <file> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" /> + </file> + <class> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" /> + </class> <extensions> <pair source="cpp" header="hpp" fileNamingConvention="NONE" /> <pair source="c" header="h" fileNamingConvention="NONE" /> diff --git a/CMakeLists.txt b/CMakeLists.txt index 60c3d8e9..6016165b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,4 +14,4 @@ add_custom_target(check WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/ci") # Specify the .cpp files for the executables -add_executable(ecss_services src/main.cpp src/Message.cpp src/Service.cpp src/Services/TestService.cpp) +add_executable(ecss_services src/main.cpp src/Message.cpp src/Service.cpp src/Services/TestService.cpp src/Services/ReqVerifService.cpp) diff --git a/inc/Services/ReqVerifService.hpp b/inc/Services/ReqVerifService.hpp new file mode 100644 index 00000000..42eeb1a0 --- /dev/null +++ b/inc/Services/ReqVerifService.hpp @@ -0,0 +1,56 @@ + +#ifndef ECSS_SERVICES_REQVERIFSERVICE_HPP +#define ECSS_SERVICES_REQVERIFSERVICE_HPP + +#include "Service.hpp" + +/** + * Implementation of the ST[01] request verification service + * + * @todo All telemetry packets shall have a telemetry packet secondary header + */ +class ReqVerifService : public Service { +public: + ReqVerifService() { + serviceType = 1; + } + + /** + * TM[1,1] successful acceptance verification report + */ + void successAcceptVerif(uint8_t packetVersionNum, uint8_t packetType, bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount); + + /** + * TM[1,2] failed acceptance verification report + */ + void failAccessVerif(uint8_t packetVersionNum, uint8_t packetType, bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, uint16_t code); + + + /** + * TM[1,7] successful completion of execution verification report + */ + void successExeVerif(uint8_t packetVersionNum, uint8_t packetType, bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount); + + /** + * TM[1,8] failed completion of execution verification report + */ + void failExeVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, + uint16_t code); + + /** + * TM[1,10] failed routing verification report + */ + void failRoutVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, + uint16_t code); + + +}; + +#endif //ECSS_SERVICES_REQVERIFSERVICE_HPP diff --git a/src/Service.cpp b/src/Service.cpp index 27a9f474..07403e43 100644 --- a/src/Service.cpp +++ b/src/Service.cpp @@ -7,9 +7,10 @@ void Service::storeMessage(const Message &message) { std::cout << "New " << ((message.packetType == Message::TM) ? "TM" : "TC") << "[" << std::dec << static_cast<int>(message.serviceType) << "," << static_cast<int>(message.messageType) << "] message!\n"; - std::cout << std::hex << std::setfill('0') << std::setw(2); + //std::cout << std::hex << std::setfill('0') << std::setw(2); for (int i = 0; i < message.dataSize; i++) { std::cout << static_cast<int>(message.data[i]); + std::cout << " "; } std::cout << std::endl; } diff --git a/src/Services/ReqVerifService.cpp b/src/Services/ReqVerifService.cpp new file mode 100644 index 00000000..8ebb6969 --- /dev/null +++ b/src/Services/ReqVerifService.cpp @@ -0,0 +1,105 @@ +#include "Services/ReqVerifService.hpp" + +void ReqVerifService::successAcceptVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, uint16_t APID, uint8_t seqFlag, + uint16_t packetSeqCount) { + // TM[1,1] successful acceptance verification report + assert(packetVersionNum <= 4 & packetType <= 1 & APID <= 1024 & seqFlag <= 2 & + packetSeqCount <= 8192); + + uint32_t value; + + value = (packetVersionNum << 29 | packetType << 28 | secondaryHeaderFlag << 27 | APID << 16 | + seqFlag << 14 | packetSeqCount); + + Message report = createTM(1); + + report.appendUint32(value); + + storeMessage(report); +} + +void ReqVerifService::failAccessVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, + uint16_t code) { + // TM[1,2] failed acceptance verification report + assert(packetVersionNum <= 4 & packetType <= 1 & APID <= 1024 & seqFlag <= 2 & + packetSeqCount <= 8192); + + uint32_t value; + + value = (packetVersionNum << 29 | packetType << 28 | secondaryHeaderFlag << 27 | APID << 16 | + seqFlag << 14 | packetSeqCount); + + Message report = createTM(2); + + report.appendUint32(value); + + report.appendUint16(code); + + storeMessage(report); +} + +void ReqVerifService::successExeVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, uint16_t APID, uint8_t seqFlag, + uint16_t packetSeqCount) { + // TM[1,7] successful completion of execution verification report + assert(packetVersionNum <= 4 & packetType <= 1 & APID <= 1024 & seqFlag <= 2 & + packetSeqCount <= 8192); + + uint32_t value; + + value = (packetVersionNum << 29 | packetType << 28 | secondaryHeaderFlag << 27 | APID << 16 | + seqFlag << 14 | packetSeqCount); + + Message report = createTM(7); + + report.appendUint32(value); + + storeMessage(report); +} + +void ReqVerifService::failExeVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, + uint16_t code) { + // TM[1,8] failed completion of execution verification report + assert(packetVersionNum <= 4 & packetType <= 1 & APID <= 1024 & seqFlag <= 2 & + packetSeqCount <= 8192); + + uint32_t value; + + value = (packetVersionNum << 29 | packetType << 28 | secondaryHeaderFlag << 27 | APID << 16 | + seqFlag << 14 | packetSeqCount); + + Message report = createTM(8); + + report.appendUint32(value); + + report.appendUint16(code); + + storeMessage(report); +} + +void ReqVerifService::failRoutVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, + uint16_t code) { + // TM[1,10] failed routing verification report + assert(packetVersionNum <= 4 & packetType <= 1 & APID <= 1024 & seqFlag <= 2 & + packetSeqCount <= 8192); + + uint32_t value; + + value = (packetVersionNum << 29 | packetType << 28 | secondaryHeaderFlag << 27 | APID << 16 | + seqFlag << 14 | packetSeqCount); + + Message report = createTM(10); + + report.appendUint32(value); + + report.appendUint16(code); + + storeMessage(report); +} \ No newline at end of file diff --git a/src/Services/TestService.cpp b/src/Services/TestService.cpp index 06f60263..d7d83a94 100644 --- a/src/Services/TestService.cpp +++ b/src/Services/TestService.cpp @@ -12,6 +12,6 @@ void TestService::onBoardConnection(Message &request) { Message report = createTM(4); report.appendUint16(request.readUint16()); - + //just print it on the screen storeMessage(report); } diff --git a/src/main.cpp b/src/main.cpp index cc24193a..0ee6aeac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include <iostream> #include <Services/TestService.hpp> +#include <Services/ReqVerifService.hpp> #include "Message.hpp" int main() { @@ -27,5 +28,19 @@ int main() { receivedPacket.appendUint16(7); testService.onBoardConnection(receivedPacket); + // ST[01] test + // parameters take random values and works as expected + ReqVerifService reqVerifService; + receivedPacket = Message(1, 1, Message::TC, 2); + reqVerifService.successAcceptVerif(2, 0, 1, 2, 2, 10); + receivedPacket = Message(1, 2, Message::TC, 2); + reqVerifService.failAccessVerif(2, 0, 1, 2, 2, 10, 5); + receivedPacket = Message(1, 7, Message::TC, 2); + reqVerifService.successExeVerif(2, 0, 1, 2, 2, 10); + receivedPacket = Message(1, 8, Message::TC, 2); + reqVerifService.failExeVerif(2, 0, 1, 2, 2, 10, 6); + receivedPacket = Message(1, 10, Message::TC, 2); + reqVerifService.failRoutVerif(2, 0, 1, 2, 2, 10, 7); + return 0; } -- GitLab