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

Implemented cli_getPid and modified makefile/gitignore

parent 1eeaa3ee
No related branches found
No related tags found
No related merge requests found
...@@ -39,9 +39,6 @@ src/vrpn/pc_linux64/* ...@@ -39,9 +39,6 @@ src/vrpn/pc_linux64/*
#Exacutables #Exacutables
logs logs
client
BackEnd BackEnd
obj obj
cli CLI
monitorQuad
testClient
...@@ -19,7 +19,7 @@ BECPPSOURCES := $(wildcard $(BESRCDIR)/*.cpp ) ...@@ -19,7 +19,7 @@ BECPPSOURCES := $(wildcard $(BESRCDIR)/*.cpp )
BECPPOBJECTS = $(BECPPSOURCES:$(BESRCDIR)/%.cpp=$(OBJDIR)/%.o) BECPPOBJECTS = $(BECPPSOURCES:$(BESRCDIR)/%.cpp=$(OBJDIR)/%.o)
# CLI Specific Variables # CLI Specific Variables
CLIBINARY=cli CLIBINARY=CLI
CLISRCDIR=src/cli CLISRCDIR=src/cli
CLISOURCES := $(wildcard $(CLISRCDIR)/*.c) CLISOURCES := $(wildcard $(CLISRCDIR)/*.c)
CLIOBJECTS = $(CLISOURCES:$(CLISRCDIR)/%.c=$(OBJDIR)/%.o) CLIOBJECTS = $(CLISOURCES:$(CLISRCDIR)/%.c=$(OBJDIR)/%.o)
......
...@@ -43,7 +43,7 @@ int main(int argc, char **argv) ...@@ -43,7 +43,7 @@ int main(int argc, char **argv)
if(useSymlink) { if(useSymlink) {
//TODO Call correct command function pointer with (argv[1] ... argc[argc]) //TODO Call correct command function pointer with (argv[1] ... argc[argc])
}else { }else {
(*cli_functions[0]) (conn, &argv[2]); (*cli_functions[0]) (conn, argc - 1, &argv[2]);
} }
ucart_backendDisconnect(conn); ucart_backendDisconnect(conn);
......
...@@ -15,7 +15,7 @@ enum CommandNameIds{ ...@@ -15,7 +15,7 @@ enum CommandNameIds{
MAX_COMMANDS MAX_COMMANDS
}; };
typedef int (*cli_function_ptr)(struct backend_conn *, char **); typedef int (*cli_function_ptr)(struct backend_conn *, int, char **);
static cli_function_ptr cli_functions[1] = { static cli_function_ptr cli_functions[1] = {
// &cli_monitor, // &cli_monitor,
// &cli_setpid, // &cli_setpid,
......
#ifndef CLI_GETIMU_H
#define CLI_GETIMU_H
#include "frontend_getimu.h"
int cli_getimu(
struct backend_conn * conn,
struct frontend_pid_data * pid_data);
#endif
\ No newline at end of file
#include <stdio.h>
#include <unistd.h>
#include <getopt.h>
#include "cli_getpid.h"
int cli_getpid(struct backend_conn * conn, int argc, char **argv) {
int c;
static int getRoll = 0, getPitch = 0, getYaw = 0, getAll = 0;
struct frontend_pid_data pid_data;
static struct option long_options[] = {
/* These options don’t set a flag. We distinguish them by their indices. */
{"roll", no_argument, &getRoll, 1},
{"pitch", no_argument, &getPitch, 1},
{"yaw", no_argument, &getYaw, 1},
{0, 0, 0, 0}
};
while (1)
{
/* getopt_long stores the option index here. */
int option_index = 0;
c = getopt_long(argc, argv, "a", long_options, &option_index);
/* Detect the end of the options. */
if (c == -1)
break;
if (c == 'a') {
getAll = 1;
}
}
int result;
if(getAll) {
pid_data.pid = ROLL;
if ((result = getValues(conn, &pid_data))) {
return result;
}
pid_data.pid = PITCH;
if ((result = getValues(conn, &pid_data))) {
return result;
}
pid_data.pid = YAW;
if ((result = getValues(conn, &pid_data))) {
return result;
}
} else {
if(getPitch) {
pid_data.pid = PITCH;
if ((result = getValues(conn, &pid_data))) {
return result;
}
}
if(getRoll) {
pid_data.pid = ROLL;
if ((result = getValues(conn, &pid_data))) {
return result;
}
}
if(getYaw) {
pid_data.pid = YAW;
if ((result = getValues(conn, &pid_data))) {
return result;
}
}
}
return 0;
}
int getValues(struct backend_conn * conn, struct frontend_pid_data * pid_data) {
if(frontend_getpid(conn, pid_data)) {
return 1;
}
switch(pid_data->pid) {
case PITCH :
printf("Pitch Constants: P = %f\tI = %f\tD = %f\n",
pid_data->p, pid_data->i, pid_data->d);
break;
case ROLL :
printf("Roll Constants: P = %f\tI = %f\tD = %f\n",
pid_data->p, pid_data->i, pid_data->d);
break;
case YAW :
printf("Yaw Constants: P = %f\tI = %f\tD = %f\n",
pid_data->p, pid_data->i, pid_data->d);
break;
default :
break;
}
return 0;
}
\ No newline at end of file
#ifndef CLI_GETPID_H
#define CLI_GETPID_H
#include "frontend_getpid.h"
int getValues(struct backend_conn *, struct frontend_pid_data *);
int cli_getpid(struct backend_conn * conn, int argc, char ** argv);
#endif
\ No newline at end of file
#ifndef CLI_MONITOR_H
#define CLI_MONITOR_H
#include "frontend_getpid.h"
int cli_getpid(
struct backend_conn * conn,
struct frontend_pid_data * pid_data);
#endif
\ 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