From 9bbcd78c73fea857ebef0bcc3486dd07e4876847 Mon Sep 17 00:00:00 2001 From: kongr45gpen <electrovesta@gmail.com> Date: Sat, 10 Aug 2019 00:55:12 +0300 Subject: [PATCH] Add Message::appendMessage() function --- inc/Message.hpp | 11 +++++++++++ src/Message.cpp | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/inc/Message.hpp b/inc/Message.hpp index 3430c38e..93821cbe 100644 --- a/inc/Message.hpp +++ b/inc/Message.hpp @@ -367,6 +367,17 @@ public: appendString(string); } + /** + * Adds a nested TC or TM Message within the current Message + * + * As a design decision, nested TC & TM Messages always have a fixed width, specified in \ref ECSSDefinitions. This + * reduces the uncertainty and complexity of having to parse the nested Message itself to see how long it is, at + * the cost of more data to be transmitted. + * @param message The message to append + * @param size The fixed number of bytes that the message will take up. The empty last bytes are padded with 0s. + */ + void appendMessage(const Message & message, uint16_t size); + /** * Fetches a single-byte boolean value from the current position in the message * diff --git a/src/Message.cpp b/src/Message.cpp index 55e9d49d..e96eacaa 100644 --- a/src/Message.cpp +++ b/src/Message.cpp @@ -3,6 +3,7 @@ #include <cstring> #include <ErrorHandler.hpp> #include <ServicePool.hpp> +#include <MessageParser.hpp> Message::Message(uint8_t serviceType, uint8_t messageType, Message::PacketType packetType, uint16_t applicationId) : serviceType(serviceType), messageType(messageType), packetType(packetType), applicationId(applicationId) {} @@ -161,3 +162,7 @@ void Message::resetRead() { readPosition = 0; currentBit = 0; } + +void Message::appendMessage(const Message& message, uint16_t size) { + appendString(MessageParser::composeECSS(message, size)); +} -- GitLab