diff --git a/inc/Services/RequestVerificationService.hpp b/inc/Services/RequestVerificationService.hpp index e6b5e8120c6571864dddf3ac5d6b341d16889a90..d3677810ff479b2991e049bf95c5220c5d6068f7 100644 --- a/inc/Services/RequestVerificationService.hpp +++ b/inc/Services/RequestVerificationService.hpp @@ -1,4 +1,4 @@ -#ifndef ECSS_SERVICES_REQEUSTVERIFICATIONSERVICE_HPP +#ifndef ECSS_SERVICES_REQUESTVERIFICATIONSERVICE_HPP #define ECSS_SERVICES_REQUESTVERIFICATIONSERVICE_HPP #include "Service.hpp" @@ -7,6 +7,7 @@ * Implementation of the ST[01] request verification service * * @todo All telemetry packets shall have a telemetry packet secondary header + * @todo See if it would be more efficient to use Messages as arguments instead of individual parameters */ class RequestVerificationService : public Service { public: @@ -17,13 +18,13 @@ public: /** * TM[1,1] successful acceptance verification report */ - void successAcceptanceVerification(uint8_t packetType, bool secondaryHeaderFlag, + void successAcceptanceVerification(Message::PacketType 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, + void failAcceptanceVerification(Message::PacketType packetType, bool secondaryHeaderFlag, uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount, uint16_t errorCode); @@ -31,13 +32,13 @@ public: /** * TM[1,7] successful completion of execution verification report */ - void successExecutionVerification(uint8_t packetType, bool secondaryHeaderFlag, + void successExecutionVerification(Message::PacketType 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, + void failExecutionVerification(Message::PacketType packetType, bool secondaryHeaderFlag, uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount, uint16_t errorCode); @@ -45,7 +46,7 @@ public: /** * TM[1,10] failed routing verification report */ - void failRoutingVerification(uint8_t packetType, + void failRoutingVerification(Message::PacketType packetType, bool secondaryHeaderFlag, uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount, uint16_t errorCode); diff --git a/src/Services/RequestVerificationService.cpp b/src/Services/RequestVerificationService.cpp index 0416fd1fe9f4ffed2226d0fbc1a54a494d731387..8203568da04184b34324fda7df394edf02b6afd3 100644 --- a/src/Services/RequestVerificationService.cpp +++ b/src/Services/RequestVerificationService.cpp @@ -1,122 +1,115 @@ #include "Services/RequestVerificationService.hpp" +#include "Message.hpp" -void RequestVerificationService::successAcceptanceVerification(uint8_t packetType, +void RequestVerificationService::successAcceptanceVerification(Message::PacketType packetType, bool secondaryHeaderFlag, uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount) { // TM[1,1] successful acceptance verification report - assert(packetType < 2); assert(apid < 2048); assert(seqFlag < 4); assert(packetSeqCount < 16384); Message report = createTM(1); - report.appendBits(3, ECSS_PUS_VERSION); // packet version number - report.appendBits(1, packetType); + report.appendEnumerated(3, ECSS_PUS_VERSION); // packet version number + report.appendEnumerated(1, packetType); report.appendBits(1, static_cast<uint16_t >(secondaryHeaderFlag)); - report.appendBits(11, apid); - report.appendBits(2, seqFlag); + report.appendEnumerated(11, apid); + report.appendEnumerated(2, seqFlag); report.appendBits(14, packetSeqCount); storeMessage(report); } void -RequestVerificationService::failAcceptanceVerification(uint8_t packetType, +RequestVerificationService::failAcceptanceVerification(Message::PacketType packetType, bool secondaryHeaderFlag, uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount, uint16_t errorCode) { // TM[1,2] failed acceptance verification report - assert(packetType < 2); assert(apid < 2048); assert(seqFlag < 4); assert(packetSeqCount < 16384); Message report = createTM(2); - report.appendBits(3, ECSS_PUS_VERSION); // packet version number - report.appendBits(1, packetType); + report.appendEnumerated(3, ECSS_PUS_VERSION); // packet version number + report.appendEnumerated(1, packetType); report.appendBits(1, static_cast<uint16_t >(secondaryHeaderFlag)); - report.appendBits(11, apid); - report.appendBits(2, seqFlag); + report.appendEnumerated(11, apid); + report.appendEnumerated(2, seqFlag); report.appendBits(14, packetSeqCount); - report.appendUint16(errorCode); storeMessage(report); } -void RequestVerificationService::successExecutionVerification(uint8_t packetType, +void RequestVerificationService::successExecutionVerification(Message::PacketType packetType, bool secondaryHeaderFlag, uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount) { // TM[1,7] successful completion of execution verification report - assert(packetType < 2); assert(apid < 2048); assert(seqFlag < 4); assert(packetSeqCount < 16384); Message report = createTM(7); - report.appendBits(3, ECSS_PUS_VERSION); // packet version number - report.appendBits(1, packetType); + report.appendEnumerated(3, ECSS_PUS_VERSION); // packet version number + report.appendEnumerated(1, packetType); report.appendBits(1, static_cast<uint16_t >(secondaryHeaderFlag)); - report.appendBits(11, apid); - report.appendBits(2, seqFlag); + report.appendEnumerated(11, apid); + report.appendEnumerated(2, seqFlag); report.appendBits(14, packetSeqCount); storeMessage(report); } void -RequestVerificationService::failExecutionVerification(uint8_t packetType, +RequestVerificationService::failExecutionVerification(Message::PacketType packetType, bool secondaryHeaderFlag, uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount, uint16_t errorCode) { // TM[1,8] failed completion of execution verification report - assert(packetType < 2); assert(apid < 2048); assert(seqFlag < 4); assert(packetSeqCount < 16384); Message report = createTM(8); - report.appendBits(3, ECSS_PUS_VERSION); // packet version number - report.appendBits(1, packetType); + report.appendEnumerated(3, ECSS_PUS_VERSION); // packet version number + report.appendEnumerated(1, packetType); report.appendBits(1, static_cast<uint16_t >(secondaryHeaderFlag)); - report.appendBits(11, apid); - report.appendBits(2, seqFlag); + report.appendEnumerated(11, apid); + report.appendEnumerated(2, seqFlag); report.appendBits(14, packetSeqCount); - report.appendUint16(errorCode); storeMessage(report); } void -RequestVerificationService::failRoutingVerification(uint8_t packetType, +RequestVerificationService::failRoutingVerification(Message::PacketType packetType, bool secondaryHeaderFlag, uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount, uint16_t errorCode) { // TM[1,10] failed routing verification report - assert(packetType < 2); assert(apid < 2048); assert(seqFlag < 4); assert(packetSeqCount < 16384); Message report = createTM(10); - report.appendBits(3, ECSS_PUS_VERSION); // packet version number - report.appendBits(1, packetType); + report.appendEnumerated(3, ECSS_PUS_VERSION); // packet version number + report.appendEnumerated(1, packetType); report.appendBits(1, static_cast<uint16_t >(secondaryHeaderFlag)); - report.appendBits(11, apid); - report.appendBits(2, seqFlag); + report.appendEnumerated(11, apid); + report.appendEnumerated(2, seqFlag); report.appendBits(14, packetSeqCount); - report.appendUint16(errorCode); storeMessage(report); diff --git a/src/main.cpp b/src/main.cpp index 67362d560377ce54d40fdc04d2637148928ddc39..f43f69cbf1cff7631025403ff7c3cc689ecd5d3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,11 +32,11 @@ int main() { // ST[01] test // parameters take random values and works as expected RequestVerificationService reqVerifService; - reqVerifService.successAcceptanceVerification(0, true, 2, 2, 10); - reqVerifService.failAcceptanceVerification(0, true, 2, 2, 10, 5); - reqVerifService.successExecutionVerification(0, true, 2, 2, 10); - reqVerifService.failExecutionVerification(0, true, 2, 2, 10, 6); - reqVerifService.failRoutingVerification(0, true, 2, 2, 10, 7); + reqVerifService.successAcceptanceVerification(Message::TC, true, 2, 2, 10); + reqVerifService.failAcceptanceVerification(Message::TC, true, 2, 2, 10, 5); + reqVerifService.successExecutionVerification(Message::TC, true, 2, 2, 10); + reqVerifService.failExecutionVerification(Message::TC, true, 2, 2, 10, 6); + reqVerifService.failRoutingVerification(Message::TC, true, 2, 2, 10, 7); return 0; }