From f0a27df53ae6f16c9aeb80380b9d3caf8c3d0b0e Mon Sep 17 00:00:00 2001 From: Theodoros Katzalis <thodkatz@gmail.com> Date: Thu, 21 Mar 2019 00:59:14 +0200 Subject: [PATCH] Change the parameter of the storeMessage, add tests for the spare field and small changes in the documentation Formatting Remove an unnecessary assertion and assign the currentBit --- inc/Message.hpp | 2 -- inc/Service.hpp | 11 ++++++----- src/Message.cpp | 3 ++- src/Platform/x86/Service.cpp | 2 +- test/TestPlatform.cpp | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/inc/Message.hpp b/inc/Message.hpp index 2e69b57b..c6ee5006 100644 --- a/inc/Message.hpp +++ b/inc/Message.hpp @@ -72,8 +72,6 @@ public: void appendBits(uint8_t numBits, uint16_t data); /** - * Define the spare field in telemetry and telecommand user data field (7.4.3.2.c and 7.4.4.2.c) - * * Appends the remaining bits to complete a byte, in case the appendBits() is the last call * and the packet data field isn't integer multiple of bytes * diff --git a/inc/Service.hpp b/inc/Service.hpp index 09937508..fbd1aff8 100644 --- a/inc/Service.hpp +++ b/inc/Service.hpp @@ -44,7 +44,7 @@ protected: * Note: For now, since we don't have any mechanisms to queue messages and send them later, * we just print the message to the screen */ - void storeMessage(const Message &message); + void storeMessage(Message &message); /** * This function declared only to remind us that every service must have a function like @@ -56,20 +56,21 @@ protected: * Default protected constructor for this Service */ Service() = default; + public: /** * @brief Unimplemented copy constructor * * Does not allow Services should be copied. There should be only one instance for each Service. */ - Service (Service const&) = delete; + Service(Service const &) = delete; /** * Unimplemented assignment operation * * Does not allow changing the instances of Services, as Services are singletons. */ - void operator=(Service const&) = delete; + void operator=(Service const &) = delete; /** * Default destructor @@ -79,12 +80,12 @@ public: /** * Default move constructor */ - Service(Service && service) noexcept = default; + Service(Service &&service) noexcept = default; /** * Default move assignment operator */ - Service & operator=(Service && service) noexcept = default; + Service &operator=(Service &&service) noexcept = default; }; diff --git a/src/Message.cpp b/src/Message.cpp index 8ee7e181..e6b6834b 100644 --- a/src/Message.cpp +++ b/src/Message.cpp @@ -37,9 +37,10 @@ void Message::appendBits(uint8_t numBits, uint16_t data) { } void Message::finalize() { - assertI(dataSize < ECSS_MAX_MESSAGE_SIZE, ErrorHandler::MessageTooLarge); + // Define the spare field in telemetry and telecommand user data field (7.4.3.2.c and 7.4.4.2.c) if (currentBit != 0) { + currentBit = 0; dataSize++; } } diff --git a/src/Platform/x86/Service.cpp b/src/Platform/x86/Service.cpp index b148c242..6a251f27 100644 --- a/src/Platform/x86/Service.cpp +++ b/src/Platform/x86/Service.cpp @@ -2,7 +2,7 @@ #include <iomanip> #include "Service.hpp" -void Service::storeMessage(Message & message) { +void Service::storeMessage(Message &message) { // appends the remaining bits to complete a byte message.finalize(); diff --git a/test/TestPlatform.cpp b/test/TestPlatform.cpp index 0880d64e..f6297918 100644 --- a/test/TestPlatform.cpp +++ b/test/TestPlatform.cpp @@ -19,7 +19,7 @@ std::multimap<std::pair<ErrorHandler::ErrorSource, uint16_t>, bool> ServiceTests std::multimap<std::pair<ErrorHandler::ErrorSource, uint16_t>, bool>(); bool ServiceTests::expectingErrors = false; -void Service::storeMessage(const Message &message) { +void Service::storeMessage(Message &message) { // Just add the message to the queue ServiceTests::queue(message); } -- GitLab