diff --git a/inc/ECSS_Definitions.hpp b/inc/ECSS_Definitions.hpp index 90eec5444a553b3ffb8781562fad03740c08f29e..eb2f737d61cdc9908902200278d251f14b740910 100644 --- a/inc/ECSS_Definitions.hpp +++ b/inc/ECSS_Definitions.hpp @@ -94,6 +94,12 @@ */ #define ECSS_TIME_MARGIN_FOR_ACTIVATION 60 +/** + * @brief Maximum size of an event's auxiliary data + * @see EventReportService + */ +#define ECSS_EVENT_DATA_AUXILIARY_MAX_SIZE 64 + /** * @brief Size of the multimap that holds every event-action definition * @see EventActionService diff --git a/inc/ErrorHandler.hpp b/inc/ErrorHandler.hpp index 238d685d6c92a345ec171e7b607c728022c15ba5..caeae9c80520866bd895f9e1e3db2bd4e4080204 100644 --- a/inc/ErrorHandler.hpp +++ b/inc/ErrorHandler.hpp @@ -229,11 +229,17 @@ public: * Reports a failure that occurred internally, not due to a failure of a received packet. * * Creates an error if \p condition is false. The created error is Internal. + * + * @param condition The condition to check. Throws an error if false. + * @param errorCode The error code that is assigned to this error. One of the \ref ErrorHandler enum values. + * @return Returns \p condition, i.e. true if the assertion is successful, false if not. */ - static void assertInternal(bool condition, InternalErrorType errorCode) { + static bool assertInternal(bool condition, InternalErrorType errorCode) { if (not condition) { reportInternalError(errorCode); } + + return condition; } /** @@ -242,12 +248,19 @@ public: * Reports a failure that occurred while processing a request, in any of the process phases. * * Creates an error if \p condition is false. The created error corresponds to a \p message. + * + * @param condition The condition to check. Throws an error if false. + * @param message The message to associate with this error + * @param errorCode The error code that is assigned to this error. One of the \ref ErrorHandler enum values. + * @return Returns \p condition, i.e. true if the assertion is successful, false if not. */ template <typename ErrorType> - static void assertRequest(bool condition, const Message& message, ErrorType errorCode) { + static bool assertRequest(bool condition, const Message& message, ErrorType errorCode) { if (not condition) { reportError(message, errorCode); } + + return condition; } /** diff --git a/inc/Helpers/TimeHelper.hpp b/inc/Helpers/TimeHelper.hpp index 526b80333fbc584e87edbd3115ca3cf413766030..027e078e817bf6748ac693821d7527a9e5c7c811 100644 --- a/inc/Helpers/TimeHelper.hpp +++ b/inc/Helpers/TimeHelper.hpp @@ -33,7 +33,7 @@ * decides what the time unit will be, so this is a subject for discussion. The recommended time unit from the * standard is the second and it is probably the best solution for accuracy. * - * @notes + * @note * The defined epoch for both time formats is 1 January 1958 00:00:00 * * Since CDS format is UTC-based, the leap second correction must be made. The leap seconds that @@ -56,7 +56,7 @@ public: /** * Convert UTC date to elapsed seconds since Unix epoch (1/1/1970 00:00:00). * - * This is a reimplemented mktime() of <ctime> library in an embedded systems way + * This is a reimplemented `mktime()` of the `<ctime>` library in an embedded compatible way * * @note * This function can convert UTC dates after 1 January 2019 to elapsed seconds since Unix epoch @@ -71,7 +71,7 @@ public: /** * Convert elapsed seconds since Unix epoch to UTC date. * - * This is a reimplemented gmtime() of <ctime> library in an embedded systems way + * This is a reimplemented `gmtime()` of the `<ctime>` library in an embedded compatible way * * @note * This function can convert elapsed seconds since Unix epoch to UTC dates after 1 January 2019 @@ -110,7 +110,7 @@ public: * * Converts a UTC date to CUC time format. * - * @notes + * @note * The T-field is specified for the seconds passed from the defined epoch 1 January 1958. We use 4 octets(32 * bits) for the time unit (seconds) because 32 bits for the seconds are enough to count 136 years! But if we use 24 * bits for the seconds then it will count 0,5 years and this isn't enough. Remember we can use only integers diff --git a/inc/Message.hpp b/inc/Message.hpp index b59938dda18b932830057e602fab0178eba81ea1..f94c31bea5cf52138caec588a6f2ec3803794459 100644 --- a/inc/Message.hpp +++ b/inc/Message.hpp @@ -33,7 +33,7 @@ public: /** * @brief Overload the equality operator to compare messages * @details Compare two @ref ::Message objects, based on their contents and type - * @param The message content to compare against + * @param msg The message content to compare against * @return The result of comparison */ bool operator==(const Message& msg) const { diff --git a/inc/MessageParser.hpp b/inc/MessageParser.hpp index 7bc486ef8da6fff253fdf4f02b69593ffafc6fe5..82517e8203cd2eb0735e3625c82ef97b9eb0646f 100644 --- a/inc/MessageParser.hpp +++ b/inc/MessageParser.hpp @@ -36,9 +36,7 @@ public: * This function takes as input TC packets and calls the proper services' functions that have been * implemented to handle TC packets. * - * @param Message Contains the necessary parameters to call the suitable subservice - * @todo Implement the execute() in the upcoming services or generally in the upcoming - * activities + * @param message Contains the necessary parameters to call the suitable subservice */ static void execute(Message& message); @@ -73,8 +71,8 @@ public: * @brief Converts a TC or TM message to a message string, appending just the ECSS header * @todo Add time reference, as soon as it is available and the format has been specified * @param message The Message object to be parsed to a String - * @param size The wanted size of the message (including the headers). Messages larger than \ref size display an - * error. Messages smaller than \ref size are padded with zeros. When `size = 0`, there is no size limit. + * @param size The wanted size of the message (including the headers). Messages larger than \p size display an + * error. Messages smaller than \p size are padded with zeros. When `size = 0`, there is no size limit. * @return A String class containing the parsed Message */ static String<CCSDS_MAX_MESSAGE_SIZE> composeECSS(const Message& message, uint16_t size = 0u); // Ignore-MISRA diff --git a/inc/Service.hpp b/inc/Service.hpp index e28620ffbd1c2c8d711bb52843c0ae7540ca6c34..53bf0bae49366814e9e8bff2a0d1436abbb877c8 100644 --- a/inc/Service.hpp +++ b/inc/Service.hpp @@ -36,7 +36,6 @@ protected: * the TC[17,3] message has `messageType = 3`. * @todo See if the Message must be returned by reference * @todo Set the application ID to the current application - * @todo Use the messageTypeCounter */ Message createTM(uint8_t messageType) { return Message(serviceType, messageType, Message::TM, 0); diff --git a/inc/Services/EventReportService.hpp b/inc/Services/EventReportService.hpp index f9b01634b7eafbbd630dddb2684bfee079a73bbd..69b80e80b504457b3e7f2ddb1cf76f16fb7ad174 100644 --- a/inc/Services/EventReportService.hpp +++ b/inc/Services/EventReportService.hpp @@ -102,9 +102,8 @@ public: * * @param eventID event definition ID * @param data the data of the report - * @param length the length of the data */ - void informativeEventReport(Event eventID, const String<64>& data); + void informativeEventReport(Event eventID, const String<ECSS_EVENT_DATA_AUXILIARY_MAX_SIZE>& data); /** * TM[5,2] low severiity anomaly report @@ -114,9 +113,8 @@ public: * * @param eventID event definition ID * @param data the data of the report - * @param length the length of the data */ - void lowSeverityAnomalyReport(Event eventID, const String<64>& data); + void lowSeverityAnomalyReport(Event eventID, const String<ECSS_EVENT_DATA_AUXILIARY_MAX_SIZE>& data); /** * TM[5,3] medium severity anomaly report @@ -126,9 +124,8 @@ public: * * @param eventID event definition ID * @param data the data of the report - * @param length the length of the data */ - void mediumSeverityAnomalyReport(Event eventID, const String<64>& data); + void mediumSeverityAnomalyReport(Event eventID, const String<ECSS_EVENT_DATA_AUXILIARY_MAX_SIZE>& data); /** * TM[5,4] high severity anomaly report @@ -138,9 +135,8 @@ public: * * @param eventID event definition ID * @param data the data of the report - * @param length the length of the data */ - void highSeverityAnomalyReport(Event eventID, const String<64>& data); + void highSeverityAnomalyReport(Event eventID, const String<ECSS_EVENT_DATA_AUXILIARY_MAX_SIZE>& data); /** * TC[5,5] request to enable report generation @@ -165,7 +161,6 @@ public: /** * TM[5,8] disabled event definitions report * Telemetry package of a report of the disabled event definitions - * @param message */ void listOfDisabledEventsReport(); @@ -182,7 +177,7 @@ public: * is the ground station. * * @note This function is called from the main execute() that is defined in the file MessageParser.hpp - * @param param Contains the necessary parameters to call the suitable subservice + * @param message Contains the necessary parameters to call the suitable subservice */ void execute(Message& message); }; diff --git a/inc/Services/FunctionManagementService.hpp b/inc/Services/FunctionManagementService.hpp index 401591ef7dd53445a460835a584c0cc5802ea6ea..36f68d84ece877d7977d6f704a73f67337702d21 100644 --- a/inc/Services/FunctionManagementService.hpp +++ b/inc/Services/FunctionManagementService.hpp @@ -46,6 +46,7 @@ * include(String<FUNC_NAME_LENGTH>("bar"), &bar); * include(String<FUNC_NAME_LENGTH>("baz"), &baz); * } + * @endcode */ typedef String<ECSS_FUNCTION_NAME_LENGTH> functionName; @@ -61,8 +62,6 @@ public: /** * Constructs the function pointer index with all the necessary functions at initialization time * These functions need to be in scope. Un-default when needed. - * - * @param None */ FunctionManagementService() = default; @@ -93,7 +92,7 @@ public: * is the ground station. * * @note This function is called from the main execute() that is defined in the file MessageParser.hpp - * @param param Contains the necessary parameters to call the suitable subservice + * @param message Contains the necessary parameters to call the suitable subservice */ void execute(Message& message); }; diff --git a/inc/Services/LargePacketTransferService.hpp b/inc/Services/LargePacketTransferService.hpp index 5b3b276cde7489fd483c60d5bde53b4f620a72a0..fe91522b0e50c5cc6007bdb0a247bb35ff584c7a 100644 --- a/inc/Services/LargePacketTransferService.hpp +++ b/inc/Services/LargePacketTransferService.hpp @@ -74,7 +74,7 @@ public: /** * Function that splits large messages - * @param Message that is exceeds the standards and has to be split down + * @param message that is exceeds the standards and has to be split down * @param largeMessageTransactionIdentifier that is a value we assign to this splitting of the large message */ void split(Message& message, uint16_t largeMessageTransactionIdentifier); diff --git a/inc/Services/MemoryManagementService.hpp b/inc/Services/MemoryManagementService.hpp index f5c1770e035621eb16cd8da5946d1745372f7208..9ae1de6e9bcd4a7aa8503c2a4475e4fe820f7085 100644 --- a/inc/Services/MemoryManagementService.hpp +++ b/inc/Services/MemoryManagementService.hpp @@ -80,7 +80,7 @@ public: * is the ground station. * * @note This function is called from the main execute() that is defined in the file MessageParser.hpp - * @param param Contains the necessary parameters to call the suitable subservice + * @param message Contains the necessary parameters to call the suitable subservice */ void execute(Message& message); diff --git a/inc/Services/TimeBasedSchedulingService.hpp b/inc/Services/TimeBasedSchedulingService.hpp index e3a6b7721a0e056fac509cb54a1db5c18dbcdbba..575b03595e94158a5dae3b4e219d903ba608f942 100644 --- a/inc/Services/TimeBasedSchedulingService.hpp +++ b/inc/Services/TimeBasedSchedulingService.hpp @@ -59,14 +59,11 @@ private: * * @details The request identifier consists of the application process ID, the packet * sequence count and the source ID, all defined in the ECSS standard. - * @var applicationID Application process ID - * @var sequenceCount Packet sequence count - * @var sourceID Packet source ID */ struct RequestID { - uint16_t applicationID = 0; - uint16_t sequenceCount = 0; - uint8_t sourceID = 0; + uint16_t applicationID = 0; ///< Application process ID + uint16_t sequenceCount = 0; ///< Packet sequence count + uint8_t sourceID = 0; ///< Packet source ID bool operator!=(const RequestID& rightSide) const { return (sequenceCount != rightSide.sequenceCount) or (applicationID != rightSide.applicationID) or @@ -79,16 +76,14 @@ private: * * @details All scheduled activities must contain the request they exist for, their release * time and the corresponding request identifier. - * @var request Contains the received TC request - * @var requestID Contains the unique request identifier for that activity - * @var requestReleaseTime The absolute time is seconds of the request release + * + * @todo If we decide to use sub-schedules, the ID of that has to be defined + * @todo If groups are used, then the group ID has to be defined here */ struct ScheduledActivity { - Message request; // Hold the received command request - RequestID requestID; // Request ID, characteristic of the definition - uint32_t requestReleaseTime = 0; // Keep the command release time - // todo: If we decide to use sub-schedules, the ID of that has to be defined - // todo: If groups are used, then the group ID has to be defined here + Message request; ///< Hold the received command request + RequestID requestID; ///< Request ID, characteristic of the definition + uint32_t requestReleaseTime = 0; ///< Keep the command release time }; /** @@ -138,7 +133,7 @@ public: void enableScheduleExecution(Message& request); /** - * @breif TC[11,2] disable the time-based schedule execution function + * @brief TC[11,2] disable the time-based schedule execution function * * @details Disables the time-based command execution scheduling * @param request Provide the received message as a parameter diff --git a/inc/Services/TimeManagementService.hpp b/inc/Services/TimeManagementService.hpp index 22e2aefb4cbe59ce538d51ac1f0608ed15c930c8..54617aaf1aaf10ae8308741b2ff459f16ba38b20 100644 --- a/inc/Services/TimeManagementService.hpp +++ b/inc/Services/TimeManagementService.hpp @@ -8,7 +8,7 @@ * Implementation of the ST[09] time management. * * @ingroup Services - * @notes + * @note * There is a noticeable difference between setting the time using GPS and setting the time * using space packets from the ground segment. The GPS module sends the actual time of UTC (123519 * is 12:35:19 UTC), while space packets, for time configuration, sends the elapsed time units diff --git a/inc/etl/String.hpp b/inc/etl/String.hpp index 04112ef92d7ab6e6371e8b7e939619a4399c1f2e..7691f78323f636c5741a68b9cb2144e7c362fa86 100644 --- a/inc/etl/String.hpp +++ b/inc/etl/String.hpp @@ -63,7 +63,7 @@ public: * Append a specified number of bytes from a uint8_t array to the String * @details The array does NOT need to be null-terminated * @param data The characters to append - * @param n The number of characters that \ref data contains + * @param n The number of characters that \p data contains * @return This string */ String& append(const uint8_t* data, size_t n) { diff --git a/src/Helpers/TimeAndDate.cpp b/src/Helpers/TimeAndDate.cpp index b531d2274ce3917f79e865fd63d20c7e5d85c602..54a17b6b17f0ca2838f741222858fc97777f25ae 100644 --- a/src/Helpers/TimeAndDate.cpp +++ b/src/Helpers/TimeAndDate.cpp @@ -15,8 +15,9 @@ TimeAndDate::TimeAndDate(uint16_t year, uint8_t month, uint8_t day, uint8_t hour ASSERT_INTERNAL(2019 <= year, ErrorHandler::InternalErrorType::InvalidDate); ASSERT_INTERNAL((1 <= month) && (month <= 12), ErrorHandler::InternalErrorType::InvalidDate); ASSERT_INTERNAL((1 <= day) && (day <= 31), ErrorHandler::InternalErrorType::InvalidDate); - ASSERT_INTERNAL(hour <= 24, ErrorHandler::InternalErrorType::InvalidDate); - ASSERT_INTERNAL(minute <= 60, ErrorHandler::InternalErrorType::InvalidDate); + ASSERT_INTERNAL(hour < 24, ErrorHandler::InternalErrorType::InvalidDate); + ASSERT_INTERNAL(minute < 60, ErrorHandler::InternalErrorType::InvalidDate); + // Seconds can be equal to 60, to account for leap seconds. ASSERT_INTERNAL(second <= 60, ErrorHandler::InternalErrorType::InvalidDate); this->year = year; diff --git a/src/Message.cpp b/src/Message.cpp index 7ca102efeec33da97226f4941ab5e2e51b438533..0333117ed92f6dc8b352268f94ff98d51eae9d14 100644 --- a/src/Message.cpp +++ b/src/Message.cpp @@ -168,9 +168,9 @@ void Message::appendMessage(const Message& message, uint16_t size) { } void Message::appendString(const etl::istring& string) { - ASSERT_INTERNAL(dataSize + string.size() < ECSS_MAX_MESSAGE_SIZE, ErrorHandler::MessageTooLarge); + ASSERT_INTERNAL(dataSize + string.size() <= ECSS_MAX_MESSAGE_SIZE, ErrorHandler::MessageTooLarge); // TODO: Do we need to keep this check? How does etl::string handle it? - ASSERT_INTERNAL(string.size() < string.capacity(), ErrorHandler::StringTooLarge); + ASSERT_INTERNAL(string.size() <= string.capacity(), ErrorHandler::StringTooLarge); memcpy(data + dataSize, string.data(), string.size()); diff --git a/src/MessageParser.cpp b/src/MessageParser.cpp index de6ba7571e603703117c355c978b1890ad29cc04..6b63975256d479c6d70a7cb3e60bc9c97d71da09 100644 --- a/src/MessageParser.cpp +++ b/src/MessageParser.cpp @@ -47,14 +47,14 @@ Message MessageParser::parse(uint8_t* data, uint32_t length) { // Individual fields of the CCSDS Space Packet primary header uint8_t versionNumber = data[0] >> 5; Message::PacketType packetType = ((data[0] & 0x10) == 0) ? Message::TM : Message::TC; - uint8_t secondaryHeaderFlag = data[0] & static_cast<uint8_t>(0x08); + bool secondaryHeaderFlag = (data[0] & 0x08u) != 0U; uint16_t APID = packetHeaderIdentification & static_cast<uint16_t>(0x07ff); auto sequenceFlags = static_cast<uint8_t>(packetSequenceControl >> 14); uint16_t packetSequenceCount = packetSequenceControl & (~ 0xc000u); // keep last 14 bits // Returning an internal error, since the Message is not available yet ASSERT_INTERNAL(versionNumber == 0U, ErrorHandler::UnacceptablePacket); - ASSERT_INTERNAL(secondaryHeaderFlag == 1U, ErrorHandler::UnacceptablePacket); + ASSERT_INTERNAL(secondaryHeaderFlag, ErrorHandler::UnacceptablePacket); ASSERT_INTERNAL(sequenceFlags == 0x3U, ErrorHandler::UnacceptablePacket); ASSERT_INTERNAL(packetDataLength == (length - 6U), ErrorHandler::UnacceptablePacket); @@ -78,7 +78,7 @@ void MessageParser::parseECSSTCHeader(const uint8_t* data, uint16_t length, Mess uint8_t serviceType = data[1]; uint8_t messageType = data[2]; - ErrorHandler::assertRequest(pusVersion == 2U, message, ErrorHandler::UnacceptableMessage); + ErrorHandler::assertRequest(pusVersion == 2u, message, ErrorHandler::UnacceptableMessage); // Remove the length of the header length -= 5; @@ -108,18 +108,19 @@ Message MessageParser::parseECSSTC(uint8_t* data) { String<CCSDS_MAX_MESSAGE_SIZE> MessageParser::composeECSS(const Message& message, uint16_t size) { uint8_t header[5]; - header[0] = ECSS_PUS_VERSION << 4u; // Assign the pusVersion = 2 - header[1] = message.serviceType; - header[2] = message.messageType; + if (message.packetType == Message::TC) { - header[0] = ECSS_PUS_VERSION << 4U; // Assign the pusVersion = 2 + header[0] = ECSS_PUS_VERSION << 4u; // Assign the pusVersion = 2 header[1] = message.serviceType; header[2] = message.messageType; header[3] = 0; header[4] = 0; } else { - header[3] = static_cast<uint8_t>(message.messageTypeCounter >> 8U); - header[4] = static_cast<uint8_t>(message.messageTypeCounter & 0xffU); + header[0] = ECSS_PUS_VERSION << 4u; // Assign the pusVersion = 2 + header[1] = message.serviceType; + header[2] = message.messageType; + header[3] = static_cast<uint8_t>(message.messageTypeCounter >> 8u); + header[4] = static_cast<uint8_t>(message.messageTypeCounter & 0xffu); } String<CCSDS_MAX_MESSAGE_SIZE> dataString(header, 5); diff --git a/src/Services/EventReportService.cpp b/src/Services/EventReportService.cpp index baf2ba484347c417a6400cbf73f990baee8798bc..c805a5fcdfdbb5784ffe7af5e5745f75a706ec55 100644 --- a/src/Services/EventReportService.cpp +++ b/src/Services/EventReportService.cpp @@ -6,7 +6,7 @@ * @todo: Add message type in TCs * @todo: this code is error prone, depending on parameters given, add fail safes (probably?) */ -void EventReportService::informativeEventReport(Event eventID, const String<64>& data) { +void EventReportService::informativeEventReport(Event eventID, const String<ECSS_EVENT_DATA_AUXILIARY_MAX_SIZE>& data) { // TM[5,1] if (stateOfEvents[static_cast<uint16_t>(eventID)]) { Message report = createTM(1); @@ -19,7 +19,8 @@ void EventReportService::informativeEventReport(Event eventID, const String<64>& } } -void EventReportService::lowSeverityAnomalyReport(Event eventID, const String<64>& data) { +void +EventReportService::lowSeverityAnomalyReport(Event eventID, const String<ECSS_EVENT_DATA_AUXILIARY_MAX_SIZE>& data) { lowSeverityEventCount++; // TM[5,2] if (stateOfEvents[static_cast<uint16_t>(eventID)]) { @@ -35,7 +36,8 @@ void EventReportService::lowSeverityAnomalyReport(Event eventID, const String<64 } } -void EventReportService::mediumSeverityAnomalyReport(Event eventID, const String<64>& data) { +void +EventReportService::mediumSeverityAnomalyReport(Event eventID, const String<ECSS_EVENT_DATA_AUXILIARY_MAX_SIZE>& data) { mediumSeverityEventCount++; // TM[5,3] if (stateOfEvents[static_cast<uint16_t>(eventID)]) { @@ -51,7 +53,8 @@ void EventReportService::mediumSeverityAnomalyReport(Event eventID, const String } } -void EventReportService::highSeverityAnomalyReport(Event eventID, const String<64>& data) { +void +EventReportService::highSeverityAnomalyReport(Event eventID, const String<ECSS_EVENT_DATA_AUXILIARY_MAX_SIZE>& data) { highSeverityEventCount++; // TM[5,4] if (stateOfEvents[static_cast<uint16_t>(eventID)]) { diff --git a/src/Services/RequestVerificationService.cpp b/src/Services/RequestVerificationService.cpp index fdab0b0cc3f85a808ef84cc1db546b7c17ff5537..e298a18276441c4a2792afcbb313ad89034026ac 100644 --- a/src/Services/RequestVerificationService.cpp +++ b/src/Services/RequestVerificationService.cpp @@ -7,10 +7,10 @@ void RequestVerificationService::successAcceptanceVerification(const Message& re 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.appendBits(1, 1); // secondary header flag 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.appendBits(14, request.packetSequenceCount); // packet sequence count storeMessage(report); } @@ -23,10 +23,10 @@ void RequestVerificationService::failAcceptanceVerification(const Message& reque 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.appendBits(1, 1); // secondary header flag 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.appendBits(14, request.packetSequenceCount); // packet sequence count report.appendEnum16(errorCode); // error code storeMessage(report); @@ -39,10 +39,10 @@ void RequestVerificationService::successStartExecutionVerification(const Message 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.appendBits(1, 1); // secondary header flag report.appendEnumerated(11, request.applicationId); // application process ID report.appendEnumerated(2, ECSS_SEQUENCE_FLAGS); // sequence flags - report.appendBits(14, 0); // packet sequence count + report.appendBits(14, request.packetSequenceCount); // packet sequence count storeMessage(report); } @@ -55,10 +55,10 @@ void RequestVerificationService::failStartExecutionVerification(const Message& r 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.appendBits(1, 1); // secondary header flag 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.appendBits(14, request.packetSequenceCount); // packet sequence count report.appendEnum16(errorCode); // error code storeMessage(report); @@ -71,10 +71,10 @@ void RequestVerificationService::successProgressExecutionVerification(const Mess 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.appendBits(1, 1); // secondary header flag 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.appendBits(14, request.packetSequenceCount); // packet sequence count report.appendByte(stepID); // step ID storeMessage(report); @@ -89,10 +89,10 @@ void RequestVerificationService::failProgressExecutionVerification(const Message 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.appendBits(1, 1); // secondary header flag 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.appendBits(14, request.packetSequenceCount); // packet sequence count report.appendByte(stepID); // step ID report.appendEnum16(errorCode); // error code @@ -106,10 +106,10 @@ void RequestVerificationService::successCompletionExecutionVerification(const Me 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.appendBits(1, 1); // secondary header flag 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.appendBits(14, request.packetSequenceCount); // packet sequence count storeMessage(report); } @@ -122,10 +122,10 @@ void RequestVerificationService::failCompletionExecutionVerification( 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.appendBits(1, 1); // secondary header flag 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.appendBits(14, request.packetSequenceCount); // packet sequence count report.appendEnum16(errorCode); // error code storeMessage(report); @@ -139,10 +139,10 @@ void RequestVerificationService::failRoutingVerification(const Message& request, 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.appendBits(1, 1); // secondary header flag 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.appendBits(14, request.packetSequenceCount); // packet sequence count report.appendEnum16(errorCode); // error code storeMessage(report); diff --git a/test/ErrorHandler.cpp b/test/ErrorHandler.cpp index c0dc1393a8a513b024a8a2ea597feda54bcd0b71..804657b3d95151ab4f2be4cdd98293d08df614e1 100644 --- a/test/ErrorHandler.cpp +++ b/test/ErrorHandler.cpp @@ -7,6 +7,7 @@ TEST_CASE("Error: Failed Acceptance", "[errors]") { ErrorHandler::reportError(failedMessage, ErrorHandler::MessageTooShort); REQUIRE(ServiceTests::hasOneMessage()); + CHECK(ServiceTests::thrownError(ErrorHandler::MessageTooShort)); Message report = ServiceTests::get(0); // Check that a TM[1,2] message was returned @@ -17,7 +18,7 @@ TEST_CASE("Error: Failed Acceptance", "[errors]") { CHECK(report.readBits(3) == CCSDS_PACKET_VERSION); CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); - CHECK(report.readBits(1) == 0); + CHECK(report.readBits(1) == 1); CHECK(report.readBits(11) == 47); CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); CHECK(report.readBits(14) == failedMessage.packetSequenceCount); @@ -29,6 +30,7 @@ TEST_CASE("Error: Failed Execution Start", "[errors]") { ErrorHandler::reportError(failedMessage, ErrorHandler::UnknownExecutionStartError); REQUIRE(ServiceTests::hasOneMessage()); + CHECK(ServiceTests::thrownError(ErrorHandler::UnknownExecutionStartError)); Message report = ServiceTests::get(0); // Check that a TM[1,3] message was returned @@ -39,7 +41,7 @@ TEST_CASE("Error: Failed Execution Start", "[errors]") { CHECK(report.readBits(3) == CCSDS_PACKET_VERSION); CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); - CHECK(report.readBits(1) == 0); + CHECK(report.readBits(1) == 1); CHECK(report.readBits(11) == 56); CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); CHECK(report.readBits(14) == failedMessage.packetSequenceCount); @@ -51,6 +53,7 @@ TEST_CASE("Error: Failed Execution Progress", "[errors]") { ErrorHandler::reportProgressError(failedMessage, ErrorHandler::UnknownExecutionProgressError, 0); REQUIRE(ServiceTests::hasOneMessage()); + CHECK(ServiceTests::thrownError(ErrorHandler::UnknownExecutionProgressError)); Message report = ServiceTests::get(0); // Check that a TM[1,6] message was returned @@ -61,7 +64,7 @@ TEST_CASE("Error: Failed Execution Progress", "[errors]") { CHECK(report.readBits(3) == CCSDS_PACKET_VERSION); CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); - CHECK(report.readBits(1) == 0); + CHECK(report.readBits(1) == 1); CHECK(report.readBits(11) == 56); CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); CHECK(report.readBits(14) == failedMessage.packetSequenceCount); @@ -74,6 +77,7 @@ TEST_CASE("Error: Failed Execution Completion", "[errors]") { ErrorHandler::reportError(failedMessage, ErrorHandler::UnknownExecutionCompletionError); REQUIRE(ServiceTests::hasOneMessage()); + CHECK(ServiceTests::thrownError(ErrorHandler::UnknownExecutionCompletionError)); Message report = ServiceTests::get(0); // Check that a TM[1,8] message was returned @@ -84,7 +88,7 @@ TEST_CASE("Error: Failed Execution Completion", "[errors]") { CHECK(report.readBits(3) == CCSDS_PACKET_VERSION); CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); - CHECK(report.readBits(1) == 0); + CHECK(report.readBits(1) == 1); CHECK(report.readBits(11) == 56); CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); CHECK(report.readBits(14) == failedMessage.packetSequenceCount); @@ -96,6 +100,7 @@ TEST_CASE("Error: Failed Routing", "[errors]") { ErrorHandler::reportError(failedMessage, ErrorHandler::UnknownRoutingError); REQUIRE(ServiceTests::hasOneMessage()); + CHECK(ServiceTests::thrownError(ErrorHandler::UnknownRoutingError)); Message report = ServiceTests::get(0); // Check that a TM[1,8] message was returned @@ -106,7 +111,7 @@ TEST_CASE("Error: Failed Routing", "[errors]") { CHECK(report.readBits(3) == CCSDS_PACKET_VERSION); CHECK(report.readBits(1) == static_cast<uint16_t>(Message::TC)); - CHECK(report.readBits(1) == 0); + CHECK(report.readBits(1) == 1); CHECK(report.readBits(11) == 71); CHECK(report.readBits(2) == ECSS_SEQUENCE_FLAGS); CHECK(report.readBits(14) == failedMessage.packetSequenceCount); diff --git a/test/Helpers/TimeAndDate.cpp b/test/Helpers/TimeAndDate.cpp index f5bc35fe51a660fe403847e65eda1b1c21d4b9b3..13866f29ebff1432aa88562fdb7f4020690fc37a 100644 --- a/test/Helpers/TimeAndDate.cpp +++ b/test/Helpers/TimeAndDate.cpp @@ -1,5 +1,6 @@ #include "catch2/catch.hpp" #include "Helpers/TimeAndDate.hpp" +#include "../Services/ServiceTests.hpp" TEST_CASE("Date comparison", "[operands]") { SECTION("Invalid date") { @@ -9,6 +10,9 @@ TEST_CASE("Date comparison", "[operands]") { TimeAndDate InvalidDate3(2030, 2, 2, 74, 5, 6); // error in hour TimeAndDate InvalidDate4(2030, 2, 2, 4, 75, 6); // error in minute TimeAndDate InvalidDate5(2030, 2, 2, 4, 5, 76); // error in seconds + + CHECK(ServiceTests::countErrors() == 6); + CHECK(ServiceTests::thrownError(ErrorHandler::InvalidDate)); } SECTION("Different year") { diff --git a/test/Helpers/TimeHelper.cpp b/test/Helpers/TimeHelper.cpp index 00577f65203e1260d1d210e50df4b0f1c71ba4e2..cca057be3459f519e781c4c758d53483e4a1d32b 100644 --- a/test/Helpers/TimeHelper.cpp +++ b/test/Helpers/TimeHelper.cpp @@ -1,5 +1,6 @@ #include "catch2/catch.hpp" #include "Helpers/TimeHelper.hpp" +#include "../Services/ServiceTests.hpp" TEST_CASE("Time format implementation for CDS", "[CDS]") { SECTION("Invalid date") { @@ -16,7 +17,7 @@ TEST_CASE("Time format implementation for CDS", "[CDS]") { TimeHelper::utcToSeconds(TimeInfo); // invalid month - TimeInfo.year = 2018; + TimeInfo.year = 2019; TimeInfo.month = 60; TimeInfo.day = 10; TimeInfo.hour = 10; @@ -26,7 +27,7 @@ TEST_CASE("Time format implementation for CDS", "[CDS]") { TimeHelper::utcToSeconds(TimeInfo); // invalid day - TimeInfo.year = 2018; + TimeInfo.year = 2019; TimeInfo.month = 4; TimeInfo.day = 35; TimeInfo.hour = 10; @@ -36,7 +37,7 @@ TEST_CASE("Time format implementation for CDS", "[CDS]") { TimeHelper::utcToSeconds(TimeInfo); // invalid hour - TimeInfo.year = 2018; + TimeInfo.year = 2019; TimeInfo.month = 4; TimeInfo.day = 10; TimeInfo.hour = 100; @@ -46,7 +47,7 @@ TEST_CASE("Time format implementation for CDS", "[CDS]") { TimeHelper::utcToSeconds(TimeInfo); // invalid minute - TimeInfo.year = 2018; + TimeInfo.year = 2019; TimeInfo.month = 4; TimeInfo.day = 10; TimeInfo.hour = 10; @@ -56,7 +57,7 @@ TEST_CASE("Time format implementation for CDS", "[CDS]") { TimeHelper::utcToSeconds(TimeInfo); // invalid second - TimeInfo.year = 2018; + TimeInfo.year = 2019; TimeInfo.month = 4; TimeInfo.day = 10; TimeInfo.hour = 10; @@ -64,6 +65,9 @@ TEST_CASE("Time format implementation for CDS", "[CDS]") { TimeInfo.second = 122; TimeHelper::utcToSeconds(TimeInfo); + + CHECK(ServiceTests::countErrors() == 6); + CHECK(ServiceTests::thrownError(ErrorHandler::InvalidDate)); } SECTION("Convert UTC date to elapsed seconds since Unix epoch") { diff --git a/test/Services/FunctionManagementService.cpp b/test/Services/FunctionManagementService.cpp index 92cd24c43ffc42081861749f5b7de31b0970700a..a4893a1a7561c2deb783ba8a12e46779c4a2d127 100644 --- a/test/Services/FunctionManagementService.cpp +++ b/test/Services/FunctionManagementService.cpp @@ -56,7 +56,7 @@ TEST_CASE("ST[08] - Call Tests") { CHECK(ServiceTests::get(0).messageType == 4); CHECK(ServiceTests::get(0).serviceType == 1); - CHECK(ServiceTests::countErrors() == 2); + CHECK(ServiceTests::countErrors() == 1); CHECK(globalVariable == 10); } } diff --git a/test/Services/ParameterService.cpp b/test/Services/ParameterService.cpp index d21f32bd200f27e3334d9d40de88f945468a7edf..6153f6c5d57f69b32bbfdc1bb1410c040d0f8a7d 100644 --- a/test/Services/ParameterService.cpp +++ b/test/Services/ParameterService.cpp @@ -25,6 +25,9 @@ TEST_CASE("Parameter Report Subservice") { CHECK_FALSE(report.readUint16() == 34672); // fail if faulty ID is present in report report.readUint32(); // ignore the carried settings } + + CHECK(ServiceTests::countErrors() == 1); + CHECK(ServiceTests::thrownError(ErrorHandler::UnknownExecutionStartError)); } // **WARNING** @@ -93,5 +96,8 @@ TEST_CASE("Parameter Setting Subservice") { CHECK(before.readUint16() == after.readUint16()); // check if all IDs are present CHECK_FALSE(after.readUint32() == 0xBAAAAAAD); // fail if any settings are BAAAAAAD :P } + + CHECK(ServiceTests::countErrors() == 3); + CHECK(ServiceTests::thrownError(ErrorHandler::UnknownExecutionStartError)); } } diff --git a/test/Services/RequestVerificationService.cpp b/test/Services/RequestVerificationService.cpp index 6576bdbaa5b2183432e747a1a76b25788f646fda..df0ea7e26c31c971b940c391f453d9908fa15696 100644 --- a/test/Services/RequestVerificationService.cpp +++ b/test/Services/RequestVerificationService.cpp @@ -20,7 +20,7 @@ TEST_CASE("TM[1,1]", "[service][st01]") { // 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.readBits(1) == 1); // 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 @@ -41,7 +41,7 @@ TEST_CASE("TM[1,2]", "[service][st01]") { // 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.readBits(1) == 1); // 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 @@ -63,7 +63,7 @@ TEST_CASE("TM[1,3]", "[service][st01]") { // 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.readBits(1) == 1); // 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 @@ -84,7 +84,7 @@ TEST_CASE("TM[1,4]", "[service][st01]") { // 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.readBits(1) == 1); // 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 @@ -106,7 +106,7 @@ TEST_CASE("TM[1,5]", "[service][st01]") { // 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.readBits(1) == 1); // 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 @@ -128,7 +128,7 @@ TEST_CASE("TM[1,6]", "[service][st01]") { // 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.readBits(1) == 1); // 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 @@ -151,7 +151,7 @@ TEST_CASE("TM[1,7]", "[service][st01]") { // 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.readBits(1) == 1); // 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 @@ -171,7 +171,7 @@ TEST_CASE("TM[1,8]", "[service][st01]") { // 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.readBits(1) == 1); // 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 @@ -193,7 +193,7 @@ TEST_CASE("TM[1,10]", "[service][st01]") { // 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.readBits(1) == 1); // 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 diff --git a/test/TestPlatform.cpp b/test/TestPlatform.cpp index beb76de1e0fb393521b3a22fe915de5c1c68f241..6833d3edeb9222d5d106f0ddf5dcac0e4f7ad5a7 100644 --- a/test/TestPlatform.cpp +++ b/test/TestPlatform.cpp @@ -48,8 +48,7 @@ struct ServiceTestsListener : Catch::TestEventListenerBase { // An Error was thrown with this Message. If you expected this to happen, please call a // corresponding assertion function from ServiceTests to silence this message. - // TODO: Uncomment the following line as soon as Issue #19 is closed - // CHECK(ServiceTests::hasNoErrors()); + CHECK(ServiceTests::hasNoErrors()); } }