From d6f4467564f45c1f05ba60c573a4552b9b64bcd4 Mon Sep 17 00:00:00 2001
From: Dimitrios Stoupis <dimitris.apple@gmail.com>
Date: Wed, 21 Nov 2018 09:13:37 +0000
Subject: [PATCH] Added octet and uint64 functions

---
 inc/Message.hpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/inc/Message.hpp b/inc/Message.hpp
index 28ba738b..cd7d27e0 100644
--- a/inc/Message.hpp
+++ b/inc/Message.hpp
@@ -187,6 +187,16 @@ public:
 		return appendWord(value);
 	}
 
+	/**
+	 * Adds an 8 byte unsigned integer to the end of the message
+	 *
+	 * PTC = 3, PFC = 16
+	 */
+	void appendUint64(uint64_t value) {
+		appendWord(static_cast<uint32_t >(value >> 32));
+		return appendWord(static_cast<uint32_t >(value));
+	}
+
 	/**
 	 * Adds a 1 byte signed integer to the end of the message
 	 *
@@ -226,6 +236,20 @@ public:
 		return appendWord(reinterpret_cast<uint32_t &>(value));
 	}
 
+	/**
+	 * Adds a N-byte string to the end of the message
+	 *
+	 *
+	 * PTC = 7, PFC = 0
+	 */
+	void appendOctetString(uint16_t size, uint8_t *byteString) {
+		assert(size < ECSS_MAX_STRING_SIZE);
+
+		for (std::size_t i = 0; i < size; i++) {
+			appendByte(byteString[i]);
+		}
+	}
+
 	/**
 	 * Fetches a single-byte boolean value from the current position in the message
 	 *
@@ -301,6 +325,15 @@ public:
 		return readWord();
 	}
 
+	/**
+	 * Fetches an 8-byte unsigned integer from the current position in the message
+	 *
+	 * PTC = 3, PFC = 16
+	 */
+	uint64_t readUint64() {
+		return ((uint64_t)readWord() << 32) |(uint64_t)readWord();
+	}
+
 	/**
 	 * Fetches an 1-byte signed integer from the current position in the message
 	 *
@@ -347,6 +380,20 @@ public:
 		return reinterpret_cast<float &>(value);
 	}
 
+	/**
+	 * Fetches a N-byte string from the current position in the message
+	 *
+	 *
+	 * PTC = 7, PFC = 0
+	 */
+	 void readOctetString(uint8_t *byteString, uint16_t size) {
+		assert(size < ECSS_MAX_STRING_SIZE);
+
+		for (std::size_t i = 0; i < size; i++) {
+			byteString[i] = readByte();
+		}
+	 }
+
 	/**
 	 * Reset the message reading status, and start reading data from it again
 	 */
-- 
GitLab