diff --git a/inc/ErrorHandler.hpp b/inc/ErrorHandler.hpp index 95c9138e1824f52e1acf152aaa0c7c4b2d8d7e73..25c65960e3e408ca35e5a818794eeaa83f873c70 100644 --- a/inc/ErrorHandler.hpp +++ b/inc/ErrorHandler.hpp @@ -4,6 +4,8 @@ // Forward declaration of the class, since its header file depends on the ErrorHandler class Message; +#include <stdint.h> // for the uint_8t stepID + /** * A class that handles unexpected software errors, including internal errors or errors due to * invalid & incorrect input data. @@ -55,6 +57,11 @@ public: * An error in the header of a packet makes it unable to be parsed */ UnacceptablePacket = 5, + + /** + * Asked a Message type that it doesn't exist + */ + UnknownMessageType = 6, }; /** @@ -80,7 +87,27 @@ public: /** * Cannot parse a Message, because there is an error in its secondary header */ - UnacceptableMessage = 5, + UnacceptableMessage = 5, + }; + + /** + * The error code for failed start of execution reports, as specified in ECSS 5.3.5.2.3g + * + * Note: Numbers are kept in code explicitly, so that there is no uncertainty when something + * changes. + */ + enum ExecutionStartErrorType { + UnknownExecutionStartError = 0, + }; + + /** + * The error code for failed progress of execution reports, as specified in ECSS 5.3.5.2.3g + * + * Note: Numbers are kept in code explicitly, so that there is no uncertainty when something + * changes. + */ + enum ExecutionProgressErrorType { + UnknownExecutionProgressError = 0, }; /** @@ -89,8 +116,8 @@ public: * Note: Numbers are kept in code explicitly, so that there is no uncertainty when something * changes. */ - enum ExecutionErrorType { - UnknownExecutionError = 0, + enum ExecutionCompletionErrorType { + UnknownExecutionCompletionError = 0, /** * Checksum comparison failed */ @@ -102,7 +129,7 @@ public: }; /** - * The error code for failed completion of execution reports, as specified in ECSS 6.1.3.3d + * The error code for failed routing reports, as specified in ECSS 6.1.3.3d * * Note: Numbers are kept in code explicitly, so that there is no uncertainty when something * changes. @@ -127,7 +154,7 @@ public: * Report a failure and, if applicable, store a failure report message * * @tparam ErrorType The Type struct of the error; can be AcceptanceErrorType, - * ExecutionErrorType, or RoutingErrorType. + * StartExecutionErrorType,CompletionExecutionErrorType, or RoutingErrorType. * @param message The incoming message that prompted the failure * @param errorCode The error's code, as defined in ErrorHandler * @todo See if this needs to include InternalErrorType @@ -135,6 +162,22 @@ public: template<typename ErrorType> static void reportError(const Message &message, ErrorType errorCode); + /** + * Report a failure about the progress of the execution of a request + * + * Note:This function is different from reportError, because we need one more /p(stepID) + * to call the proper function for reporting the progress of the execution of a request + * + * @param message The incoming message that prompted the failure + * @param errorCode The error's code, when a failed progress of the execution of a request + * occurs + * @param stepID If the execution of a request is a long process, then we can divide + * the process into steps. Each step goes with its own definition, the stepID. Each value + * ,that the stepID is assigned, should be documented. + */ + static void reportProgressError(const Message &message, ExecutionProgressErrorType errorCode, + uint8_t stepID); + /** * Report a failure that occurred internally, not due to a failure of a received packet. * diff --git a/inc/Message.hpp b/inc/Message.hpp index ecee3cb27ba37675e4a8398294f338fc4d2c6352..1b1cca380acb2186f35c7d8525a116e1c9c77dc4 100644 --- a/inc/Message.hpp +++ b/inc/Message.hpp @@ -1,6 +1,7 @@ #ifndef ECSS_SERVICES_PACKET_H #define ECSS_SERVICES_PACKET_H + // Forward declaration of the Message class, needed for the ErrorHandler class Message; diff --git a/inc/MessageParser.hpp b/inc/MessageParser.hpp index 0ffa87e3aa792dd43ba474f93ab43e3747b1c5f5..5c43505f4c4aa1c73009cce45c6c6023b0af20f0 100644 --- a/inc/MessageParser.hpp +++ b/inc/MessageParser.hpp @@ -24,6 +24,8 @@ public: * * @todo The implementation of the execute function should correspond to the numbers of the * services/activities that have been created + * @todo execute() needs to be redefined. The /p message isn't enough to call some + * subservices. More arguments are needed. */ void execute(Message &message); diff --git a/inc/Services/RequestVerificationService.hpp b/inc/Services/RequestVerificationService.hpp index a664e1147414260a3ca07118670f58d0869dc28b..3f78f83b369b33b73269488b6f70451044f6c729 100644 --- a/inc/Services/RequestVerificationService.hpp +++ b/inc/Services/RequestVerificationService.hpp @@ -2,6 +2,9 @@ #define ECSS_SERVICES_REQUESTVERIFICATIONSERVICE_HPP #include "Service.hpp" +#include "Message.hpp" +#include "ErrorHandler.hpp" +#include "ECSS_Definitions.hpp" /** * Implementation of the ST[01] request verification service @@ -10,7 +13,6 @@ * 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 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]) */ @@ -26,7 +28,6 @@ public: * @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 - * */ void successAcceptanceVerification(const Message &request); @@ -36,29 +37,79 @@ public: * @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 + * @param errorCode The cause of creating this type of report + */ + void failAcceptanceVerification(const Message &request, ErrorHandler::AcceptanceErrorType + errorCode); + + /** + * TM[1,3] successful start of execution verification report + * + * @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 its start of execution is successful */ - void failAcceptanceVerification(const Message &request); + void successStartExecutionVerification(const Message &request); + /** + * TM[1,4] failed start of execution verification report + * + * @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 its start of execution has failed + * @param errorCode The cause of creating this type of report + */ + void failStartExecutionVerification(const Message &request, + ErrorHandler::ExecutionStartErrorType + errorCode); + + /** + * TM[1,5] successful progress of execution verification report + * + * @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 its progress of execution is successful + * @param stepID If the execution of a request is a long process, then we can divide + * the process into steps. Each step goes with its own definition, the stepID. + * @todo Each value,that the stepID is assigned, should be documented. + * @todo error handling for undocumented assigned values to stepID + */ + void successProgressExecutionVerification(const Message &request, uint8_t stepID); + + /** + * TM[1,6] failed progress of execution verification report + * + * @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 its progress of execution has failed + * @param errorCode The cause of creating this type of report + * @param stepID If the execution of a request is a long process, then we can divide + * the process into steps. Each step goes with its own definition, the stepID. + * @todo Each value,that the stepID is assigned, should be documented. + * @todo error handling for undocumented assigned values to stepID + */ + void failProgressExecutionVerification(const Message &request, + ErrorHandler::ExecutionProgressErrorType errorCode, uint8_t stepID); /** * TM[1,7] successful completion of execution verification report * * @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 - * + * telecommand packet that executed completely and successfully */ - void successExecutionVerification(const Message &request); + void successCompletionExecutionVerification(const Message &request); /** * TM[1,8] failed completion of execution verification report * * @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 - * + * telecommand packet that failed to be executed completely + * @param errorCode The cause of creating this type of report */ - void failExecutionVerification(const Message &request); + void failCompletionExecutionVerification(const Message &request, + ErrorHandler::ExecutionCompletionErrorType errorCode); /** * TM[1,10] failed routing verification report @@ -66,9 +117,9 @@ public: * @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 errorCode The cause of creating this type of report */ - void failRoutingVerification(const Message &request); + void failRoutingVerification(const Message &request, ErrorHandler::RoutingErrorType errorCode); /** * It is responsible to call the suitable function that execute the proper subservice. The @@ -77,13 +128,14 @@ public: * * Note:The functions of this service takes dummy values as arguments for the time being * - * @todo Error handling for the switch() in the implementation of this execute function + * @todo execute() needs to be redefined. The /p message isn't enough to call some + * subservices. More arguments are needed. */ void execute(const Message &message); /** - * The purpose of this instance is to access the execute function of this service when a - * MessageParser object is created + * The purpose of this instance is to access the execute function of this service when a + * MessageParser object is created */ static RequestVerificationService instance; }; diff --git a/src/ErrorHandler.cpp b/src/ErrorHandler.cpp index d689ab1a1835c08c4a2908c6822cd1513b3ac422..d62eadd5025efb6ecbaa252def3a664ef1a8f55b 100644 --- a/src/ErrorHandler.cpp +++ b/src/ErrorHandler.cpp @@ -1,29 +1,43 @@ #include <iostream> #include <cxxabi.h> #include <ErrorHandler.hpp> - #include "Services/RequestVerificationService.hpp" + // TODO: Use service singleton, as soon as singletons are ready static RequestVerificationService requestVerificationService; template<> void ErrorHandler::reportError(const Message &message, AcceptanceErrorType errorCode) { - requestVerificationService.failAcceptanceVerification(message); + requestVerificationService.failAcceptanceVerification(message, errorCode); + + logError(message, errorCode); +} + +template<> +void ErrorHandler::reportError(const Message &message, ExecutionStartErrorType errorCode) { + requestVerificationService.failStartExecutionVerification(message, errorCode); + + logError(message, errorCode); +} + +void ErrorHandler::reportProgressError(const Message &message, ExecutionProgressErrorType +errorCode, uint8_t stepID) { + requestVerificationService.failProgressExecutionVerification(message, errorCode, stepID); logError(message, errorCode); } template<> -void ErrorHandler::reportError(const Message &message, ExecutionErrorType errorCode) { - requestVerificationService.failExecutionVerification(message); +void ErrorHandler::reportError(const Message &message, ExecutionCompletionErrorType errorCode) { + requestVerificationService.failCompletionExecutionVerification(message, errorCode); logError(message, errorCode); } template<> void ErrorHandler::reportError(const Message &message, RoutingErrorType errorCode) { - requestVerificationService.failRoutingVerification(message); + requestVerificationService.failRoutingVerification(message, errorCode); logError(message, errorCode); } diff --git a/src/MessageParser.cpp b/src/MessageParser.cpp index 33b5574da44deec320cae4a7e6364e194825f885..ff933f68824253cd227b7ba87b1ed71ed4b4f412 100644 --- a/src/MessageParser.cpp +++ b/src/MessageParser.cpp @@ -18,8 +18,7 @@ void MessageParser::execute(Message &message) { TestService::instance.execute(message); break; default: - // cout is very bad for embedded systems - std::cout << "This service hasn't been implemented yet or it doesn't exist"; + ErrorHandler::reportInternalError(ErrorHandler::UnknownMessageType); break; } } diff --git a/src/Services/RequestVerificationService.cpp b/src/Services/RequestVerificationService.cpp index 0e08b3e71ab47f462a306a8c7c2bde193a68a9dc..768971daf89b7388075adad9f3e6a471b0795e0c 100644 --- a/src/Services/RequestVerificationService.cpp +++ b/src/Services/RequestVerificationService.cpp @@ -1,5 +1,5 @@ #include "Services/RequestVerificationService.hpp" -#include "Message.hpp" + void RequestVerificationService::successAcceptanceVerification(const Message &request) { // TM[1,1] successful acceptance verification report @@ -10,14 +10,15 @@ void RequestVerificationService::successAcceptanceVerification(const Message &re 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.appendEnumerated(2, ECSS_SEQUENCE_FLAGS); // sequence flags report.appendBits(14, 0); // packet sequence count(not implemented) storeMessage(report); } void -RequestVerificationService::failAcceptanceVerification(const Message &request) { +RequestVerificationService::failAcceptanceVerification(const Message &request, + ErrorHandler::AcceptanceErrorType errorCode) { // TM[1,2] failed acceptance verification report Message report = createTM(2); @@ -26,14 +27,81 @@ RequestVerificationService::failAcceptanceVerification(const Message &request) { 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.appendEnumerated(2, ECSS_SEQUENCE_FLAGS); // sequence flags + report.appendBits(14, 0); // packet sequence count(not implemented) + report.appendEnum16(errorCode); // error code + + storeMessage(report); +} + +void RequestVerificationService::successStartExecutionVerification(const Message &request) { + // TM[1,3] successful start of execution verification report + + Message report = createTM(3); + + 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, ECSS_SEQUENCE_FLAGS); // sequence flags + report.appendBits(14, 0); // packet sequence count + + storeMessage(report); +} + +void RequestVerificationService::failStartExecutionVerification(const Message &request, + ErrorHandler::ExecutionStartErrorType errorCode) { + // TM[1,4] failed start of execution verification report + + Message report = createTM(4); + + 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, ECSS_SEQUENCE_FLAGS); // sequence flags report.appendBits(14, 0); // packet sequence count(not implemented) - report.appendEnum16(0); // error code(not implemented) + report.appendEnum16(errorCode); // error code storeMessage(report); } -void RequestVerificationService::successExecutionVerification(const Message &request) { +void RequestVerificationService::successProgressExecutionVerification(const Message &request, + uint8_t stepID) { + // TM[1,5] successful progress of execution verification report + + Message report = createTM(5); + + 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, ECSS_SEQUENCE_FLAGS); // sequence flags + report.appendBits(14, 0); // packet sequence count(not implemented) + report.appendByte(stepID); // step ID + + storeMessage(report); +} + +void RequestVerificationService::failProgressExecutionVerification(const Message &request, + ErrorHandler::ExecutionProgressErrorType errorCode, uint8_t stepID) { + // TM[1,6] failed progress of execution verification report + + Message report = createTM(6); + + 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, ECSS_SEQUENCE_FLAGS); // sequence flags + report.appendBits(14, 0); // packet sequence count(not implemented) + report.appendByte(stepID); // step ID + report.appendEnum16(errorCode); // error code + + storeMessage(report); +} + +void RequestVerificationService::successCompletionExecutionVerification(const Message &request) { // TM[1,7] successful completion of execution verification report Message report = createTM(7); @@ -42,14 +110,15 @@ void RequestVerificationService::successExecutionVerification(const Message &req 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.appendEnumerated(2, ECSS_SEQUENCE_FLAGS); // sequence flags report.appendBits(14, 0); // packet sequence count(not implemented) storeMessage(report); } void -RequestVerificationService::failExecutionVerification(const Message &request) { +RequestVerificationService::failCompletionExecutionVerification(const Message &request, + ErrorHandler::ExecutionCompletionErrorType errorCode) { // TM[1,8] failed completion of execution verification report Message report = createTM(8); @@ -58,15 +127,16 @@ RequestVerificationService::failExecutionVerification(const Message &request) { 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.appendEnumerated(2, ECSS_SEQUENCE_FLAGS); // sequence flags report.appendBits(14, 0); // packet sequence count(not implemented) - report.appendEnum16(0); // error code(not implemented) + report.appendEnum16(errorCode); // error code storeMessage(report); } void -RequestVerificationService::failRoutingVerification(const Message &request) { +RequestVerificationService::failRoutingVerification(const Message &request, + ErrorHandler::RoutingErrorType errorCode) { // TM[1,10] failed routing verification report Message report = createTM(10); @@ -75,34 +145,45 @@ RequestVerificationService::failRoutingVerification(const Message &request) { 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.appendEnumerated(2, ECSS_SEQUENCE_FLAGS); // sequence flags report.appendBits(14, 0); // packet sequence count(not implemented) - report.appendEnum16(0); // error code(not implemented) + report.appendEnum16(errorCode); // error code storeMessage(report); } + void RequestVerificationService::execute(const Message &message) { switch (message.messageType) { case 1: successAcceptanceVerification(message); break; - case 2: - failAcceptanceVerification(message); + //case 2: + //failAcceptanceVerification(message); + //break; + case 3: + successStartExecutionVerification(message); break; + //case 4: + //failStartExecutionVerification(message); + //break; + //case 5: + //successProgressExecutionVerification(message); + //break; + //case 6: + //failProgressExecutionVerification(message); + //break; case 7: - successExecutionVerification(message); - break; - case 8: - failExecutionVerification(message); - break; - case 10: - failRoutingVerification(message); + successCompletionExecutionVerification(message); break; + //case 8: + //failCompletionExecutionVerification(message); + //break; + //case 10: + //failRoutingVerification(message); + //break; default: - // cout is very bad for embedded systems - std::cout << "Error: There is not such a message type in ST[01] service"; - assert(false); + ErrorHandler::reportInternalError(ErrorHandler::UnknownMessageType); break; } } diff --git a/src/main.cpp b/src/main.cpp index bc6fcc911e3b2f95cb29861c14fde59f7affcb05..c62b168141de2c4034cac45420be4aa028f1313d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -118,16 +118,31 @@ int main() { reqVerifService.successAcceptanceVerification(receivedMessage); receivedMessage = Message(1, 2, Message::TC, 3); - reqVerifService.failAcceptanceVerification(receivedMessage); + reqVerifService.failAcceptanceVerification(receivedMessage, ErrorHandler::UnknownAcceptanceError); + + receivedMessage = Message(1, 3, Message::TC, 3); + reqVerifService.successStartExecutionVerification(receivedMessage); + + receivedMessage = Message(1, 4, Message::TC, 3); + reqVerifService.failStartExecutionVerification(receivedMessage, + ErrorHandler::UnknownExecutionStartError); + + receivedMessage = Message(1, 5, Message::TC, 3); + reqVerifService.successProgressExecutionVerification(receivedMessage, 0); + + receivedMessage = Message(1, 6, Message::TC, 3); + reqVerifService.failProgressExecutionVerification(receivedMessage, + ErrorHandler::UnknownExecutionProgressError, 0); receivedMessage = Message(1, 7, Message::TC, 3); - reqVerifService.successExecutionVerification(receivedMessage); + reqVerifService.successCompletionExecutionVerification(receivedMessage); receivedMessage = Message(1, 8, Message::TC, 3); - reqVerifService.failExecutionVerification(receivedMessage); + reqVerifService.failCompletionExecutionVerification(receivedMessage, + ErrorHandler::UnknownExecutionCompletionError); receivedMessage = Message(1, 10, Message::TC, 3); - reqVerifService.failRoutingVerification(receivedMessage); + reqVerifService.failRoutingVerification(receivedMessage, ErrorHandler::UnknownRoutingError); // ST[05] (5,1 to 5,4) test [works] const char eventReportData[12] = "Hello World"; @@ -155,14 +170,22 @@ int main() { // ST[01] test message = Message(1, 1, Message::TC, 3); messageParser.execute(message); - message = Message(1, 2, Message::TC, 3); + //message = Message(1, 2, Message::TC, 3); + //messageParser.execute(message); + message = Message(1, 3, Message::TC, 3); messageParser.execute(message); + //message = Message(1, 4, Message::TC, 3); + //messageParser.execute(message); + //message = Message(1, 5, Message::TC, 3) + //messageParser.execute(message); + //message = Message(1, 6, Message::TC, 3) + //messageParser.execute(message); message = Message(1, 7, Message::TC, 3); messageParser.execute(message); - message = Message(1, 8, Message::TC, 3); - messageParser.execute(message); - message = Message(1, 10, Message::TC, 3); - messageParser.execute(message); + //message = Message(1, 8, Message::TC, 3); + //messageParser.execute(message); + //message = Message(1, 10, Message::TC, 3); + //messageParser.execute(message); // ErrorHandler test std::cout << std::flush; diff --git a/test/ErrorHandler.cpp b/test/ErrorHandler.cpp index e6d4003bc89d40ef363d1a24465e739abd2b7740..eb8be383e89a8ce91686eb0ceddf57c7cd383933 100644 --- a/test/ErrorHandler.cpp +++ b/test/ErrorHandler.cpp @@ -19,14 +19,60 @@ TEST_CASE("Error: Failed Acceptance", "[errors]") { CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); CHECK(report.readBits(1) == false); CHECK(report.readBits(11) == 47); - CHECK(report.readBits(2) == 0); + CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); CHECK(report.readBits(14) == failedMessage.packetSequenceCount); - CHECK(report.readEnum16() == 0); + CHECK(report.readEnum16() == ErrorHandler::MessageTooShort); +} + +TEST_CASE("Error: Failed Execution Start", "[errors]") { + Message failedMessage(38, 32, Message::TC, 56); + ErrorHandler::reportError(failedMessage, ErrorHandler::UnknownExecutionStartError); + + REQUIRE(ServiceTests::hasOneMessage()); + Message report = ServiceTests::get(0); + + // Check that a TM[1,3] message was returned + CHECK(report.serviceType == 1); + CHECK(report.messageType == 4); + CHECK(report.packetType == Message::TM); + REQUIRE(report.dataSize == 6); + + CHECK(report.readBits(3) == CCSDS_PACKET_VERSION); + CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); + CHECK(report.readBits(1) == false); + CHECK(report.readBits(11) == 56); + CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); + CHECK(report.readBits(14) == failedMessage.packetSequenceCount); + CHECK(report.readEnum16() == ErrorHandler::UnknownExecutionStartError); +} + +TEST_CASE("Error: Failed Execution Progress", "[errors]") { + Message failedMessage(38, 32, Message::TC, 56); + ErrorHandler::reportProgressError(failedMessage, ErrorHandler::UnknownExecutionProgressError, + 0); + + REQUIRE(ServiceTests::hasOneMessage()); + Message report = ServiceTests::get(0); + + // Check that a TM[1,6] message was returned + CHECK(report.serviceType == 1); + CHECK(report.messageType == 6); + CHECK(report.packetType == Message::TM); + REQUIRE(report.dataSize == 7); + + CHECK(report.readBits(3) == CCSDS_PACKET_VERSION); + CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); + CHECK(report.readBits(1) == false); + CHECK(report.readBits(11) == 56); + CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); + CHECK(report.readBits(14) == failedMessage.packetSequenceCount); + CHECK(report.readEnum16() == ErrorHandler::UnknownExecutionProgressError); + CHECK(report.readByte() == 0); // stepID } TEST_CASE("Error: Failed Execution Completion", "[errors]") { Message failedMessage(38, 32, Message::TC, 56); - ErrorHandler::reportError(failedMessage, ErrorHandler::UnknownExecutionError); + ErrorHandler::reportError(failedMessage, ErrorHandler::UnknownExecutionCompletionError); REQUIRE(ServiceTests::hasOneMessage()); Message report = ServiceTests::get(0); @@ -41,9 +87,9 @@ TEST_CASE("Error: Failed Execution Completion", "[errors]") { CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); CHECK(report.readBits(1) == false); CHECK(report.readBits(11) == 56); - CHECK(report.readBits(2) == 0); + CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); CHECK(report.readBits(14) == failedMessage.packetSequenceCount); - CHECK(report.readEnum16() == 0); + CHECK(report.readEnum16() == ErrorHandler::UnknownExecutionCompletionError); } TEST_CASE("Error: Failed Routing", "[errors]") { @@ -63,7 +109,7 @@ TEST_CASE("Error: Failed Routing", "[errors]") { CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); CHECK(report.readBits(1) == false); CHECK(report.readBits(11) == 71); - CHECK(report.readBits(2) == 0); + CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); CHECK(report.readBits(14) == failedMessage.packetSequenceCount); - CHECK(report.readEnum16() == 0); + CHECK(report.readEnum16() == ErrorHandler::UnknownRoutingError); } diff --git a/test/MessageParser.cpp b/test/MessageParser.cpp index d06d7c2570cb9d036c7e1c01db5ba09a25fdf4bf..ace886d2b54e89ec08e4cb7c83d4c4a69ec3b52a 100644 --- a/test/MessageParser.cpp +++ b/test/MessageParser.cpp @@ -16,13 +16,41 @@ TEST_CASE("ST[01] message execution", "[MessageParser][st01]") { CHECK(response.messageType == 1); CHECK(response.packetType == Message::TM); - message = Message(1, 2, Message::TC, 2); + //message = Message(1, 2, Message::TC, 2); + //messageParser.execute(message); + //response = ServiceTests::get(1); + //CHECK(response.serviceType == 1); + //CHECK(response.messageType == 2); + //CHECK(response.packetType == Message::TM); + + message = Message(1, 3, Message::TC, 2); messageParser.execute(message); response = ServiceTests::get(1); CHECK(response.serviceType == 1); - CHECK(response.messageType == 2); + CHECK(response.messageType == 3); CHECK(response.packetType == Message::TM); + + //message = Message(1, 4, Message::TC, 2); + //messageParser.execute(message); + //response = ServiceTests::get(2); + //CHECK(response.serviceType == 1); + //CHECK(response.messageType == 4); + //CHECK(response.packetType == Message::TM); + + //message = Message(1, 5, Message::TC, 2); + //messageParser.execute(message); + //response = ServiceTests::get(2); + //CHECK(response.serviceType == 1); + //CHECK(response.messageType == 5); + //CHECK(response.packetType == Message::TM); + //message = Message(1, 6, Message::TC, 2); + //messageParser.execute(message); + //response = ServiceTests::get(2); + //CHECK(response.serviceType == 1); + //CHECK(response.messageType == 6); + //CHECK(response.packetType == Message::TM); + message = Message(1, 7, Message::TC, 2); messageParser.execute(message); response = ServiceTests::get(2); @@ -30,19 +58,19 @@ TEST_CASE("ST[01] message execution", "[MessageParser][st01]") { CHECK(response.messageType == 7); CHECK(response.packetType == Message::TM); - message = Message(1, 8, Message::TC, 2); - messageParser.execute(message); - response = ServiceTests::get(3); - CHECK(response.serviceType == 1); - CHECK(response.messageType == 8); - CHECK(response.packetType == Message::TM); + //message = Message(1, 8, Message::TC, 2); + //messageParser.execute(message); + //response = ServiceTests::get(3); + //CHECK(response.serviceType == 1); + //CHECK(response.messageType == 8); + //CHECK(response.packetType == Message::TM); - message = Message(1, 10, Message::TC, 2); - messageParser.execute(message); - response = ServiceTests::get(4); - CHECK(response.serviceType == 1); - CHECK(response.messageType == 10); - CHECK(response.packetType == Message::TM); + //message = Message(1, 10, Message::TC, 2); + //messageParser.execute(message); + //response = ServiceTests::get(4); + //CHECK(response.serviceType == 1); + //CHECK(response.messageType == 10); + //CHECK(response.packetType == Message::TM); } TEST_CASE("ST[17] message execution", "[MessageParser][st17]") { diff --git a/test/Services/RequestVerificationService.cpp b/test/Services/RequestVerificationService.cpp index 65a256d3d37010317e7b61106beeb2083f7e976e..3e80440466cb13eb0a89d49dbc3d23b7eafd43ab 100644 --- a/test/Services/RequestVerificationService.cpp +++ b/test/Services/RequestVerificationService.cpp @@ -22,7 +22,7 @@ TEST_CASE("TM[1,1]", "[service][st01]") { 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.readEnumerated(2) == ECSS_SEQUENCE_FLAGS); // sequence flags CHECK(response.readBits(14) == 0); // packet sequence count } @@ -30,7 +30,8 @@ TEST_CASE("TM[1,2]", "[service][st01]") { RequestVerificationService reqVerifService; Message receivedMessage = Message(1, 2, Message::TC, 3); - reqVerifService.failAcceptanceVerification(receivedMessage); + reqVerifService.failAcceptanceVerification(receivedMessage, + ErrorHandler::UnknownAcceptanceError); REQUIRE(ServiceTests::hasOneMessage()); Message response = ServiceTests::get(0); @@ -45,16 +46,115 @@ TEST_CASE("TM[1,2]", "[service][st01]") { 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.readEnumerated(2) == ECSS_SEQUENCE_FLAGS); // sequence flags CHECK(response.readBits(14) == 0); // packet sequence count - CHECK(response.readEnum16() == 0); // error code + CHECK(response.readEnum16() == ErrorHandler::UnknownAcceptanceError); // error code +} + +TEST_CASE("TM[1,3]", "[service][st01]") { + RequestVerificationService reqVerifService; + + Message receivedMessage = Message(1, 3, Message::TC, 3); + reqVerifService.successStartExecutionVerification(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 == 3); + 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) == 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) == ECSS_SEQUENCE_FLAGS); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count +} + +TEST_CASE("TM[1,4]", "[service][st01]") { + RequestVerificationService reqVerifService; + + Message receivedMessage = Message(1, 2, Message::TC, 3); + reqVerifService.failStartExecutionVerification(receivedMessage, + ErrorHandler::UnknownExecutionStartError); + REQUIRE(ServiceTests::hasOneMessage()); + + Message response = ServiceTests::get(0); + // Checks for the data-members of the object response + CHECK(response.serviceType == 1); + CHECK(response.messageType == 4); + 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) == 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) == ECSS_SEQUENCE_FLAGS); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readEnum16() == ErrorHandler::UnknownExecutionStartError); // error code +} + +TEST_CASE("TM[1,5]", "[service][st01]") { + RequestVerificationService reqVerifService; + + Message receivedMessage = Message(1, 5, Message::TC, 3); + reqVerifService.successProgressExecutionVerification(receivedMessage, 0); + REQUIRE(ServiceTests::hasOneMessage()); + + Message response = ServiceTests::get(0); + // Checks for the data-members of the object response + CHECK(response.serviceType == 1); + CHECK(response.messageType == 5); + CHECK(response.packetType == Message::TM); // packet type + CHECK(response.applicationId == 0); + REQUIRE(response.dataSize == 5); // 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) == 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) == ECSS_SEQUENCE_FLAGS); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readByte() == 0); // step ID +} + +TEST_CASE("TM[1,6]", "[service][st01]") { + RequestVerificationService reqVerifService; + + Message receivedMessage = Message(1, 5, Message::TC, 3); + reqVerifService.failProgressExecutionVerification(receivedMessage, + ErrorHandler::UnknownExecutionProgressError, + 0); + REQUIRE(ServiceTests::hasOneMessage()); + + Message response = ServiceTests::get(0); + // Checks for the data-members of the object response + CHECK(response.serviceType == 1); + CHECK(response.messageType == 6); + CHECK(response.packetType == Message::TM); // packet type + CHECK(response.applicationId == 0); + REQUIRE(response.dataSize == 7); // 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) == 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) == ECSS_SEQUENCE_FLAGS); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readByte() == 0); // step ID + CHECK(response.readEnum16() == ErrorHandler::UnknownExecutionProgressError); } TEST_CASE("TM[1,7]", "[service][st01]") { RequestVerificationService reqVerifService; Message receivedMessage = Message(1, 7, Message::TC, 3); - reqVerifService.successExecutionVerification(receivedMessage); + reqVerifService.successCompletionExecutionVerification(receivedMessage); REQUIRE(ServiceTests::hasOneMessage()); Message response = ServiceTests::get(0); @@ -69,7 +169,7 @@ TEST_CASE("TM[1,7]", "[service][st01]") { 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.readEnumerated(2) == ECSS_SEQUENCE_FLAGS); // sequence flags CHECK(response.readBits(14) == 0); // packet sequence count } @@ -77,7 +177,8 @@ TEST_CASE("TM[1,8]", "[service][st01]") { RequestVerificationService reqVerifService; Message receivedMessage = Message(1, 8, Message::TC, 3); - reqVerifService.failExecutionVerification(receivedMessage); + reqVerifService.failCompletionExecutionVerification(receivedMessage, + ErrorHandler::UnknownExecutionCompletionError); REQUIRE(ServiceTests::hasOneMessage()); Message response = ServiceTests::get(0); @@ -91,16 +192,16 @@ TEST_CASE("TM[1,8]", "[service][st01]") { 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.readEnumerated(2) == ECSS_SEQUENCE_FLAGS); // sequence flags CHECK(response.readBits(14) == 0); // packet sequence count - CHECK(response.readEnum16() == 0); // error code + CHECK(response.readEnum16() == ErrorHandler::UnknownExecutionCompletionError); // error code } TEST_CASE("TM[1,10]", "[service][st01]") { RequestVerificationService reqVerifService; Message receivedMessage = Message(1, 10, Message::TC, 3); - reqVerifService.failRoutingVerification(receivedMessage); + reqVerifService.failRoutingVerification(receivedMessage, ErrorHandler::UnknownRoutingError); REQUIRE(ServiceTests::hasOneMessage()); Message response = ServiceTests::get(0); @@ -115,7 +216,7 @@ TEST_CASE("TM[1,10]", "[service][st01]") { 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.readEnumerated(2) == ECSS_SEQUENCE_FLAGS); // sequence flags CHECK(response.readBits(14) == 0); // packet sequence count - CHECK(response.readEnum16() == 0); // error code + CHECK(response.readEnum16() == ErrorHandler::UnknownRoutingError); // error code }