From 65c3610773dd879d6d6fbf437b3c999fef565eac Mon Sep 17 00:00:00 2001
From: thodkatz <thodkatz@gmail.com>
Date: Mon, 19 Nov 2018 07:52:21 +0200
Subject: [PATCH] Implement code review comments

---
 inc/Services/RequestVerificationService.hpp | 22 +++---
 src/Services/RequestVerificationService.cpp | 82 ++++++++++-----------
 src/main.cpp                                |  3 +-
 3 files changed, 53 insertions(+), 54 deletions(-)

diff --git a/inc/Services/RequestVerificationService.hpp b/inc/Services/RequestVerificationService.hpp
index 8584e188..e6b5e812 100644
--- a/inc/Services/RequestVerificationService.hpp
+++ b/inc/Services/RequestVerificationService.hpp
@@ -1,5 +1,5 @@
-#ifndef ECSS_SERVICES_REQUSTVERIFICATIONSERVICE_HPP
-#define ECSS_SERVICES_REQUSTVERIFICATIONSERVICE_HPP
+#ifndef ECSS_SERVICES_REQEUSTVERIFICATIONSERVICE_HPP
+#define ECSS_SERVICES_REQUESTVERIFICATIONSERVICE_HPP
 
 #include "Service.hpp"
 
@@ -18,39 +18,39 @@ public:
 	 * TM[1,1] successful acceptance verification report
 	 */
 	void successAcceptanceVerification(uint8_t packetType, bool secondaryHeaderFlag,
-	                                   uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount);
+	                                   uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount);
 
 	/**
 	 * TM[1,2] failed acceptance verification report
 	 */
 	void failAcceptanceVerification(uint8_t packetType, bool secondaryHeaderFlag,
-	                                uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount,
-	                                uint16_t code);
+	                                uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount,
+	                                uint16_t errorCode);
 
 
 	/**
  	*  TM[1,7] successful completion of execution verification report
  	*/
 	void successExecutionVerification(uint8_t packetType, bool secondaryHeaderFlag,
-	                                  uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount);
+	                                  uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount);
 
 	/**
  	*  TM[1,8] failed completion of execution verification report
  	*/
 	void failExecutionVerification(uint8_t packetType,
 	                               bool secondaryHeaderFlag,
-	                               uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount,
-	                               uint16_t code);
+	                               uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount,
+	                               uint16_t errorCode);
 
 	/**
  	*  TM[1,10] failed routing verification report
  	*/
 	void failRoutingVerification(uint8_t packetType,
 	                             bool secondaryHeaderFlag,
-	                             uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount,
-	                             uint16_t code);
+	                             uint16_t apid, uint8_t seqFlag, uint16_t packetSeqCount,
+	                             uint16_t errorCode);
 
 
 };
 
