diff --git a/inc/MessageParser.hpp b/inc/MessageParser.hpp index 0af0afbf7bf55f278c9bc69f27688dc56b4560b6..485d42dbfa90dca62b5f27275726a399a2c645ed 100644 --- a/inc/MessageParser.hpp +++ b/inc/MessageParser.hpp @@ -20,6 +20,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 a3edf9a9a5386b27e20d1036dc884c064d9fa82c..6fef8a641083ed9fa2c435375eb89f327b7b473d 100644 --- a/inc/Services/RequestVerificationService.hpp +++ b/inc/Services/RequestVerificationService.hpp @@ -38,7 +38,8 @@ public: * 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(const Message &request); + void failAcceptanceVerification(const Message &request, ErrorHandler::AcceptanceErrorType + errorCode); /** * TM[1,3] successful start of execution verification report @@ -56,7 +57,8 @@ public: * 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); + void failStartExecutionVerification(const Message &request, ErrorHandler::ExecutionErrorType + errorCode); /** * TM[1,5] successful progress of execution verification report @@ -74,7 +76,8 @@ public: * 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); + void failProgressExecutionVerification(const Message &request, + ErrorHandler::ExecutionErrorType errorCode); /** * TM[1,7] successful completion of execution verification report @@ -92,7 +95,8 @@ public: * The data is actually some data members of Message that contain the basic info of the * telecommand packet that failed to be executed completely */ - void failCompletionExecutionVerification(const Message &request); + void failCompletionExecutionVerification(const Message &request, + ErrorHandler::ExecutionErrorType errorCode); /** * TM[1,10] failed routing verification report @@ -101,7 +105,7 @@ public: * 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); + void failRoutingVerification(const Message &request, ErrorHandler::RoutingErrorType errorCode); /** * It is responsible to call the suitable function that execute the proper subservice. The @@ -110,9 +114,10 @@ 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); + //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 0cb0c20374d905aa7c8fe1e2b9e5307e1e730931..1cb8e686a9caf74a2140e6b4753d1efd86fa3fd4 100644 --- a/src/ErrorHandler.cpp +++ b/src/ErrorHandler.cpp @@ -9,21 +9,21 @@ 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, ExecutionErrorType errorCode) { - requestVerificationService.failCompletionExecutionVerification(message); + 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 fe2426e5d394ca2d63e6036793417267e645ad47..540738e55be43bb02b4e30cc5b4e5cf2e60d6d8b 100644 --- a/src/MessageParser.cpp +++ b/src/MessageParser.cpp @@ -10,15 +10,14 @@ RequestVerificationService RequestVerificationService::instance; void MessageParser::execute(Message &message) { switch (message.serviceType) { - case 1: - RequestVerificationService::instance.execute(message); - break; + //case 1: + //RequestVerificationService::instance.execute(message); + //break; case 17: 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 33c06beb6969984ab35ac004d7911849d6095709..3a2ed7b774d09c029e42791ca173d76a1167bf10 100644 --- a/src/Services/RequestVerificationService.cpp +++ b/src/Services/RequestVerificationService.cpp @@ -17,7 +17,8 @@ void RequestVerificationService::successAcceptanceVerification(const Message &re } 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); @@ -28,12 +29,12 @@ RequestVerificationService::failAcceptanceVerification(const Message &request) { 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) + report.appendEnum16(errorCode); // error code storeMessage(report); } -void RequestVerificationService::successStartExecutionVerification(const Message &request){ +void RequestVerificationService::successStartExecutionVerification(const Message &request) { // TM[1,3] successful start of execution verification report Message report = createTM(3); @@ -43,12 +44,13 @@ void RequestVerificationService::successStartExecutionVerification(const Message 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.appendBits(14, 0); // packet sequence count storeMessage(report); } -void RequestVerificationService::failStartExecutionVerification(const Message &request){ +void RequestVerificationService::failStartExecutionVerification(const Message &request, + ErrorHandler::ExecutionErrorType errorCode) { // TM[1,4] failed start of execution verification report Message report = createTM(4); @@ -59,12 +61,12 @@ void RequestVerificationService::failStartExecutionVerification(const Message &r 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) + report.appendEnum16(errorCode); // error code storeMessage(report); } -void RequestVerificationService::successProgressExecutionVerification(const Message &request){ +void RequestVerificationService::successProgressExecutionVerification(const Message &request) { // TM[1,5] successful progress of execution verification report Message report = createTM(5); @@ -79,7 +81,8 @@ void RequestVerificationService::successProgressExecutionVerification(const Mess storeMessage(report); } -void RequestVerificationService::failProgressExecutionVerification(const Message &request){ +void RequestVerificationService::failProgressExecutionVerification(const Message &request, + ErrorHandler::ExecutionErrorType errorCode) { // TM[1,6] failed progress of execution verification report Message report = createTM(6); @@ -90,7 +93,7 @@ void RequestVerificationService::failProgressExecutionVerification(const Message 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) + report.appendEnum16(errorCode); // error code storeMessage(report); } @@ -111,7 +114,8 @@ void RequestVerificationService::successCompletionExecutionVerification(const Me } void -RequestVerificationService::failCompletionExecutionVerification(const Message &request) { +RequestVerificationService::failCompletionExecutionVerification(const Message &request, + ErrorHandler::ExecutionErrorType errorCode) { // TM[1,8] failed completion of execution verification report Message report = createTM(8); @@ -122,13 +126,14 @@ RequestVerificationService::failCompletionExecutionVerification(const Message &r 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) + 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); @@ -139,11 +144,12 @@ RequestVerificationService::failRoutingVerification(const Message &request) { 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) + report.appendEnum16(errorCode); // error code storeMessage(report); } +/* void RequestVerificationService::execute(const Message &message) { switch (message.messageType) { case 1: @@ -178,3 +184,4 @@ void RequestVerificationService::execute(const Message &message) { break; } } + */ diff --git a/src/main.cpp b/src/main.cpp index 7649c4abbf0e9aed49f56ddc54adf47fe0179524..1b395c00b2bde8f78c4511bb776fd6458d533779 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -117,28 +117,28 @@ 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); + reqVerifService.failStartExecutionVerification(receivedMessage, ErrorHandler::UnknownExecutionError); receivedMessage = Message(1, 5, Message::TC, 3); reqVerifService.successProgressExecutionVerification(receivedMessage); receivedMessage = Message(1, 6, Message::TC, 3); - reqVerifService.failProgressExecutionVerification(receivedMessage); + reqVerifService.failProgressExecutionVerification(receivedMessage, ErrorHandler::UnknownExecutionError); receivedMessage = Message(1, 7, Message::TC, 3); reqVerifService.successCompletionExecutionVerification(receivedMessage); receivedMessage = Message(1, 8, Message::TC, 3); - reqVerifService.failCompletionExecutionVerification(receivedMessage); + reqVerifService.failCompletionExecutionVerification(receivedMessage, ErrorHandler::UnknownExecutionError); 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"; @@ -165,15 +165,15 @@ int main() { // ST[01] test message = Message(1, 1, Message::TC, 3); - messageParser.execute(message); + //messageParser.execute(message); message = Message(1, 2, Message::TC, 3); - messageParser.execute(message); + //messageParser.execute(message); message = Message(1, 7, Message::TC, 3); - messageParser.execute(message); + //messageParser.execute(message); message = Message(1, 8, Message::TC, 3); - messageParser.execute(message); + //messageParser.execute(message); message = Message(1, 10, Message::TC, 3); - messageParser.execute(message); + //messageParser.execute(message); // ErrorHandler test std::cout << std::flush;