diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cefb30f61899a10a63251f697bc1b7b0170f8b0..a6c978bb8f90be6c505788c684b0ad8563498f72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,9 +17,9 @@ add_custom_target(check add_library(common OBJECT src/ErrorHandler.cpp src/Message.cpp - src/MessageParser.cpp + src/MessageParser.cpp src/Helpers/CRCHelper.cpp - src/Services/EventReportService.cpp + src/Services/EventReportService.cpp src/Services/MemoryManagementService.cpp src/Services/ParameterService.cpp src/Services/RequestVerificationService.cpp diff --git a/inc/ECSS_Definitions.hpp b/inc/ECSS_Definitions.hpp index baee71ec54496ccaf12154891507276735a0640f..3a2eeedba9ebd9fd6e080c054e485a7936880ae5 100644 --- a/inc/ECSS_Definitions.hpp +++ b/inc/ECSS_Definitions.hpp @@ -6,6 +6,9 @@ #define ECSS_MAX_STRING_SIZE 256 +// 7.4.1 +#define CCSDS_PACKET_VERSION 0 + // 7.4.4.1c #define ECSS_PUS_VERSION 2 diff --git a/inc/Services/RequestVerificationService.hpp b/inc/Services/RequestVerificationService.hpp index 67b0f5b102028497d04322f26121bef7cbc67c41..a664e1147414260a3ca07118670f58d0869dc28b 100644 --- a/inc/Services/RequestVerificationService.hpp +++ b/inc/Services/RequestVerificationService.hpp @@ -6,12 +6,13 @@ /** * Implementation of the ST[01] request verification service * - * Note: ST[01]'s messages should not contain calls to the ErrorHandler, as the ErrorHandler - * calls ST[01] functions again. Doing so would risk an infinite recursive loop. + * Note:For the time being, the cause(routing, acceptance, execution), that functions of ST[01] + * should be called, hasn't been implemented yet. In main.cpp there are some random calls with + * dummy values. * * @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 + * @todo See if the deduced data defined from the standard should still be ignored. This deduced + * data exists only in reports that send failure signs(for example the TM[1,2]) */ class RequestVerificationService : public Service { public: @@ -21,79 +22,53 @@ public: /** * TM[1,1] successful acceptance verification report - * Send report when the Cubesat accepts successfully commands * - * Note:The parameters are the necessary information, defined from the standard, that the report - * should contain + * @param request Contains the necessary data to send the report. + * The data is actually some data members of Message that contain the basic info + * of the telecommand packet that accepted successfully * - * @param apid Application process ID - * @param seqFlag Sequence flags - * @param packetSeqCount Packet sequence count */ - void successAcceptanceVerification(Message::PacketType packetType, bool secondaryHeaderFlag, - uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount); + void successAcceptanceVerification(const Message &request); /** * TM[1,2] failed acceptance verification report - *Send report when the Cubesat don't accept commands * - * Note:The parameters are the necessary information, defined from the standard, that the report - * should contain - * - * @param apid Application process ID - * @param seqFlag Sequence flags - * @param packetSeqCount Packet sequence count + * @param request Contains the necessary data to send the report. + * The data is actually some data members of Message that contain the basic + * info of the telecommand packet that failed to be accepted */ - void failAcceptanceVerification(Message::PacketType packetType, bool secondaryHeaderFlag, - uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount, - uint16_t errorCode); + void failAcceptanceVerification(const Message &request); /** - * TM[1,7] successful completion of execution verification report - * Send report when the Cubesat completes an execution + * TM[1,7] successful completion of execution verification report * - * Note:The parameters are the necessary information, defined from the standard, that the report - * should contain + * @param request Contains the necessary data to send the report. + * The data is actually data members of Message that contain the basic info of the + * telecommand packet that executed successfully * - * @param apid Application process ID - * @param seqFlag Sequence flags - * @param packetSeqCount Packet sequence count - */ - void successExecutionVerification(Message::PacketType packetType, bool secondaryHeaderFlag, - uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount); + */ + void successExecutionVerification(const Message &request); /** - * TM[1,8] failed completion of execution verification report - * Send report when the Cubesat don't complete an execution + * TM[1,8] failed completion of execution verification report * - * Note:The parameters are the necessary information, defined from the standard, that the report - * should contain + * @param request Contains the necessary data to send the report. + * The data is actually some data members of Message that contain the basic info of the + * telecommand packet that failed to be executed * - * @param apid Application process ID - * @param seqFlag Sequence flags - * @param packetSeqCount Packet sequence count - */ - void failExecutionVerification(Message::PacketType packetType, - bool secondaryHeaderFlag, - uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount, - uint16_t errorCode); + */ + void failExecutionVerification(const Message &request); /** - * TM[1,10] failed routing verification report - * Send report when the routing of a request has failed + * TM[1,10] failed routing verification report * - * Note:The parameters are the necessary information, defined from the standard, that the report - * should contain + * @param request Contains the necessary data to send the report. + * The data is actually some data members of Message that contain the basic info of the + * telecommand packet that failed the routing * - * @param apid Application process ID - * @param seqFlag Sequence flags - * @param packetSeqCount Packet sequence count - */ - void failRoutingVerification(Message::PacketType packetType, - bool secondaryHeaderFlag, - uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount, - uint16_t errorCode); + */ + void failRoutingVerification(const Message &request); /** * It is responsible to call the suitable function that execute the proper subservice. The @@ -104,7 +79,7 @@ public: * * @todo Error handling for the switch() in the implementation of this execute function */ - void execute(Message &message); + void execute(const Message &message); /** * The purpose of this instance is to access the execute function of this service when a diff --git a/src/ErrorHandler.cpp b/src/ErrorHandler.cpp index d278b1edcd06e67b2c24faea34c6b9f45f0975df..d689ab1a1835c08c4a2908c6822cd1513b3ac422 100644 --- a/src/ErrorHandler.cpp +++ b/src/ErrorHandler.cpp @@ -9,42 +9,21 @@ static RequestVerificationService requestVerificationService; template<> void ErrorHandler::reportError(const Message &message, AcceptanceErrorType errorCode) { - requestVerificationService.failAcceptanceVerification( - message.packetType, - true, - message.applicationId, - ECSS_SEQUENCE_FLAGS, - message.packetSequenceCount, - static_cast<uint16_t>(errorCode) - ); + requestVerificationService.failAcceptanceVerification(message); logError(message, errorCode); } template<> void ErrorHandler::reportError(const Message &message, ExecutionErrorType errorCode) { - requestVerificationService.failExecutionVerification( - message.packetType, - true, - message.applicationId, - ECSS_SEQUENCE_FLAGS, - message.packetSequenceCount, - static_cast<uint16_t>(errorCode) - ); + requestVerificationService.failExecutionVerification(message); logError(message, errorCode); } template<> void ErrorHandler::reportError(const Message &message, RoutingErrorType errorCode) { - requestVerificationService.failRoutingVerification( - message.packetType, - true, - message.applicationId, - ECSS_SEQUENCE_FLAGS, - message.packetSequenceCount, - static_cast<uint16_t>(errorCode) - ); + requestVerificationService.failRoutingVerification(message); logError(message, errorCode); } diff --git a/src/Services/RequestVerificationService.cpp b/src/Services/RequestVerificationService.cpp index 38de1e70e0b1e646323ca66c652e3807c783f008..0e08b3e71ab47f462a306a8c7c2bde193a68a9dc 100644 --- a/src/Services/RequestVerificationService.cpp +++ b/src/Services/RequestVerificationService.cpp @@ -1,146 +1,103 @@ #include "Services/RequestVerificationService.hpp" #include "Message.hpp" -void RequestVerificationService::successAcceptanceVerification(Message::PacketType packetType, - bool secondaryHeaderFlag, - uint16_t apid, uint8_t seqFlag, - uint16_t packetSeqCount) { +void RequestVerificationService::successAcceptanceVerification(const Message &request) { // TM[1,1] successful acceptance verification report - // parameters have max values defined from standard - assert(apid < 2048); - assert(seqFlag < 4); - assert(packetSeqCount < 16384); - Message report = createTM(1); - report.appendEnumerated(3, ECSS_PUS_VERSION); // packet version number - report.appendEnumerated(1, packetType); - report.appendBits(1, static_cast<uint8_t >(secondaryHeaderFlag)); - report.appendEnumerated(11, apid); - report.appendEnumerated(2, seqFlag); - report.appendBits(14, packetSeqCount); + report.appendEnumerated(3, CCSDS_PACKET_VERSION); // packet version number + report.appendEnumerated(1, request.packetType); // packet type + report.appendBits(1, 0); // secondary header flag(not implemented) + report.appendEnumerated(11, request.applicationId); // application process ID + report.appendEnumerated(2, 0); // sequence flags(not implemented) + report.appendBits(14, 0); // packet sequence count(not implemented) storeMessage(report); } void -RequestVerificationService::failAcceptanceVerification(Message::PacketType packetType, - bool secondaryHeaderFlag, - uint16_t apid, uint8_t seqFlag, - uint16_t packetSeqCount, - uint16_t errorCode) { +RequestVerificationService::failAcceptanceVerification(const Message &request) { // TM[1,2] failed acceptance verification report - // parameters have max values defined from standard - assert(apid < 2048); - assert(seqFlag < 4); - assert(packetSeqCount < 16384); - Message report = createTM(2); - report.appendEnumerated(3, ECSS_PUS_VERSION); // packet version number - report.appendEnumerated(1, packetType); - report.appendBits(1, static_cast<uint8_t >(secondaryHeaderFlag)); - report.appendEnumerated(11, apid); - report.appendEnumerated(2, seqFlag); - report.appendBits(14, packetSeqCount); - report.appendEnum16(errorCode); + report.appendEnumerated(3, CCSDS_PACKET_VERSION); // packet version number + report.appendEnumerated(1, request.packetType); // packet type + report.appendBits(1, 0); // secondary header flag(not implemented) + report.appendEnumerated(11, request.applicationId); // application process ID + report.appendEnumerated(2, 0); // sequence flags(not implemented) + report.appendBits(14, 0); // packet sequence count(not implemented) + report.appendEnum16(0); // error code(not implemented) storeMessage(report); } -void RequestVerificationService::successExecutionVerification(Message::PacketType packetType, - bool secondaryHeaderFlag, - uint16_t apid, uint8_t seqFlag, - uint16_t packetSeqCount) { +void RequestVerificationService::successExecutionVerification(const Message &request) { // TM[1,7] successful completion of execution verification report - // parameters have max values defined from standard - assert(apid < 2048); - assert(seqFlag < 4); - assert(packetSeqCount < 16384); - Message report = createTM(7); - report.appendEnumerated(3, ECSS_PUS_VERSION); // packet version number - report.appendEnumerated(1, packetType); - report.appendBits(1, static_cast<uint8_t >(secondaryHeaderFlag)); - report.appendEnumerated(11, apid); - report.appendEnumerated(2, seqFlag); - report.appendBits(14, packetSeqCount); + report.appendEnumerated(3, CCSDS_PACKET_VERSION); // packet version number + report.appendEnumerated(1, request.packetType); // packet type + report.appendBits(1, 0); // secondary header flag(not implemented) + report.appendEnumerated(11, request.applicationId); // application process ID + report.appendEnumerated(2, 0); // sequence flags(not implemented) + report.appendBits(14, 0); // packet sequence count(not implemented) storeMessage(report); } void -RequestVerificationService::failExecutionVerification(Message::PacketType packetType, - bool secondaryHeaderFlag, - uint16_t apid, uint8_t seqFlag, - uint16_t packetSeqCount, - uint16_t errorCode) { +RequestVerificationService::failExecutionVerification(const Message &request) { // TM[1,8] failed completion of execution verification report - // parameters have max values defined from standard - assert(apid < 2048); - assert(seqFlag < 4); - assert(packetSeqCount < 16384); - Message report = createTM(8); - report.appendEnumerated(3, ECSS_PUS_VERSION); // packet version number - report.appendEnumerated(1, packetType); - report.appendBits(1, static_cast<uint8_t >(secondaryHeaderFlag)); - report.appendEnumerated(11, apid); - report.appendEnumerated(2, seqFlag); - report.appendBits(14, packetSeqCount); - report.appendEnum16(errorCode); + report.appendEnumerated(3, CCSDS_PACKET_VERSION); // packet version number + report.appendEnumerated(1, request.packetType); // packet type + report.appendBits(1, 0); // secondary header flag(not implemented) + report.appendEnumerated(11, request.applicationId); // application process ID + report.appendEnumerated(2, 0); // sequence flags(not implemented) + report.appendBits(14, 0); // packet sequence count(not implemented) + report.appendEnum16(0); // error code(not implemented) storeMessage(report); } void -RequestVerificationService::failRoutingVerification(Message::PacketType packetType, - bool secondaryHeaderFlag, - uint16_t apid, uint8_t seqFlag, - uint16_t packetSeqCount, - uint16_t errorCode) { +RequestVerificationService::failRoutingVerification(const Message &request) { // TM[1,10] failed routing verification report - // parameters have max values defined from standard - assert(apid < 2048); - assert(seqFlag < 4); - assert(packetSeqCount < 16384); - Message report = createTM(10); - report.appendEnumerated(3, ECSS_PUS_VERSION); // packet version number - report.appendEnumerated(1, packetType); - report.appendBits(1, static_cast<uint8_t >(secondaryHeaderFlag)); - report.appendEnumerated(11, apid); - report.appendEnumerated(2, seqFlag); - report.appendBits(14, packetSeqCount); - report.appendEnum16(errorCode); + report.appendEnumerated(3, CCSDS_PACKET_VERSION); // packet version number + report.appendEnumerated(1, request.packetType); // packet type + report.appendBits(1, 0); // secondary header flag(not implemented) + report.appendEnumerated(11, request.applicationId); // application process ID + report.appendEnumerated(2, 0); // sequence flags(not implemented) + report.appendBits(14, 0); // packet sequence count(not implemented) + report.appendEnum16(0); // error code(not implemented) storeMessage(report); } -void RequestVerificationService::execute(Message &message) { +void RequestVerificationService::execute(const Message &message) { switch (message.messageType) { case 1: - successAcceptanceVerification(Message::TC, true, 2, 2, 10); + successAcceptanceVerification(message); break; case 2: - failAcceptanceVerification(Message::TC, true, 2, 2, 10, 5); + failAcceptanceVerification(message); break; case 7: - successExecutionVerification(Message::TC, true, 2, 2, 10); + successExecutionVerification(message); break; case 8: - failExecutionVerification(Message::TC, true, 2, 2, 10, 6); + failExecutionVerification(message); break; case 10: - failRoutingVerification(Message::TC, true, 2, 2, 10, 7); + failRoutingVerification(message); break; default: // cout is very bad for embedded systems diff --git a/src/main.cpp b/src/main.cpp index b07291023e944d224842aa5ddf08d305f3785f95..0883b6023edfb55e97d1300e4372a3a68039fa0e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,7 @@ #include "Services/TestService.hpp" #include "Services/ParameterService.hpp" #include "Services/RequestVerificationService.hpp" +#include "Services/MemoryManagementService.hpp" #include "Services/EventReportService.hpp" #include "Message.hpp" #include "MessageParser.hpp" @@ -106,13 +107,23 @@ int main() { // ST[01] test - // parameters take random values and works as expected + RequestVerificationService reqVerifService; - 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); + + Message receivedMessage = Message(1, 1, Message::TC, 3); + reqVerifService.successAcceptanceVerification(receivedMessage); + + receivedMessage = Message(1, 2, Message::TC, 3); + reqVerifService.failAcceptanceVerification(receivedMessage); + + receivedMessage = Message(1, 7, Message::TC, 3); + reqVerifService.successExecutionVerification(receivedMessage); + + receivedMessage = Message(1, 8, Message::TC, 3); + reqVerifService.failExecutionVerification(receivedMessage); + + receivedMessage = Message(1, 10, Message::TC, 3); + reqVerifService.failRoutingVerification(receivedMessage); // ST[05] test [works] const unsigned char eventReportData[12] = "Hello World"; @@ -128,6 +139,7 @@ int main() { // MessageParser class test std::cout << "\n"; + // ST[17] test Message message = Message(17, 1, Message::TC, 1); MessageParser messageParser; @@ -137,15 +149,15 @@ int main() { messageParser.execute(message); // ST[01] test - message = Message(1, 1, Message::TC, 2); + message = Message(1, 1, Message::TC, 3); messageParser.execute(message); - message = Message(1, 2, Message::TC, 2); + message = Message(1, 2, Message::TC, 3); messageParser.execute(message); - message = Message(1, 7, Message::TC, 2); + message = Message(1, 7, Message::TC, 3); messageParser.execute(message); - message = Message(1, 8, Message::TC, 2); + message = Message(1, 8, Message::TC, 3); messageParser.execute(message); - message = Message(1, 10, Message::TC, 2); + message = Message(1, 10, Message::TC, 3); messageParser.execute(message); // ErrorHandler test diff --git a/test/ErrorHandler.cpp b/test/ErrorHandler.cpp index 23eaa2aef869e2501b7b74ea56157db7255e6503..e6d4003bc89d40ef363d1a24465e739abd2b7740 100644 --- a/test/ErrorHandler.cpp +++ b/test/ErrorHandler.cpp @@ -15,13 +15,13 @@ TEST_CASE("Error: Failed Acceptance", "[errors]") { CHECK(report.packetType == Message::TM); REQUIRE(report.dataSize == 6); - CHECK(report.readBits(3) == ECSS_PUS_VERSION); + CHECK(report.readBits(3) == CCSDS_PACKET_VERSION); CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); - CHECK(report.readBits(1) == true); + CHECK(report.readBits(1) == false); CHECK(report.readBits(11) == 47); - CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); + CHECK(report.readBits(2) == 0); CHECK(report.readBits(14) == failedMessage.packetSequenceCount); - CHECK(report.readEnum16() == 1); + CHECK(report.readEnum16() == 0); } TEST_CASE("Error: Failed Execution Completion", "[errors]") { @@ -37,11 +37,11 @@ TEST_CASE("Error: Failed Execution Completion", "[errors]") { CHECK(report.packetType == Message::TM); REQUIRE(report.dataSize == 6); - CHECK(report.readBits(3) == ECSS_PUS_VERSION); + CHECK(report.readBits(3) == CCSDS_PACKET_VERSION); CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); - CHECK(report.readBits(1) == true); + CHECK(report.readBits(1) == false); CHECK(report.readBits(11) == 56); - CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); + CHECK(report.readBits(2) == 0); CHECK(report.readBits(14) == failedMessage.packetSequenceCount); CHECK(report.readEnum16() == 0); } @@ -59,11 +59,11 @@ TEST_CASE("Error: Failed Routing", "[errors]") { CHECK(report.packetType == Message::TM); REQUIRE(report.dataSize == 6); - CHECK(report.readBits(3) == ECSS_PUS_VERSION); + CHECK(report.readBits(3) == CCSDS_PACKET_VERSION); CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); - CHECK(report.readBits(1) == true); + CHECK(report.readBits(1) == false); CHECK(report.readBits(11) == 71); - CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); + CHECK(report.readBits(2) == 0); CHECK(report.readBits(14) == failedMessage.packetSequenceCount); CHECK(report.readEnum16() == 0); } diff --git a/test/Services/RequestVerificationService.cpp b/test/Services/RequestVerificationService.cpp index ebb97762346f5c03b07a82052e4e1baeca928d46..65a256d3d37010317e7b61106beeb2083f7e976e 100644 --- a/test/Services/RequestVerificationService.cpp +++ b/test/Services/RequestVerificationService.cpp @@ -5,108 +5,117 @@ TEST_CASE("TM[1,1]", "[service][st01]") { RequestVerificationService reqVerifService; - reqVerifService.successAcceptanceVerification(Message::TC, true, 2, 2, 10); + + Message receivedMessage = Message(1, 1, Message::TC, 3); + reqVerifService.successAcceptanceVerification(receivedMessage); REQUIRE(ServiceTests::hasOneMessage()); Message response = ServiceTests::get(0); // Checks for the data-members of the object response CHECK(response.serviceType == 1); CHECK(response.messageType == 1); - CHECK(response.packetType == 0); // packet type(TM = 0, TC = 1) + CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 4); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) - CHECK(response.readEnumerated(3) == 2); // packet version number - CHECK(response.readEnumerated(1) == 1); // packet type - CHECK(response.readBits(1) == true); // secondary header flag - CHECK(response.readEnumerated(11) == 2); // application process ID - CHECK(response.readEnumerated(2) == 2); // sequence flags - CHECK(response.readBits(14) == 10); // packet sequence count + CHECK(response.readEnumerated(3) == CCSDS_PACKET_VERSION); // packet version number + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 0); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == 0); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count } TEST_CASE("TM[1,2]", "[service][st01]") { RequestVerificationService reqVerifService; - reqVerifService.failAcceptanceVerification(Message::TC, true, 2, 2, 10, 5); + + Message receivedMessage = Message(1, 2, Message::TC, 3); + reqVerifService.failAcceptanceVerification(receivedMessage); REQUIRE(ServiceTests::hasOneMessage()); Message response = ServiceTests::get(0); // Checks for the data-members of the object response CHECK(response.serviceType == 1); CHECK(response.messageType == 2); - CHECK(response.packetType == 0); // packet type(TM = 0, TC = 1) + CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 6); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) - CHECK(response.readEnumerated(3) == 2); // packet version number - CHECK(response.readEnumerated(1) == 1); // packet type - CHECK(response.readBits(1) == true); // secondary header flag - CHECK(response.readEnumerated(11) == 2); // application process ID - CHECK(response.readEnumerated(2) == 2); // sequence flags - CHECK(response.readBits(14) == 10); // packet sequence count - CHECK(response.readEnum16() == 5); // error code + CHECK(response.readEnumerated(3) == CCSDS_PACKET_VERSION); // packet version number + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 0); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == 0); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readEnum16() == 0); // error code } TEST_CASE("TM[1,7]", "[service][st01]") { RequestVerificationService reqVerifService; - reqVerifService.successExecutionVerification(Message::TC, true, 2, 2, 10); + + Message receivedMessage = Message(1, 7, Message::TC, 3); + reqVerifService.successExecutionVerification(receivedMessage); REQUIRE(ServiceTests::hasOneMessage()); Message response = ServiceTests::get(0); // Checks for the data-members of the object response CHECK(response.serviceType == 1); CHECK(response.messageType == 7); - CHECK(response.packetType == 0); // packet type(TM = 0, TC = 1) + CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 4); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) - CHECK(response.readEnumerated(3) == 2); // packet version number - CHECK(response.readEnumerated(1) == 1); // packet type - CHECK(response.readBits(1) == true); // secondary header flag - CHECK(response.readEnumerated(11) == 2); // application process ID - CHECK(response.readEnumerated(2) == 2); // sequence flags - CHECK(response.readBits(14) == 10); // packet sequence count + CHECK(response.readEnumerated(3) == CCSDS_PACKET_VERSION); // packet version number + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 0); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == 0); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count } TEST_CASE("TM[1,8]", "[service][st01]") { RequestVerificationService reqVerifService; - reqVerifService.failExecutionVerification(Message::TC, true, 2, 2, 10, 6); + + Message receivedMessage = Message(1, 8, Message::TC, 3); + reqVerifService.failExecutionVerification(receivedMessage); REQUIRE(ServiceTests::hasOneMessage()); Message response = ServiceTests::get(0); - // Checks for the data-members of the object response CHECK(response.serviceType == 1); CHECK(response.messageType == 8); - CHECK(response.packetType == 0); // packet type(TM = 0, TC = 1) + CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 6); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) - CHECK(response.readEnumerated(3) == 2); // packet version number - CHECK(response.readEnumerated(1) == 1); // packet type - CHECK(response.readBits(1) == true); // secondary header flag - CHECK(response.readEnumerated(11) == 2); // application process ID - CHECK(response.readEnumerated(2) == 2); // sequence flags - CHECK(response.readBits(14) == 10); // packet sequence count - CHECK(response.readEnum16() == 6); // error code + CHECK(response.readEnumerated(3) == CCSDS_PACKET_VERSION); // packet version number + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 0); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == 0); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readEnum16() == 0); // error code } TEST_CASE("TM[1,10]", "[service][st01]") { RequestVerificationService reqVerifService; - reqVerifService.failRoutingVerification(Message::TC, true, 2, 2, 10, 7); + + Message receivedMessage = Message(1, 10, Message::TC, 3); + reqVerifService.failRoutingVerification(receivedMessage); REQUIRE(ServiceTests::hasOneMessage()); Message response = ServiceTests::get(0); // Checks for the data-members of the object response CHECK(response.serviceType == 1); CHECK(response.messageType == 10); - CHECK(response.packetType == 0); // packet type(TM = 0, TC = 1) + CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 6); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) - CHECK(response.readEnumerated(3) == 2); // packet version number - CHECK(response.readEnumerated(1) == 1); // packet type - CHECK(response.readBits(1) == true); // secondary header flag - CHECK(response.readEnumerated(11) == 2); // application process ID - CHECK(response.readEnumerated(2) == 2); // sequence flags - CHECK(response.readBits(14) == 10); // packet sequence count - CHECK(response.readEnum16() == 7); // error code + CHECK(response.readEnumerated(3) == CCSDS_PACKET_VERSION); // packet version number + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 0); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == 0); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readEnum16() == 0); // error code }