Skip to content
Snippets Groups Projects
Commit 61a1b075 authored by burneykb's avatar burneykb
Browse files

everything compiles

parent c4a2da7c
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define __CLI_H #define __CLI_H
#include "cli_setsetpoint.h" #include "cli_setsetpoint.h"
#include "cli_getsetpoint.h"
#include "cli_monitor.h" #include "cli_monitor.h"
#include "cli_setpid.h" #include "cli_setpid.h"
#include "cli_getpid.h" #include "cli_getpid.h"
...@@ -13,6 +14,7 @@ enum CommandNameIds{ ...@@ -13,6 +14,7 @@ enum CommandNameIds{
CMD_SETPID, CMD_SETPID,
CMD_GETIMU, CMD_GETIMU,
CMD_SETSETPOINT, CMD_SETSETPOINT,
CMD_GETSETPOINT,
MAX_COMMANDS MAX_COMMANDS
}; };
...@@ -30,7 +32,8 @@ static char* commandNames[MAX_COMMANDS] = { ...@@ -30,7 +32,8 @@ static char* commandNames[MAX_COMMANDS] = {
"getpid", "getpid",
"setpid", "setpid",
"getimu", "getimu",
"setsetpoint" "setsetpoint",
"getsetpoint"
}; };
#endif /* __CLI_H */ #endif /* __CLI_H */
\ No newline at end of file
...@@ -62,62 +62,62 @@ int cli_getpid(struct backend_conn * conn, int argc, char **argv) { ...@@ -62,62 +62,62 @@ int cli_getpid(struct backend_conn * conn, int argc, char **argv) {
if(getAll) { if(getAll) {
for(int i = 0; i < PID_NUM_PIDS; ++i) { for(int i = 0; i < PID_NUM_PIDS; ++i) {
pid_data.controller = i; pid_data.controller = i;
if ((result = getValues(conn, &pid_data))) { if ((result = getPidValues(conn, &pid_data))) {
return result; return result;
} }
} }
} else { } else {
if(getPitch) { if(getPitch) {
pid_data.controller = PID_PITCH; pid_data.controller = PID_PITCH;
if ((result = getValues(conn, &pid_data))) { if ((result = getPidValues(conn, &pid_data))) {
return result; return result;
} }
} }
if(getRoll) { if(getRoll) {
pid_data.controller = PID_ROLL; pid_data.controller = PID_ROLL;
if ((result = getValues(conn, &pid_data))) { if ((result = getPidValues(conn, &pid_data))) {
return result; return result;
} }
} }
if(getYaw) { if(getYaw) {
pid_data.controller = PID_YAW; pid_data.controller = PID_YAW;
if ((result = getValues(conn, &pid_data))) { if ((result = getPidValues(conn, &pid_data))) {
return result; return result;
} }
} }
if(getPitchV) { if(getPitchV) {
pid_data.controller = PID_PITCH_RATE; pid_data.controller = PID_PITCH_RATE;
if ((result = getValues(conn, &pid_data))) { if ((result = getPidValues(conn, &pid_data))) {
return result; return result;
} }
} }
if(getRollV) { if(getRollV) {
pid_data.controller = PID_ROLL_RATE; pid_data.controller = PID_ROLL_RATE;
if ((result = getValues(conn, &pid_data))) { if ((result = getPidValues(conn, &pid_data))) {
return result; return result;
} }
} }
if(getYawV) { if(getYawV) {
pid_data.controller = PID_YAW_RATE; pid_data.controller = PID_YAW_RATE;
if ((result = getValues(conn, &pid_data))) { if ((result = getPidValues(conn, &pid_data))) {
return result; return result;
} }
} }
if(getHeight) { if(getHeight) {
pid_data.controller = PID_HEIGHT; pid_data.controller = PID_HEIGHT;
if ((result = getValues(conn, &pid_data))) { if ((result = getPidValues(conn, &pid_data))) {
return result; return result;
} }
} }
if(getLat) { if(getLat) {
pid_data.controller = PID_LAT; pid_data.controller = PID_LAT;
if ((result = getValues(conn, &pid_data))) { if ((result = getPidValues(conn, &pid_data))) {
return result; return result;
} }
} }
if(getLong) { if(getLong) {
pid_data.controller = PID_LONG; pid_data.controller = PID_LONG;
if ((result = getValues(conn, &pid_data))) { if ((result = getPidValues(conn, &pid_data))) {
return result; return result;
} }
} }
...@@ -127,7 +127,7 @@ int cli_getpid(struct backend_conn * conn, int argc, char **argv) { ...@@ -127,7 +127,7 @@ int cli_getpid(struct backend_conn * conn, int argc, char **argv) {
return 0; return 0;
} }
int getValues(struct backend_conn * conn, struct frontend_pid_data * pid_data) { int getPidValues(struct backend_conn * conn, struct frontend_pid_data * pid_data) {
if(frontend_getpid(conn, pid_data)) { if(frontend_getpid(conn, pid_data)) {
return 1; return 1;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "frontend_getpid.h" #include "frontend_getpid.h"
int getValues(struct backend_conn *, struct frontend_pid_data *); int getPidValues(struct backend_conn *, struct frontend_pid_data *);
int cli_getpid(struct backend_conn * conn, int argc, char ** argv); int cli_getpid(struct backend_conn * conn, int argc, char ** argv);
#endif /* __CLI_GETPID_H */ #endif /* __CLI_GETPID_H */
\ No newline at end of file
#include <stdio.h>
#include <unistd.h>
#include <getopt.h>
#include "cli_getsetpoint.h"
int cli_getsetpoint(struct backend_conn * conn, int argc, char **argv) {
int c;
static int getheight = 0, getlat = 0, getlong = 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", no_argument, &getheight, 1},
{"long", no_argument, &getlong, 1},
{"lat", no_argument, &getlat, 1},
{0, 0, 0, 0}
};
while (1)
{
/* getopt_long stores the option index here. */
int option_index = 0;
c = getopt_long(argc, argv, "", long_options, &option_index);
/* Detect the end of the options. */
if (c == -1)
break;
if (c == 'a') {
getheight = 1;
getlat = 1;
getlong = 1;
}
}
if (needHelp) {
printf("Getsetpoint gets the height, lat , and long set point values for the quad.\n");
printf("Usage Syntax : \n\t./Cli getsetpoint [options...]\n");
printf("Symlink Usage Syntax : \n\t./getsetpoint [options...]\n\n");
printf("Available options include the following\n");
printf("\t[--height] : Gets the height setpoint\n");
printf("\t[--lat] : Gets the latitude setpoint\n");
printf("\t[--long] : Gets the longitude setpoint\n");
return 0;
}
if (argc < 2) {
printf("Incorrect Usage, run './cli getsetpoint --help' for correct usage.\n");
return 1;
}
int result;
if(getheight) {
if ((result = getSetPointValues(conn, &setpoint_data, HEIGHT))) {
return result;
}
}
if(getlat) {
if ((result = getSetPointValues(conn, &setpoint_data, LAT))) {
return result;
}
}
if(getlong) {
if ((result = getSetPointValues(conn, &setpoint_data, LONGG))) {
return result;
}
}
return 0;
}
int getSetPointValues(struct backend_conn * conn, struct frontend_setpoint_data * setpoint_data, int type) {
if(frontend_getsetpoint(conn, setpoint_data, type)) {
return 1;
}
switch(type) {
case HEIGHT :
printf("Height: %f\n",
setpoint_data->height);
break;
case LAT :
printf("Latitude: %f\n",
setpoint_data->lat);
case LONGG :
printf("Longitude: %f\n",
setpoint_data->longg);
default :
break;
}
return 0;
}
#ifndef __CLI_GETSETPOINT_H
#define __CLI_GETSETPOINT_H
#include "frontend_getsetpoint.h"
#define HEIGHT 0
#define LAT 1
#define LONGG 2
int getSetPointValues(struct backend_conn *, struct frontend_setpoint_data *, int type);
int cli_getsetpoint(struct backend_conn * conn, int argc, char ** argv);
#endif /* __CLI_GETSETPOINT_H */
\ No newline at end of file
...@@ -50,13 +50,13 @@ int cli_setsetpoint(struct backend_conn * conn, int argc, char **argv) { ...@@ -50,13 +50,13 @@ int cli_setsetpoint(struct backend_conn * conn, int argc, char **argv) {
} }
if (needHelp) { if (needHelp) {
printf("Setsetpoint sets the x, y , or z set point values for the quad.\n"); printf("Setsetpoint sets the height, lat , or long set point values for the quad.\n");
printf("Usage Syntax : \n\t./Cli setsetpoint [options...]\n"); printf("Usage Syntax : \n\t./Cli setsetpoint [options...]\n");
printf("Symlink Usage Syntax : \n\t./setsetpoint [options...]\n\n"); printf("Symlink Usage Syntax : \n\t./setsetpoint [options...]\n\n");
printf("Available options include the following\n"); printf("Available options include the following\n");
printf("\t[-x] 'val' : Sets the x setpoint value to 'val'\n"); printf("\t[--height] 'val' : Sets the height setpoint value to 'val'\n");
printf("\t[-z] 'val' : Sets the y setpoint value to 'val'\n"); printf("\t[--lat] 'val' : Sets the latitude setpoint value to 'val'\n");
printf("\t[-z] 'val' : Sets the z setpoint value to 'val'\n"); printf("\t[--long] 'val' : Sets the longitude setpoint value to 'val'\n");
return 0; return 0;
} }
......
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "frontend_getsetpoint.h"
#include "setpoint_common.h"
#include "cli_getsetpoint.h"
/* Get a specified setpoint.
*
* Example:
*
* struct frontend_setpoint_data setpoint_data;
* if (frontend_getpid(conn, &pid_data)) {
* error
* } else {
* setpoint_data.height, setpoint_data.lat, and setpoint.long are filled
* }
*
* Returns 0 on success, 1 on error
*/
int frontend_getsetpoint(
struct backend_conn * conn, struct frontend_setpoint_data * setpoint_data, int type) {
char line[25] = "";
switch (type) {
case HEIGHT :
strncpy(line, "getheight\n", 10);
break;
case LAT :
strncpy(line, "getlat\n", 7);
break;
case LONGG :
strncpy(line, "getlong\n", 8);
break;
}
int size;
if((size = ucart_backendWrite(conn, line)) < 0 ) {
return 1;
}
return 0;
}
#ifndef __FRONTEND_GETSETPOINT_H
#define __FRONTEND_GETSETPOINT_H
#include "frontend_common.h"
#include "setpoint_common.h"
/* Get a specified setpoint.
*
* Example:
*
* struct frontend_setpoint_data setpoint_data;
* if (frontend_getpid(conn, &pid_data)) {
* error
* } else {
* setpoint_data.height, setpoint_data.lat, and setpoint.long are filled
* }
*
* Returns 0 on success, 1 on error
*/
int frontend_getsetpoint(
struct backend_conn * conn,
struct frontend_setpoint_data * setpoint_data,
int type);
#endif /* __FRONTEND_GETPID_H */
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment