diff --git a/CMakeLists.txt b/CMakeLists.txt index 6016165b3172d91883fac9fb36430caa2fc37a8e..61383de4df9b3ab1fe03881b621ed2d05bc226f5 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 42eeb1a0d840450685d04f14f311f0e627143d31..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..fc69b08b948fd831fc00e3187f373ffab1a7d5cd --- /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 8ebb6969c910063a25ee3291fb51b73e3661ce9c..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..00ca89d9c4d52b58c46a72cbeef479afab68d1a5 --- /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 efa422e19f1220466c3cde9ecfa30e664bf45ba2..a80938a5fc9881ee4f50b2bbb02b283b7edc8200 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; }