-#endif //ECSS_SERVICES_REQUSTVERIFICATIONSERVICE_HPP
+#endif //ECSS_SERVICES_REQUESTVERIFICATIONSERVICE_HPP
diff --git a/src/Services/RequestVerificationService.cpp b/src/Services/RequestVerificationService.cpp
index 5c0e4136..0416fd1f 100644
--- a/src/Services/RequestVerificationService.cpp
+++ b/src/Services/RequestVerificationService.cpp
@@ -2,20 +2,20 @@
 
 void RequestVerificationService::successAcceptanceVerification(uint8_t packetType,
                                                                bool secondaryHeaderFlag,
-                                                               uint16_t APID, uint8_t seqFlag,
+                                                               uint16_t apid, uint8_t seqFlag,
                                                                uint16_t packetSeqCount) {
 	// TM[1,1] successful acceptance verification report
-	assert(packetType <= 1);
-	assert(APID <= 1024);
-	assert(seqFlag <= 2);
-	assert(packetSeqCount <= 8192);
+	assert(packetType < 2);
+	assert(apid < 2048);
+	assert(seqFlag < 4);
+	assert(packetSeqCount < 16384);
 
 	Message report = createTM(1);
 
-	report.appendBits(3, ECSS_PUS_VERSION); //packet version number
+	report.appendBits(3, ECSS_PUS_VERSION); // packet version number
 	report.appendBits(1, packetType);
 	report.appendBits(1, static_cast<uint16_t >(secondaryHeaderFlag));
-	report.appendBits(11, APID);
+	report.appendBits(11, apid);
 	report.appendBits(2, seqFlag);
 	report.appendBits(14, packetSeqCount);
 
@@ -25,45 +25,45 @@ void RequestVerificationService::successAcceptanceVerification(uint8_t packetTyp
 void
 RequestVerificationService::failAcceptanceVerification(uint8_t packetType,
                                                        bool secondaryHeaderFlag,
-                                                       uint16_t APID, uint8_t seqFlag,
+                                                       uint16_t apid, uint8_t seqFlag,
                                                        uint16_t packetSeqCount,
-                                                       uint16_t code) {
+                                                       uint16_t errorCode) {
 	// TM[1,2] failed acceptance verification report
-	assert(packetType <= 1);
-	assert(APID <= 1024);
-	assert(seqFlag <= 2);
-	assert(packetSeqCount <= 8192);
+	assert(packetType < 2);
+	assert(apid < 2048);
+	assert(seqFlag < 4);
+	assert(packetSeqCount < 16384);
 
 	Message report = createTM(2);
 
-	report.appendBits(3, ECSS_PUS_VERSION); //packet version number
+	report.appendBits(3, ECSS_PUS_VERSION); // packet version number
 	report.appendBits(1, packetType);
 	report.appendBits(1, static_cast<uint16_t >(secondaryHeaderFlag));
-	report.appendBits(11, APID);
+	report.appendBits(11, apid);
 	report.appendBits(2, seqFlag);
 	report.appendBits(14, packetSeqCount);
 
-	report.appendUint16(code);
+	report.appendUint16(errorCode);
 
 	storeMessage(report);
 }
 
 void RequestVerificationService::successExecutionVerification(uint8_t packetType,
                                                               bool secondaryHeaderFlag,
-                                                              uint16_t APID, uint8_t seqFlag,
+                                                              uint16_t apid, uint8_t seqFlag,
                                                               uint16_t packetSeqCount) {
 	// TM[1,7] successful completion of execution verification report
-	assert(packetType <= 1);
-	assert(APID <= 1024);
-	assert(seqFlag <= 2);
-	assert(packetSeqCount <= 8192);
+	assert(packetType < 2);
+	assert(apid < 2048);
+	assert(seqFlag < 4);
+	assert(packetSeqCount < 16384);
 
 	Message report = createTM(7);
 
-	report.appendBits(3, ECSS_PUS_VERSION); //packet version number
+	report.appendBits(3, ECSS_PUS_VERSION); // packet version number
 	report.appendBits(1, packetType);
 	report.appendBits(1, static_cast<uint16_t >(secondaryHeaderFlag));
-	report.appendBits(11, APID);
+	report.appendBits(11, apid);
 	report.appendBits(2, seqFlag);
 	report.appendBits(14, packetSeqCount);
 
@@ -73,25 +73,25 @@ void RequestVerificationService::successExecutionVerification(uint8_t packetType
 void
 RequestVerificationService::failExecutionVerification(uint8_t packetType,
                                                       bool secondaryHeaderFlag,
-                                                      uint16_t APID, uint8_t seqFlag,
+                                                      uint16_t apid, uint8_t seqFlag,
                                                       uint16_t packetSeqCount,
-                                                      uint16_t code) {
+                                                      uint16_t errorCode) {
 	// TM[1,8] failed completion of execution verification report
-	assert(packetType <= 1);
-	assert(APID <= 1024);
-	assert(seqFlag <= 2);
-	assert(packetSeqCount <= 8192);
+	assert(packetType < 2);
+	assert(apid < 2048);
+	assert(seqFlag < 4);
+	assert(packetSeqCount < 16384);
 
 	Message report = createTM(8);
 
-	report.appendBits(3, ECSS_PUS_VERSION); //packet version number
+	report.appendBits(3, ECSS_PUS_VERSION); // packet version number
 	report.appendBits(1, packetType);
 	report.appendBits(1, static_cast<uint16_t >(secondaryHeaderFlag));
-	report.appendBits(11, APID);
+	report.appendBits(11, apid);
 	report.appendBits(2, seqFlag);
 	report.appendBits(14, packetSeqCount);
 
-	report.appendUint16(code);
+	report.appendUint16(errorCode);
 
 	storeMessage(report);
 }
@@ -99,25 +99,25 @@ RequestVerificationService::failExecutionVerification(uint8_t packetType,
 void
 RequestVerificationService::failRoutingVerification(uint8_t packetType,
                                                     bool secondaryHeaderFlag,
-                                                    uint16_t APID, uint8_t seqFlag,
+                                                    uint16_t apid, uint8_t seqFlag,
                                                     uint16_t packetSeqCount,
-                                                    uint16_t code) {
+                                                    uint16_t errorCode) {
 	// TM[1,10] failed routing verification report
-	assert(packetType <= 1);
-	assert(APID <= 1024);
-	assert(seqFlag <= 2);
-	assert(packetSeqCount <= 8192);
+	assert(packetType < 2);
+	assert(apid < 2048);
+	assert(seqFlag < 4);
+	assert(packetSeqCount < 16384);
 
 	Message report = createTM(10);
 
-	report.appendBits(3, ECSS_PUS_VERSION); //packet version number
+	report.appendBits(3, ECSS_PUS_VERSION); // packet version number
 	report.appendBits(1, packetType);
 	report.appendBits(1, static_cast<uint16_t >(secondaryHeaderFlag));
-	report.appendBits(11, APID);
+	report.appendBits(11, apid);
 	report.appendBits(2, seqFlag);
 	report.appendBits(14, packetSeqCount);
 
-	report.appendUint16(code);
+	report.appendUint16(errorCode);
 
 	storeMessage(report);
 }
diff --git a/src/main.cpp b/src/main.cpp
index 70d5030d..67362d56 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -20,7 +20,7 @@ int main() {
 	std::cout << "Word: " << string << " " << packet.readBits(15) << packet.readBits(1)
 	          << std::endl;
 	std::cout << packet.readFloat() << " " << std::dec << packet.readSint32() << std::endl;
-	/*
+
 	// ST[17] test
 	TestService testService;
 	Message receivedPacket = Message(17, 1, Message::TC, 1);
@@ -28,7 +28,6 @@ int main() {
 	receivedPacket = Message(17, 3, Message::TC, 1);
 	receivedPacket.appendUint16(7);
 	testService.onBoardConnection(receivedPacket);
-	 */
 
 	// ST[01] test
 	// parameters take random values and works as expected
-- 
GitLab