From edfa0e849879123ecf3a548e8749afa64c37df8a Mon Sep 17 00:00:00 2001 From: thodkatz <thodkatz@gmail.com> Date: Sun, 18 Nov 2018 20:29:27 +0200 Subject: [PATCH] Some suggestions have been integrated --- CMakeLists.txt | 2 +- inc/Services/ReqVerifService.hpp | 56 --------- inc/Services/RequestVerificationService.hpp | 57 +++++++++ src/Services/ReqVerifService.cpp | 105 ----------------- src/Services/RequestVerificationService.cpp | 123 ++++++++++++++++++++ src/main.cpp | 14 +-- 6 files changed, 188 insertions(+), 169 deletions(-) delete mode 100644 inc/Services/ReqVerifService.hpp create mode 100644 inc/Services/RequestVerificationService.hpp delete mode 100644 src/Services/ReqVerifService.cpp create mode 100644 src/Services/RequestVerificationService.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6016165b..61383de4 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 src/Services/ReqVerifService.cpp) +add_executable(ecss_services src/main.cpp src/Message.cpp src/Service.cpp src/Services/TestService.cpp src/Services/RequestVerificationService.cpp) diff --git a/inc/Services/ReqVerifService.hpp b/inc/Services/ReqVerifService.hpp deleted file mode 100644 index 42eeb1a0..00000000 --- a/inc/Services/ReqVerifService.hpp +++ /dev/null @@ -1,56 +0,0 @@ - -#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/inc/Services/RequestVerificationService.hpp b/inc/Services/RequestVerificationService.hpp new file mode 100644 index 00000000..fc69b08b --- /dev/null +++ b/inc/Services/RequestVerificationService.hpp @@ -0,0 +1,57 @@ + +#ifndef ECSS_SERVICES_REQUSTVERIFICATIONSERVICE_HPP +#define ECSS_SERVICES_REQUESTVERIFICATIONSERVICE_HPP + +#include "Service.hpp" + +/** + * Implementation of the ST[01] request verification service + * + * @todo All telemetry packets shall have a telemetry packet secondary header + */ +class RequestVerificationService : public Service { +public: + RequestVerificationService() { + serviceType = 1; + } + + /** + * TM[1,1] successful acceptance verification report + */ + void successAcceptanceVerification(uint8_t packetType, bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount); + + /** + * TM[1,2] failed acceptance verification report + */ + void failAcceptanceVerification(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 successExecutionVerification(uint8_t packetType, bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount); + + /** + * TM[1,8] failed completion of execution verification report + */ + void failExecutionVerification(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 failRoutingVerification(uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, + uint16_t code); + + +}; + +#endif //ECSS_SERVICES_REQUESTVERIFICATIONSERVICE_HPP diff --git a/src/Services/ReqVerifService.cpp b/src/Services/ReqVerifService.cpp deleted file mode 100644 index 8ebb6969..00000000 --- a/src/Services/ReqVerifService.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#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/RequestVerificationService.cpp b/src/Services/RequestVerificationService.cpp new file mode 100644 index 00000000..00ca89d9 --- /dev/null +++ b/src/Services/RequestVerificationService.cpp @@ -0,0 +1,123 @@ +#include "Services/RequestVerificationService.hpp" + +void RequestVerificationService::successAcceptanceVerification(uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, + uint16_t packetSeqCount) { + // TM[1,1] successful acceptance verification report + assert(packetType <= 1); + assert(APID <= 1024); + assert(seqFlag <= 2); + assert(packetSeqCount <= 8192); + + Message report = createTM(1); + + report.appendBits(3, ECSS_PUS_VERSION); //packet version number + report.appendBits(1, packetType); + report.appendBits(1, (uint16_t) secondaryHeaderFlag); + report.appendBits(11, APID); + report.appendBits(2, seqFlag); + report.appendBits(14, packetSeqCount); + + storeMessage(report); +} + +void +RequestVerificationService::failAcceptanceVerification(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(packetType <= 1); + assert(APID <= 1024); + assert(seqFlag <= 2); + assert(packetSeqCount <= 8192); + + Message report = createTM(2); + + report.appendBits(3, ECSS_PUS_VERSION); //packet version number + report.appendBits(1, packetType); + report.appendBits(1, (uint16_t) secondaryHeaderFlag); + report.appendBits(11, APID); + report.appendBits(2, seqFlag); + report.appendBits(14, packetSeqCount); + + report.appendUint16(code); + + storeMessage(report); +} + +void RequestVerificationService::successExecutionVerification(uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, + uint16_t packetSeqCount) { + // TM[1,7] successful completion of execution verification report + assert(packetType <= 1); + assert(APID <= 1024); + assert(seqFlag <= 2); + assert(packetSeqCount <= 8192); + + Message report = createTM(7); + + report.appendBits(3, ECSS_PUS_VERSION); //packet version number + report.appendBits(1, packetType); + report.appendBits(1, (uint16_t) secondaryHeaderFlag); + report.appendBits(11, APID); + report.appendBits(2, seqFlag); + report.appendBits(14, packetSeqCount); + + storeMessage(report); +} + +void +RequestVerificationService::failExecutionVerification(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(packetType <= 1); + assert(APID <= 1024); + assert(seqFlag <= 2); + assert(packetSeqCount <= 8192); + + Message report = createTM(8); + + report.appendBits(3, ECSS_PUS_VERSION); //packet version number + report.appendBits(1, packetType); + report.appendBits(1, (uint16_t) secondaryHeaderFlag); + report.appendBits(11, APID); + report.appendBits(2, seqFlag); + report.appendBits(14, packetSeqCount); + + report.appendUint16(code); + + storeMessage(report); +} + +void +RequestVerificationService::failRoutingVerification(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(packetType <= 1); + assert(APID <= 1024); + assert(seqFlag <= 2); + assert(packetSeqCount <= 8192); + + Message report = createTM(10); + + report.appendBits(3, ECSS_PUS_VERSION); //packet version number + report.appendBits(1, packetType); + report.appendBits(1, (uint16_t) secondaryHeaderFlag); + report.appendBits(11, APID); + report.appendBits(2, seqFlag); + report.appendBits(14, packetSeqCount); + + report.appendUint16(code); + + storeMessage(report); +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index efa422e1..a80938a5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,6 @@ #include <iostream> #include <Services/TestService.hpp> -#include <Services/ReqVerifService.hpp> +#include <Services/RequestVerificationService.hpp> #include "Message.hpp" int main() { @@ -31,17 +31,17 @@ int main() { // ST[01] test // parameters take random values and works as expected - ReqVerifService reqVerifService; + RequestVerificationService reqVerifService; receivedPacket = Message(1, 1, Message::TC, 2); - reqVerifService.successAcceptVerif(2, 0, 1, 2, 2, 10); + reqVerifService.successAcceptanceVerification(0, (uint8_t )1, 2, 2, 10); receivedPacket = Message(1, 2, Message::TC, 2); - reqVerifService.failAccessVerif(2, 0, 1, 2, 2, 10, 5); + reqVerifService.failAcceptanceVerification(0, (uint8_t )1, 2, 2, 10, 5); receivedPacket = Message(1, 7, Message::TC, 2); - reqVerifService.successExeVerif(2, 0, 1, 2, 2, 10); + reqVerifService.successExecutionVerification(0, (uint8_t )1, 2, 2, 10); receivedPacket = Message(1, 8, Message::TC, 2); - reqVerifService.failExeVerif(2, 0, 1, 2, 2, 10, 6); + reqVerifService.failExecutionVerification(0, (uint8_t )1, 2, 2, 10, 6); receivedPacket = Message(1, 10, Message::TC, 2); - reqVerifService.failRoutVerif(2, 0, 1, 2, 2, 10, 7); + reqVerifService.failRoutingVerification(0, (uint8_t )1, 2, 2, 10, 7); return 0; } -- GitLab