diff --git a/inc/ErrorHandler.hpp b/inc/ErrorHandler.hpp index adffdc132bffd5aa7830bcbd414f415a643c6340..df687ad47b7799db340bf4a7884e38340e0ca373 100644 --- a/inc/ErrorHandler.hpp +++ b/inc/ErrorHandler.hpp @@ -56,6 +56,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, }; /** diff --git a/inc/Services/RequestVerificationService.hpp b/inc/Services/RequestVerificationService.hpp index a664e1147414260a3ca07118670f58d0869dc28b..a3edf9a9a5386b27e20d1036dc884c064d9fa82c 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); @@ -39,26 +40,59 @@ public: */ void failAcceptanceVerification(const Message &request); + /** + * 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 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 + */ + void failStartExecutionVerification(const Message &request); + + /** + * 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 + */ + void successProgressExecutionVerification(const Message &request); + + /** + * 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 + */ + void failProgressExecutionVerification(const Message &request); /** * 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 */ - void failExecutionVerification(const Message &request); + void failCompletionExecutionVerification(const Message &request); /** * TM[1,10] failed routing verification report @@ -66,7 +100,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 failed the routing - * */ void failRoutingVerification(const Message &request); diff --git a/src/ErrorHandler.cpp b/src/ErrorHandler.cpp index d689ab1a1835c08c4a2908c6822cd1513b3ac422..0cb0c20374d905aa7c8fe1e2b9e5307e1e730931 100644 --- a/src/ErrorHandler.cpp +++ b/src/ErrorHandler.cpp @@ -16,7 +16,7 @@ void ErrorHandler::reportError(const Message &message, AcceptanceErrorType error template<> void ErrorHandler::reportError(const Message &message, ExecutionErrorType errorCode) { - requestVerificationService.failExecutionVerification(message); + requestVerificationService.failCompletionExecutionVerification(message); logError(message, errorCode); } diff --git a/src/Services/RequestVerificationService.cpp b/src/Services/RequestVerificationService.cpp index 0e08b3e71ab47f462a306a8c7c2bde193a68a9dc..33c06beb6969984ab35ac004d7911849d6095709 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,7 +10,7 @@ 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(not implemented) report.appendBits(14, 0); // packet sequence count(not implemented) storeMessage(report); @@ -26,14 +26,76 @@ 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(not implemented) + report.appendBits(14, 0); // packet sequence count(not implemented) + report.appendEnum16(0); // error code(not implemented) + + 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(not implemented) + report.appendBits(14, 0); // packet sequence count(not implemented) + + storeMessage(report); +} + +void RequestVerificationService::failStartExecutionVerification(const Message &request){ + // 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(not implemented) report.appendBits(14, 0); // packet sequence count(not implemented) report.appendEnum16(0); // error code(not implemented) storeMessage(report); } -void RequestVerificationService::successExecutionVerification(const Message &request) { +void RequestVerificationService::successProgressExecutionVerification(const Message &request){ + // 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(not implemented) + report.appendBits(14, 0); // packet sequence count(not implemented) + + storeMessage(report); +} + +void RequestVerificationService::failProgressExecutionVerification(const Message &request){ + // 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(not implemented) + report.appendBits(14, 0); // packet sequence count(not implemented) + report.appendEnum16(0); // error code(not implemented) + + storeMessage(report); +} + +void RequestVerificationService::successCompletionExecutionVerification(const Message &request) { // TM[1,7] successful completion of execution verification report Message report = createTM(7); @@ -42,14 +104,14 @@ 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(not implemented) report.appendBits(14, 0); // packet sequence count(not implemented) storeMessage(report); } void -RequestVerificationService::failExecutionVerification(const Message &request) { +RequestVerificationService::failCompletionExecutionVerification(const Message &request) { // TM[1,8] failed completion of execution verification report Message report = createTM(8); @@ -58,7 +120,7 @@ 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(not implemented) report.appendBits(14, 0); // packet sequence count(not implemented) report.appendEnum16(0); // error code(not implemented) @@ -75,7 +137,7 @@ 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(not implemented) report.appendBits(14, 0); // packet sequence count(not implemented) report.appendEnum16(0); // error code(not implemented) @@ -90,19 +152,29 @@ void RequestVerificationService::execute(const Message &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); + successCompletionExecutionVerification(message); break; case 8: - failExecutionVerification(message); + 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 bcc262edea6839be3fdee14bebf64daf2f0a1859..7649c4abbf0e9aed49f56ddc54adf47fe0179524 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -119,11 +119,23 @@ int main() { receivedMessage = Message(1, 2, Message::TC, 3); reqVerifService.failAcceptanceVerification(receivedMessage); + receivedMessage = Message(1, 3, Message::TC, 3); + reqVerifService.successStartExecutionVerification(receivedMessage); + + receivedMessage = Message(1, 4, Message::TC, 3); + reqVerifService.failStartExecutionVerification(receivedMessage); + + receivedMessage = Message(1, 5, Message::TC, 3); + reqVerifService.successProgressExecutionVerification(receivedMessage); + + receivedMessage = Message(1, 6, Message::TC, 3); + reqVerifService.failProgressExecutionVerification(receivedMessage); + 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); receivedMessage = Message(1, 10, Message::TC, 3); reqVerifService.failRoutingVerification(receivedMessage);