From aa39dfa71602ae1fc0aba3bb8ccab6571dd51307 Mon Sep 17 00:00:00 2001
From: kongr45gpen <electrovesta@gmail.com>
Date: Sat, 10 Aug 2019 13:41:13 +0300
Subject: [PATCH] Remove more non-static usages of the MessageParser

Add MessageParser tests

Apply suggestion to src/MessageParser.cpp

Fix documentation typo
---
 inc/etl/String.hpp    | 2 +-
 src/MessageParser.cpp | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/inc/etl/String.hpp b/inc/etl/String.hpp
index c771556a..04112ef9 100644
--- a/inc/etl/String.hpp
+++ b/inc/etl/String.hpp
@@ -60,7 +60,7 @@ public:
 	using etl::istring::append; // Use the append function from the parent
 
     /**
-     * Append a specified with of bytes from a uint8_t array to the String
+     * 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
diff --git a/src/MessageParser.cpp b/src/MessageParser.cpp
index c15dafe4..de6ba757 100644
--- a/src/MessageParser.cpp
+++ b/src/MessageParser.cpp
@@ -108,7 +108,9 @@ 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[1] = message.serviceType;
@@ -116,9 +118,6 @@ String<CCSDS_MAX_MESSAGE_SIZE> MessageParser::composeECSS(const Message& message
 		header[3] = 0;
 		header[4] = 0;
 	} else {
-		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);
 	}
-- 
GitLab