From f537f33cdebfbe92ec23735a52e536adbe2c2e0d Mon Sep 17 00:00:00 2001
From: burneykb <burneykb@iastate.edu>
Date: Tue, 24 Jan 2017 08:29:25 -0600
Subject: [PATCH] changing to fit new command scheme

---
 groundStation/src/cli/cli_setsetpoint.c       | 26 +++++++++++--------
 .../src/frontend/frontend_setsetpoint.c       | 18 ++++++-------
 .../src/frontend/frontend_setsetpoint.h       |  8 +++---
 groundStation/src/frontend/setpoint_common.h  |  7 ++---
 4 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/groundStation/src/cli/cli_setsetpoint.c b/groundStation/src/cli/cli_setsetpoint.c
index 85cd86d16..77bdef93c 100644
--- a/groundStation/src/cli/cli_setsetpoint.c
+++ b/groundStation/src/cli/cli_setsetpoint.c
@@ -6,13 +6,16 @@
 
 int cli_set(struct backend_conn * conn,	int argc, char **argv) {
 	int c;
-	static int setX = 0, setY = 0, setZ = 0;
+	static int setheight = 0, setlat = 0, setlong = 0;
 	struct frontend_setpoint_data setpoint_data;
 	static int needHelp = 0;
 	static int mask;
 	static struct option long_options[] = {
  		/* These options don’t set a flag. We distinguish them by their indices. */
  		{"help",	no_argument,	&needHelp,	1},
+ 		{"height",  required_argument,	0,  'h'},
+ 		{"long",	required_argument,	0,	't'},
+ 		{"lat",		required_argument, 	0,	'l'},
  		{0, 0, 0, 0}
  	};
 
@@ -21,28 +24,29 @@ int cli_set(struct backend_conn * conn,	int argc, char **argv) {
 		/* getopt_long stores the option index here. */
 		int option_index = 0;
 
-		c = getopt_long(argc, argv, "x:y:z:", long_options, &option_index);
+		c = getopt_long(argc, argv, "", long_options, &option_index);
 
 		/* Detect the end of the options. */
 		if (c == -1)
 			break;
 
 		switch(c) {
-			case 'x' :
-				setpoint_data.x  = atof(optarg);
-				mask |= SET_X;
+			case 'h' :
+				setpoint_data.height  = atof(optarg);
+				mask |= SET_HEIGHT;
 				break;
-			case 'y' :
-				setpoint_data.y  = atof(optarg);
-				mask |= SET_Y;
+			case 't' :
+				setpoint_data.lat  = atof(optarg);
+				mask |= SET_LAT;
 				break;
-			case 'z' :
-				setpoint_data.z  = atof(optarg);
-				mask |= SET_Z;
+			case 'l' :
+				setpoint_data.longg  = atof(optarg);
+				mask |= SET_LONG;
 				break;
 			default :
 				break;
 		}
+
 	}
 
 	if (needHelp) {
diff --git a/groundStation/src/frontend/frontend_setsetpoint.c b/groundStation/src/frontend/frontend_setsetpoint.c
index f26447921..d6c3f37bf 100644
--- a/groundStation/src/frontend/frontend_setsetpoint.c
+++ b/groundStation/src/frontend/frontend_setsetpoint.c
@@ -16,26 +16,26 @@ int frontend_setsetpoint(
 
 	char buffer[2048];
 	/* Set the P, I, and D */
-	if (mask & SET_X) {
+	if (mask & SET_HEIGHT) {
 		if (snprintf(buffer, 2048,
-					"setsetpointx %f\n",  
-					setpoint_data->x) >= 2048) {
+					"setheight %f\n",  
+					setpoint_data->height) >= 2048) {
 			errx(0, "Buffer to small to format!");
 		}
 		ucart_backendWrite(conn, buffer);
 	}
-	if (mask & SET_Y) {
+	if (mask & SET_LAT) {
 		if (snprintf(buffer, 2048,
-					"setsetpointy %f\n",
-					setpoint_data->y) >= 2048) {
+					"setlat %f\n",
+					setpoint_data->lat) >= 2048) {
 			errx(0, "Buffer to small to format!");
 		}
 		ucart_backendWrite(conn, buffer);
 	}
-	if (mask & SET_Z) {
+	if (mask & SET_LONG) {
 		if (snprintf(buffer, 2048,
-					"setsetpointz %f\n",
-					setpoint_data->z) >= 2048) {
+					"setlong %f\n",
+					setpoint_data->longg) >= 2048) {
 			errx(0, "Buffer to small to format!");
 		}
 		ucart_backendWrite(conn, buffer);
diff --git a/groundStation/src/frontend/frontend_setsetpoint.h b/groundStation/src/frontend/frontend_setsetpoint.h
index 03806fdfe..272de3ce8 100644
--- a/groundStation/src/frontend/frontend_setsetpoint.h
+++ b/groundStation/src/frontend/frontend_setsetpoint.h
@@ -9,12 +9,12 @@ int frontend_setsetpoint(
 		struct frontend_setpoint_data * setpoint_data,
 		int mask);
 
-#define SET_X 0x01
-#define SET_Y 0x02
-#define SET_Z 0x04
+#define SET_LAT 0x01
+#define SET_LONG 0x02
+#define SET_HEIGHT 0x04
 
 #ifndef SET_ALL
-#define SET_ALL (SET_X | SET_Y | SET_Z)
+#define SET_ALL (SET_LAT | SET_LONG | SET_HEIGHT)
 #endif /* SET_ALL */
 
 #endif /* FRONTEND_SETSETPOINT_H */
\ No newline at end of file
diff --git a/groundStation/src/frontend/setpoint_common.h b/groundStation/src/frontend/setpoint_common.h
index 25dc8c1ce..9fc86acf0 100644
--- a/groundStation/src/frontend/setpoint_common.h
+++ b/groundStation/src/frontend/setpoint_common.h
@@ -2,9 +2,10 @@
 #define SETPOINT_COMMON_H
 
 struct frontend_setpoint_data {
-	float x;
-	float y;
-	float z;
+	float height;
+	float lat;
+	/* names with two g's due to long type name */
+	float longg;
 };
 
 
-- 
GitLab