From 754ed22e3ec2637d5107bce2325816fb7fca4ad6 Mon Sep 17 00:00:00 2001
From: "ucart@co3050-12" <dawehr@iastate.edu>
Date: Sat, 28 Jan 2017 15:09:11 -0600
Subject: [PATCH] Added the IDs for the valuetypes and PID constants to
 commands.c/h also added some more comments in both files

---
 groundStation/src/backend/commands.c | 12 ++++-
 groundStation/src/backend/commands.h | 68 +++++++++++++++++++++-------
 2 files changed, 61 insertions(+), 19 deletions(-)

diff --git a/groundStation/src/backend/commands.c b/groundStation/src/backend/commands.c
index 36f42bcd4..59c09ca4c 100644
--- a/groundStation/src/backend/commands.c
+++ b/groundStation/src/backend/commands.c
@@ -37,7 +37,8 @@
  *
  */
 
-/* List of callbacks. DO NOT MODIFY THESE IN THIS FILE - 
+/*
+ * List of callbacks. DO NOT MODIFY THESE IN THIS FILE -
  * Simply implement a function with the same name
  * in a different file (callbacks.c) and these will
  * be overridden.
@@ -60,7 +61,14 @@ command_cb cb_setval __attribute__((weak, alias("cb_default")));
 command_cb cb_getval __attribute__((weak, alias("cb_default")));
 command_cb cb_respval __attribute__((weak, alias("cb_default")));
 
-/* Command structure */
+/*
+ * Command structure.
+ * This array is used to keep track of the callback functions
+ * for commands between the quad and the ground station.
+ *
+ * There is one callback function pointer associated with each
+ * element in this struct array.
+ */
 struct MessageType MessageTypes[MAX_TYPE] =
 {
 	// DEBUG
diff --git a/groundStation/src/backend/commands.h b/groundStation/src/backend/commands.h
index e54e0ee5a..89b006705 100644
--- a/groundStation/src/backend/commands.h
+++ b/groundStation/src/backend/commands.h
@@ -7,15 +7,17 @@
 
 #include "callbacks.h"
 
-// ----------------------
-// Helper stuff
+#define MAX_CMD_TEXT_LENGTH 100
 
 enum Message{
 	BEGIN_CHAR = 0xBE,
 	END_CHAR   = 0xED
 };
 
-// This should also have double to avoid confusion with float values.
+/*
+ * Enumeration of the data types that a callback function may use
+ * doubleType should get added here at some point
+ */
 enum DataType
 {
 	floatType,
@@ -23,27 +25,59 @@ enum DataType
 	stringType
 };
 
-// message type IDs used to know what kind of message we are dealing with
-// DO NOT change this enum or you will break backwards compatibility.
+/*
+ * Message type IDs used to know what kind of message we are dealing with
+ * Enumeration used to index the MessageTypes array in commands.c
+ * DO NOT change this enum or you will break backwards compatibility.
+ */
 enum MessageTypeID{
-	DEBUG_TYPE_ID,
-	PACKETLOG_TYPE_ID,
-	GETPACKETLOGS_TYPE_ID,
-	UPDATE_TYPE_ID,
-	BEGINUPDATE_TYPE_ID,
-	LOG_TYPE_ID,
-	RESPONSE_TYPE_ID,
-	SETVAL_TYPE_ID,
-	GETVAL_TYPE_ID,
-	RESPVAL_TYPE_ID,
+	DEBUG_TYPE_ID,             //
+	PACKETLOG_TYPE_ID,         //
+	GETPACKETLOGS_TYPE_ID,     //
+	UPDATE_TYPE_ID,            //
+	BEGINUPDATE_TYPE_ID,       //
+	LOG_TYPE_ID,               //
+	RESPONSE_TYPE_ID,          //
+	SETVAL_TYPE_ID,            // setting values. Example: PID constants
+	GETVAL_TYPE_ID,            // getting values. Example: PID constants
+	RESPVAL_TYPE_ID,           // responding with values. Example: PID constants
 	// This last type is just used to keep track of the size
 	MAX_TYPE
 };
 
-// MESSAGE SUBTYPES
+/*
+ * Value types used to know which value the command is referencing
+ */
+enum ValueType{
+	// PID controllers. Each one has a P, I, D, setpoint value option
+	ROLL,
+	PITCH,
+	YAW,
+	ROLL_RATE,
+	PITCH_RATE,
+	YAW_RATE,
+	LOCAL_X,
+	LOCAL_Y,
+	ALT,
+};
+
+/*
+ * Enumeration of PID constants
+ */
+enum PIDType{
+	KP, // P constant
+	KI, // I constant
+	KD, // D constant
+	SP, // Setpoint value
+};
+
+/*
+ * Message type struct used to keep track of the callback function
+ * pointers located in commands.c
+ */
 struct MessageType{
 	char ID;
-	char cmdText[100];
+	char cmdText[MAX_CMD_TEXT_LENGTH];
 	char cmdDataType;
 	command_cb * functionPtr;
 };
-- 
GitLab