From 9a8459c76c9a17bec68ad17be9013fde8a0a8c97 Mon Sep 17 00:00:00 2001
From: "ucart@co3050-12" <dawehr@iastate.edu>
Date: Wed, 15 Mar 2017 15:17:50 -0500
Subject: [PATCH] Added LOG_END message type on quadcopter and in shared
 commands.

---
 groundStation/src/backend/commands.c | 10 ++++++++++
 groundStation/src/backend/commands.h |  6 ++++--
 quad/sw/modular_quad_pid/src/main.c  |  2 ++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/groundStation/src/backend/commands.c b/groundStation/src/backend/commands.c
index 4bba28735..8c64c0efc 100644
--- a/groundStation/src/backend/commands.c
+++ b/groundStation/src/backend/commands.c
@@ -55,6 +55,7 @@ command_cb cb_update __attribute__((weak, alias("cb_default")));
 command_cb cb_beginupdate __attribute__((weak, alias("cb_default")));
 command_cb cb_log __attribute__((weak, alias("cb_default")));
 command_cb cb_response __attribute__((weak, alias("cb_default")));
+command_cb cb_logend __attribute__((weak, alias("cb_default")));
 
 /* Callbacks for configuration */
 command_cb cb_setparam __attribute__((weak, alias("cb_default")));
@@ -163,6 +164,15 @@ struct MessageType MessageTypes[MAX_TYPE_ID] =
 		floatType,
 		// Function pointer
 		&cb_respparam
+	},
+	// LOG_END
+	{
+		// Command text
+		"logend",
+		// Type of the command data
+		stringType,
+		// Function pointer
+		&cb_logend
 	}
 
 };
diff --git a/groundStation/src/backend/commands.h b/groundStation/src/backend/commands.h
index 73ec98f95..08218e6ff 100644
--- a/groundStation/src/backend/commands.h
+++ b/groundStation/src/backend/commands.h
@@ -29,7 +29,8 @@ enum DataType
  * 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.
+ * DO NOT change items in the middle of this enum or you will break backwards compatibility.
+ *     - Add new message types in the slot between MAX_TYPE_ID and the one before it
  * DO NOT change this enum without also updating the "MessageTypes" array
  * in commands.c to match.
  */
@@ -44,7 +45,8 @@ enum MessageTypeID{
 	SETPARAM_ID,          // 07 - Setting controller parameters. Example: PID constants
 	GETPARAM_ID,          // 08 - Getting controller parameters. Example: PID constants
 	RESPPARAM_ID,         // 09 - Responding with controller parameters. Example: PID constants
-	MAX_TYPE_ID           // 10 - Just used to keep track of the size
+	LOG_END_ID,           // 10 - Responding with controller parameters. Example: PID constants
+	MAX_TYPE_ID           // 11 - Just used to keep track of the size. Must remain at the end
 };
 
 /*
diff --git a/quad/sw/modular_quad_pid/src/main.c b/quad/sw/modular_quad_pid/src/main.c
index 52f8c0a83..790dc32f3 100644
--- a/quad/sw/modular_quad_pid/src/main.c
+++ b/quad/sw/modular_quad_pid/src/main.c
@@ -129,6 +129,8 @@ int main()
 			printLogging(&(structs.log_struct), &(structs.parameter_struct));
 			resetLogging();
 			MIO7_led_off();
+			char data[1] = {0}; // 1 byte to make compilers happy
+			send_data(LOG_END_ID, 0, data, 0);
 		}
 
 		last_kill_condition = this_kill_condition;
-- 
GitLab