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

Setpoints are partially implemented.

Ready to test the responses from quad->backend.
Then create the correct response from backend->frontend and print nicely
parent 1a86e334
Branches groundStation-dev-cli-setpoint
No related tags found
No related merge requests found
......@@ -48,3 +48,4 @@ getpid
monitor
setpid
setsetpoint
getsetpoint
......@@ -23,7 +23,7 @@ CLIBINARY=Cli
CLISRCDIR=src/cli
CLISOURCES := $(wildcard $(CLISRCDIR)/*.c)
CLIOBJECTS = $(CLISOURCES:$(CLISRCDIR)/%.c=$(OBJDIR)/%.o)
SYMLINKS=monitor setpid getpid setsetpoint
SYMLINKS=monitor setpid getpid setsetpoint getsetpoint
# Frontend-common stuff
FESRCDIR=src/frontend
......
......@@ -76,6 +76,8 @@ int main(int argc, char **argv)
needCommandHelp = 1;
}
}
printf("made it\n");
/**
* I the user has asked for help, and we have already found
......
......@@ -24,7 +24,8 @@ static cli_function_ptr cli_functions[] = {
&cli_getpid,
&cli_setpid,
&cli_getimu,
&cli_setsetpoint
&cli_setsetpoint,
&cli_getsetpoint
};
static char* commandNames[MAX_COMMANDS] = {
......
......@@ -28,13 +28,12 @@ int cli_getsetpoint(struct backend_conn * conn, int argc, char **argv) {
/* getopt_long stores the option index here. */
int option_index = 0;
c = getopt_long(argc, argv, "", long_options, &option_index);
c = getopt_long(argc, argv, "a", long_options, &option_index);
/* Detect the end of the options. */
if (c == -1)
break;
if (c == 'a') {
getheight = 1;
getlat = 1;
......@@ -43,7 +42,6 @@ int cli_getsetpoint(struct backend_conn * conn, int argc, char **argv) {
getroll = 1;
getyaw = 1;
}
}
if (needHelp) {
......@@ -51,6 +49,7 @@ int cli_getsetpoint(struct backend_conn * conn, int argc, char **argv) {
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[-a] : Gets all of the following setpoints\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");
......
......@@ -33,7 +33,7 @@ struct backend_conn * ucart_backendConnect()
struct backend_conn * conn = NULL;
printf("Trying to connect...\n");
printf("Trying to connect...");
remote.sun_family = AF_UNIX;
char * sock_env = getenv(SOCKET_ENV);
......@@ -60,6 +60,7 @@ struct backend_conn * ucart_backendConnect()
warn("setvbuf");
}
printf("Success\n");
/* success */
goto fail_final;
......@@ -68,6 +69,7 @@ fail_malloc_conn:
conn = NULL;
fail_sock:
close(s);
printf("Failure\n");
fail_final:
return conn;
}
......
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <err.h>
#include "frontend_getpid.h"
#include "pid_common.h"
......@@ -60,5 +61,23 @@ int frontend_getpid(
return 1;
}
char * response;
for (;;) {
response = ucart_backendGetline(conn);
if (response == NULL) {
warnx("Line not returned from backend");
return 1;
}
printf("received : %s\n", response);
// if (strncmp(response, MAGIC, strlen(MAGIC)) == 0) {
// break;
// }
}
// if (strncmp(response, MAGIC " ERROR", strlen(MAGIC " ERROR")) == 0) {
// warnx("Backend returned an error: %s", strstr(response, "ERROR"));
// return 1;
// }
return 0;
}
......@@ -40,6 +40,30 @@ int frontend_setsetpoint(
}
ucart_backendWrite(conn, buffer);
}
if (mask & SET_PITCH) {
if (snprintf(buffer, 2048,
"setpitch %f\n",
setpoint_data->pitch) >= 2048) {
errx(0, "Buffer to small to format!");
}
ucart_backendWrite(conn, buffer);
}
if (mask & SET_ROLL) {
if (snprintf(buffer, 2048,
"setroll %f\n",
setpoint_data->roll) >= 2048) {
errx(0, "Buffer to small to format!");
}
ucart_backendWrite(conn, buffer);
}
if (mask & SET_YAW) {
if (snprintf(buffer, 2048,
"setyaw %f\n",
setpoint_data->yaw) >= 2048) {
errx(0, "Buffer to small to format!");
}
ucart_backendWrite(conn, buffer);
}
return 0;
}
......@@ -4,7 +4,7 @@
struct frontend_setpoint_data {
float height;
float lat;
/* names with two g's due to long type name */
/* named with two g's due to long type name */
float longg;
float pitch;
float roll;
......
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