From ab1cc30121a333114d7de11fb4d23996b4749e97 Mon Sep 17 00:00:00 2001
From: Jake Drahos <j@kedrahos.com>
Date: Mon, 28 Nov 2016 16:09:19 -0600
Subject: [PATCH] Added support for setpid

Example: setpid --pitch -p 5.0

Support is not fully fleshed out because the quad
doesn't support everything. Some backend changes
will be needed to support the rest of the PID constants that
are in the design document.

Right now, the P and the D of pitch, roll, and yaw are
supported. The Height/Lat/Long PID controllers are
not supported by the quad<->backend protocol,
nor are the I constants of anything. The quad<->backend
protocol is aware of a Throttle controller, which is
nowhere in the documentation.
---
 groundStation/src/cli/cli.h                  | 16 ++++++++--------
 groundStation/src/cli/cli_setpid.h           |  8 ++++++++
 groundStation/src/frontend/frontend_setpid.c |  2 +-
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/groundStation/src/cli/cli.h b/groundStation/src/cli/cli.h
index 2951fd8d4..f4c2fe3f4 100644
--- a/groundStation/src/cli/cli.h
+++ b/groundStation/src/cli/cli.h
@@ -2,29 +2,29 @@
 #define __CLI_H
 
 #include "cli_monitor.h"
-// #include "cli_setpid.h"
+#include "cli_setpid.h"
 #include "cli_getpid.h"
 // #include "cli_getimu.h"
 enum CommandNameIds{
 	CMD_MONITOR,
-	CMD_SETPID,
 	CMD_GETPID,
+	CMD_SETPID,
 	CMD_GETIMU,
 	MAX_COMMANDS
 };
 
 typedef int (*cli_function_ptr)(struct backend_conn *, int, char **);
-static cli_function_ptr cli_functions[2] = {
+static cli_function_ptr cli_functions[] = {
 	&cli_monitor,
-	&cli_getpid
-	// &cli_setpid,
-	// &cli_getimu
+	&cli_getpid,
+	&cli_setpid
+	//&cli_getimu
 };
 
 static char* commandNames[MAX_COMMANDS] = {
 	"monitor",
-	"getPid",
-	"setPid",
+	"getpid",
+	"setpid",
 	"getImu"
 };
 
diff --git a/groundStation/src/cli/cli_setpid.h b/groundStation/src/cli/cli_setpid.h
index e69de29bb..87fb0a4f4 100644
--- a/groundStation/src/cli/cli_setpid.h
+++ b/groundStation/src/cli/cli_setpid.h
@@ -0,0 +1,8 @@
+#ifndef _CLI_SETPID_H
+#define _CLI_SETPID_H
+
+#include "frontend_setpid.h"
+
+int cli_setpid(struct backend_conn * conn, int argc, char ** argv);
+
+#endif
diff --git a/groundStation/src/frontend/frontend_setpid.c b/groundStation/src/frontend/frontend_setpid.c
index ec3119925..0a25d8e3c 100644
--- a/groundStation/src/frontend/frontend_setpid.c
+++ b/groundStation/src/frontend/frontend_setpid.c
@@ -27,7 +27,7 @@ int frontend_setpid(
 			break;
 			/* What is the "throttle" pid constant? */
 		default:
-			warnx("Unsupported PID variable");
+			warnx("Unsupported PID constant");
 			return -1;
 	}
 
-- 
GitLab