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

All commands work and have been tested

parent 2cea4b46
No related branches found
No related tags found
No related merge requests found
...@@ -6,8 +6,8 @@ GXX=g++ ...@@ -6,8 +6,8 @@ GXX=g++
CFLAGS= -Wall -pedantic -Wextra -Werror -std=gnu99 -g -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-but-set-variable CFLAGS= -Wall -pedantic -Wextra -Werror -std=gnu99 -g -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-but-set-variable
CXXFLAGS= -Wall -pedantic -Wextra -Werror -Wno-reorder -Wno-unused-variable -std=c++0x -g CXXFLAGS= -Wall -pedantic -Wextra -Werror -Wno-reorder -Wno-unused-variable -std=c++0x -g
INCLUDES = $(foreach dir, $(INCDIR), -I$(dir)) INCLUDES = $(foreach dir, $(INCDIR), -I$(dir))
INCDIR=../quad/inc src/vrpn src/vrpn/quat src/vrpn/build $(BESRCDIR) $(CLISRCDIR) $(FESRCDIR) INCDIR= src/vrpn src/vrpn/quat src/vrpn/build $(BESRCDIR) $(CLISRCDIR) $(FESRCDIR) ../quad/inc
LIBS= -lpthread -lbluetooth -lvrpn -lquat -Lsrc/vrpn/build -Lsrc/vrpn/build/quat -lcomputation_graph -L../quad/lib -lcommands LIBS= -lpthread -lbluetooth -lvrpn -lquat -Lsrc/vrpn/build -Lsrc/vrpn/build/quat -L../quad/lib -lquad_app -lcommands -lgraph_blocks -lcomputation_graph
OBJDIR=obj OBJDIR=obj
# Backend Specific Variables # Backend Specific Variables
...@@ -50,7 +50,6 @@ cli: $(CLIOBJECTS) $(FECOBJECTS) ...@@ -50,7 +50,6 @@ cli: $(CLIOBJECTS) $(FECOBJECTS)
$(CLIOBJECTS) : $(OBJDIR)/%.o : $(CLISRCDIR)/%.c $(CLIOBJECTS) : $(OBJDIR)/%.o : $(CLISRCDIR)/%.c
$(GCC) $(CFLAGS) -c $^ -o $@ $(INCLUDES) $(LIBS) $(GCC) $(CFLAGS) -c $^ -o $@ $(INCLUDES) $(LIBS)
backend: $(BECPPOBJECTS) $(BECOBJECTS) backend: $(BECPPOBJECTS) $(BECOBJECTS)
$(GXX) $(CXXFLAGS) $^ -o $(BEBINARY) $(INCLUDES) $(LIBS) $(GXX) $(CXXFLAGS) $^ -o $(BEBINARY) $(INCLUDES) $(LIBS)
...@@ -79,5 +78,4 @@ clean_logs: ...@@ -79,5 +78,4 @@ clean_logs:
clean: clean:
rm -rf $(OBJDIR)/ $(BEBINARY) $(CLIBINARY) $(SYMLINKS) rm -rf $(OBJDIR)/ $(BEBINARY) $(CLIBINARY) $(SYMLINKS)
debug: debug:
@echo $(COMOBJECTS) \ No newline at end of file
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "cli.h" #include "cli.h"
#include "cli_nodes.h" #include "cli_nodes.h"
#include "frontend_nodes.h" #include "frontend_nodes.h"
#include "graph_blocks.h"
int cli_getnodes(struct backend_conn * conn, int argc, char ** argv) { int cli_getnodes(struct backend_conn * conn, int argc, char ** argv) {
size_t num_nodes = 0; size_t num_nodes = 0;
...@@ -13,6 +15,9 @@ int cli_getnodes(struct backend_conn * conn, int argc, char ** argv) { ...@@ -13,6 +15,9 @@ int cli_getnodes(struct backend_conn * conn, int argc, char ** argv) {
int needHelp = 0; int needHelp = 0;
size_t i, n;
if ((needHelp = help_check(argc, argv))) { if ((needHelp = help_check(argc, argv))) {
printf("getnodes gets the number of nodes along with the block_id, type_id and name of each node\n"); printf("getnodes gets the number of nodes along with the block_id, type_id and name of each node\n");
printf("Usage Syntax : \n\t./Cli getnodes\n"); printf("Usage Syntax : \n\t./Cli getnodes\n");
...@@ -37,9 +42,35 @@ int cli_getnodes(struct backend_conn * conn, int argc, char ** argv) { ...@@ -37,9 +42,35 @@ int cli_getnodes(struct backend_conn * conn, int argc, char ** argv) {
printf("------------------------------------------------\n"); printf("------------------------------------------------\n");
printf("\tBLOCK\t\tTYPE\t\tNAME\n"); printf("\tBLOCK\t\tTYPE\t\tNAME\n");
printf("------------------------------------------------\n"); printf("------------------------------------------------\n");
for(size_t i = 0; i < num_nodes; ++i) { for(i = 0; i < num_nodes; ++i) {
printf("\t%3d\t\t%3d\t\t%s\n", node_data[i].block, node_data[i].type, node_data[i].name); printf("\t%3d\t\t%3d\t\t%s\t", node_data[i].block, node_data[i].type, node_data[i].name);
const struct graph_node_type * node_definition = blockDefs[node_data[i].type];
printf(" {");
for(n = 0; n < (size_t)node_definition->n_inputs; ++n) {
printf(" %-5s ", node_definition->input_names[n]);
}
printf("} ");
printf(" {");
for(n = 0; n < (size_t)node_definition->n_params; ++n) {
printf(" %s ", node_definition->param_names[n]);
}
printf("} ");
printf(" {");
for(n = 0; n < (size_t)node_definition->n_outputs; ++n) {
printf(" %s ", node_definition->output_names[n]);
}
printf("}\n");
free(node_data[i].name);
} }
free(node_data); free(node_data);
return 0; return 0;
} }
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
#include "cli.h" #include "cli.h"
#include "cli_param.h" #include "cli_param.h"
#include "frontend_param.h"
int cli_getparam(struct backend_conn * conn, int argc, char ** argv) { int cli_getparam(struct backend_conn * conn, int argc, char ** argv) {
int needHelp = 0; int needHelp = 0;
struct frontend_param_data param_data; struct frontend_param_data param_data;
if ((needHelp = help_check(argc, argv))) { if ((needHelp = help_check(argc, argv))) {
printf("getparam gets the param_val for a specified block_id and param_id\n"); printf("getparam gets the param_val for a specified block_id and param_id\n");
printf("Usage Syntax : \n\t./Cli getparam block_id param_id\n"); printf("Usage Syntax : \n\t./Cli getparam block_id param_id\n");
...@@ -22,8 +22,9 @@ int cli_getparam(struct backend_conn * conn, int argc, char ** argv) { ...@@ -22,8 +22,9 @@ int cli_getparam(struct backend_conn * conn, int argc, char ** argv) {
return 1; return 1;
} }
param_data.block = atoi(argv[1]); if (convert_to_id(conn, argv, &param_data)) {
param_data.param = atoi(argv[2]); return 1;
}
if (frontend_getparam(conn, &param_data)) { if (frontend_getparam(conn, &param_data)) {
return 1; return 1;
...@@ -53,8 +54,11 @@ int cli_setparam(struct backend_conn * conn, int argc, char ** argv) { ...@@ -53,8 +54,11 @@ int cli_setparam(struct backend_conn * conn, int argc, char ** argv) {
return 1; return 1;
} }
param_data.block = atoi(argv[1]);
param_data.param = atoi(argv[2]); if (convert_to_id(conn, argv, &param_data)) {
return 1;
}
param_data.value = atoi(argv[3]); param_data.value = atoi(argv[3]);
if (frontend_setparam(conn, &param_data)) { if (frontend_setparam(conn, &param_data)) {
......
#ifndef _CLI_PARAM_H #ifndef _CLI_PARAM_H
#define _CLI_PARAM_H #define _CLI_PARAM_H
#include <ctype.h>
#include <string.h>
#include "frontend_param.h" #include "frontend_param.h"
#include "frontend_nodes.h"
#include "graph_blocks.h"
static int isNumber(char *number)
{
int i = 0;
//checking for negative numbers
if (number[0] == '-')
i = 1;
for (; number[i] != 0; i++)
{
//if (number[i] > '9' || number[i] < '0')
if (!isdigit(number[i]))
return 0;
}
return 1;
}
static int convert_to_id(struct backend_conn * conn, char **argv, struct frontend_param_data * param_data) {
/* variables used to search for id values */
size_t num_nodes = 0, i;
struct frontend_node_data* search_data;
int search_for_block = 0, search_for_param = 0;
const struct graph_node_type * node_definition;
if (!isNumber(argv[1])) {
search_for_block = 1;
} else {
param_data->block = atoi(argv[1]);
}
if (!isNumber(argv[2])) {
search_for_param = 1;
} else {
param_data->param = atoi(argv[2]);
}
if (!search_for_block && !search_for_param) {
return 0;
}
search_data = malloc(sizeof((*search_data)) * num_nodes);
if (frontend_getnodes(conn, &search_data, &num_nodes)) {
return 1;
}
if (search_for_block) {
for (i = 0; i < num_nodes; ++i) {
if (strncmp(search_data[i].name, argv[1], strlen(search_data[i].name)) == 0) {
param_data->block = search_data[i].block;
node_definition = blockDefs[search_data[i].type];
break;
}
}
}
if (i == num_nodes)
return 1;
if (search_for_param) {
if (!search_for_block) {
node_definition = blockDefs[search_data[param_data->block].type];
}
for (i = 0; i < (size_t)node_definition->n_params; ++i) {
if (strncmp(node_definition->param_names[i],
argv[2],
strlen(node_definition->param_names[i])) == 0) {
param_data->param = i;
search_for_param = 0;
break;
}
}
}
for(i = 0; i < num_nodes; ++i) {
free(search_data[i].name);
}
free(search_data);
return search_for_param;
}
int cli_getparam(struct backend_conn * conn, int argc, char ** argv); int cli_getparam(struct backend_conn * conn, int argc, char ** argv);
int cli_setparam(struct backend_conn * conn, int argc, char ** argv); int cli_setparam(struct backend_conn * conn, int argc, char ** argv);
......
...@@ -41,7 +41,7 @@ struct frontend_source_data { ...@@ -41,7 +41,7 @@ struct frontend_source_data {
struct frontend_node_data { struct frontend_node_data {
int16_t block; int16_t block;
int16_t type; int16_t type;
char name[512]; /* This should be more than enough room for a node name */ char *name;
}; };
#endif /* __FRONTEND_COMMON_H */ #endif /* __FRONTEND_COMMON_H */
\ No newline at end of file
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
* all of the nodes in the current comp_graph. * all of the nodes in the current comp_graph.
* *
* Returns 0 on success, 1 on error * Returns 0 on success, 1 on error
*
*
* Note : node_data may be resized inside this function.
* That is why you must pass in a strcut ... **
*/ */
int frontend_getnodes( int frontend_getnodes(
struct backend_conn * conn, struct backend_conn * conn,
...@@ -68,11 +72,13 @@ int frontend_getnodes( ...@@ -68,11 +72,13 @@ int frontend_getnodes(
} }
for (size_t i = 0; i < *num_nodes; ++i) { for (size_t i = 0; i < *num_nodes; ++i) {
sscanf(response, " '%[^\t\n']' %n", (char *)&arr[i].name, (int *)&offset); char tmp_name[512];
sscanf(response, " '%[^\t\n']' %n", (char *)&tmp_name, (int *)&offset);
arr[i].name = malloc(sizeof(*arr[i].name) * strlen(tmp_name) + 1);
strcpy((char*)arr[i].name, tmp_name);
// printf("found name '%s'\n", arr[i].name); // printf("found name '%s'\n", arr[i].name);
response += offset; response += offset;
} }
pendingResponses--; pendingResponses--;
} }
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
* all of the nodes in the current comp_graph. * all of the nodes in the current comp_graph.
* *
* Returns 0 on success, 1 on error * Returns 0 on success, 1 on error
*
* Note : node_data may be resized inside this function.
* That is why you must pass in a strcut ... **
*/ */
int frontend_getnodes( int frontend_getnodes(
struct backend_conn * conn, struct backend_conn * conn,
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
*/ */
/* /*
* Enumerates all the types of different block types. * Enumerates all the types of different block types.
* Must match blockDefs * Must match blockDefs
......
...@@ -2,6 +2,5 @@ TOP=../.. ...@@ -2,6 +2,5 @@ TOP=../..
NAME = quad_app NAME = quad_app
REQLIBS = -ltest -lcomputation_graph -lm -lqueue -lgraph_blocks -lcommands REQLIBS = -ltest -lcomputation_graph -lm -lqueue -lgraph_blocks -lcommands
REQLIBS = -ltest -lcomputation_graph -lm -lqueue -lcommands
include $(TOP)/library.mk include $(TOP)/library.mk
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