diff --git a/groundStation/src/cli/cli_setsetpoint.c b/groundStation/src/cli/cli_setsetpoint.c index 85cd86d164712e0a83ef7bdc64bd1b50a0ffeee3..77bdef93ce2c3f59fb62ac06605b8d18f7111484 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 f264479210dc801629bd27f14200a11709a38e1b..d6c3f37bfe204c8e095332b352e4d5242c727703 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 03806fdfe2bfb492a458475c36ffbb012586ebcd..272de3ce8b11d891b43320da0ab1047a459c730e 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 25dc8c1ce8ee6ae76805ba10595c0e0139ea8a00..9fc86acf002279c7cf673f48e7a323a77fced17d 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; };