From 210fc7f6cd20ce5575a477b64c2648b348fc6e43 Mon Sep 17 00:00:00 2001
From: Grigoris Pavlakis <grigpavl@ece.auth.gr>
Date: Sun, 25 Nov 2018 00:48:12 +0200
Subject: [PATCH] Update ParameterService source and test to use resetRead()
 instead of the hackier msg.readPosition = 0 and fix some formatting

---
 inc/Services/ParameterService.hpp  | 2 +-
 src/Services/ParameterService.cpp  | 6 +++---
 test/Services/ParameterService.cpp | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/inc/Services/ParameterService.hpp b/inc/Services/ParameterService.hpp
index f0761bea..43987f7c 100644
--- a/inc/Services/ParameterService.hpp
+++ b/inc/Services/ParameterService.hpp
@@ -31,7 +31,7 @@ struct Parameter {
 };
 
 /**
- * Parameter manager
+ * Parameter manager - ST[20]
  * Holds the list with the parameters and provides functions
  * for parameter reporting and modification.
  *
diff --git a/src/Services/ParameterService.cpp b/src/Services/ParameterService.cpp
index 4fa0e1b2..3329d685 100644
--- a/src/Services/ParameterService.cpp
+++ b/src/Services/ParameterService.cpp
@@ -73,7 +73,7 @@ Message ParameterService::reportParameterIds(Message paramIds) {
 				reqParam.appendUint32(paramsList[currId].settingData);
 			} else {
 
-				// generate failure of execution notification for ST[06]
+								// generate failure of execution notification for ST[06]
 				continue;       //ignore the invalid ID
 			}
 		}
@@ -110,7 +110,7 @@ void ParameterService::setParameterIds(Message newParamValues) {
 				paramsList[currId].settingData = newParamValues.readUint32();
 			} else {
 
-				// generate failure of execution notification for ST[06]
+								// generate failure of execution notification for ST[06]
 				continue;       // ignore the invalid ID
 			}
 		}
@@ -119,7 +119,7 @@ void ParameterService::setParameterIds(Message newParamValues) {
 
 uint16_t ParameterService::numOfValidIds(Message idMsg) {
 
-	idMsg.readPosition = 0;
+	idMsg.resetRead();
 	// start reading from the beginning of the idMsg object
 	// (original obj. will not be influenced if this is called by value)
 
diff --git a/test/Services/ParameterService.cpp b/test/Services/ParameterService.cpp
index c87cd773..43038dbe 100644
--- a/test/Services/ParameterService.cpp
+++ b/test/Services/ParameterService.cpp
@@ -20,7 +20,7 @@ TEST_CASE("Parameter Report Subservice") {
 		request.appendUint16(3);      // valid
 
 		report = pserv.reportParameterIds(request);
-		request.readPosition = 0;
+		request.resetRead();
 
 		uint16_t repIdCount = report.readUint16();
 		uint16_t reqIdCount = request.readUint16();
-- 
GitLab