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

Almost fully operational cli/monitor interface

parent a769bf9c
No related branches found
No related tags found
No related merge requests found
...@@ -103,7 +103,7 @@ struct ucart_vrpn_tracker * tracker = NULL; ...@@ -103,7 +103,7 @@ struct ucart_vrpn_tracker * tracker = NULL;
#define MAX_CLIENTS 32 #define MAX_CLIENTS 32
#define CLIENT_BUFFER_SIZE 1024 #define CLIENT_BUFFER_SIZE 1024
#define CLIENT_MAX_PENDING_RESPONSES 5 #define CLIENT_MAX_PENDING_RESPONSES 15
static char client_buffers[MAX_CLIENTS][CLIENT_BUFFER_SIZE]; static char client_buffers[MAX_CLIENTS][CLIENT_BUFFER_SIZE];
static int client_fds[MAX_CLIENTS]; static int client_fds[MAX_CLIENTS];
static int client_pending_responses[MAX_CLIENTS][CLIENT_MAX_PENDING_RESPONSES]; static int client_pending_responses[MAX_CLIENTS][CLIENT_MAX_PENDING_RESPONSES];
......
...@@ -9,11 +9,16 @@ ...@@ -9,11 +9,16 @@
#include "cli_monitor.h" #include "cli_monitor.h"
#include "frontend_tracker.h" #include "frontend_tracker.h"
#include "frontend_getpid.h"
#include "pid_common.h"
int rate = 10;
static int pidcounter = 0;
int cli_monitor(struct backend_conn * conn, int argc, char **argv) { int cli_monitor(struct backend_conn * conn, int argc, char **argv) {
int c, result; int c, result;
int countFlag = 0; int countFlag = 0;
int count, rate = 10; int count;
int forever = 0; int forever = 0;
static int needHelp = 0; static int needHelp = 0;
...@@ -96,33 +101,37 @@ int cli_monitor(struct backend_conn * conn, int argc, char **argv) { ...@@ -96,33 +101,37 @@ int cli_monitor(struct backend_conn * conn, int argc, char **argv) {
} }
int monitor(struct backend_conn * conn) { int monitor(struct backend_conn * conn) {
static struct frontend_pid_data pid_data[PID_NUM_PIDS] = {0};
/* Get tracker data */ /* Get tracker data */
struct frontend_tracker_data td; struct frontend_tracker_data td;
if (frontend_track(conn, &td)) { if (frontend_track(conn, &td)) {
errx(1, "Error reading tracker data"); errx(1, "Error reading tracker data");
} }
/* TODO: Get PID constants and status */ pid_data[pidcounter].controller = pidcounter;
/* It might be a good idea to only read the pid constants if (frontend_getpid(conn, &pid_data[pidcounter % PID_NUM_PIDS])) {
* every few seconds, so count iterations and only do it if errx(1, "Error reading pid values");
* this is every (rate * 2 or 3) pass through the loop }
*/
/* Print stuff on screen */ /* Print stuff on screen */
/* Assuming a tab width of 8 columns */ /* Assuming a tab width of 8 columns */
printf("\033[2J"); printf("\033[2J");
printf("STATUS: NA\n"); printf("STATUS: NA\n");
printf("CTRLR :\tP\tR\tY\tP_V\tR_V\tY_V\tH\tLAT\tLON\n"); printf("CTRLR :\tP\tR\tY\tP_V\tR_V\tY_V\tH\tLAT\tLON\n");
printf(" P :\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\n", printf(" P :\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\n",
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); pid_data[0].p, pid_data[1].p, pid_data[2].p, pid_data[3].p, pid_data[4].p,
pid_data[5].p, pid_data[6].p, pid_data[7].p, pid_data[8].p);
printf(" I :\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\n", printf(" I :\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\n",
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); pid_data[0].i, pid_data[1].i, pid_data[2].i, pid_data[3].i, pid_data[4].i,
pid_data[5].i, pid_data[6].i, pid_data[7].i, pid_data[8].i);
printf(" D :\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\n", printf(" D :\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\n",
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); pid_data[0].d, pid_data[1].d, pid_data[2].d, pid_data[3].d, pid_data[4].d,
pid_data[5].d, pid_data[6].d, pid_data[7].d, pid_data[8].d);
printf("PosAtt:\tH\tLAT\tLON\tP\tR\tY\n"); printf("PosAtt:\tH\tLAT\tLON\tP\tR\tY\n");
printf(" :\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\n", printf(" :\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\t%6.3lf\n",
td.height, td.lateral, td.longitudinal, td.height, td.lateral, td.longitudinal,
td.pitch, td.roll, td.yaw); td.pitch, td.roll, td.yaw);
pidcounter = ((pidcounter + 1) % PID_NUM_PIDS);
return 0; return 0;
} }
...@@ -35,13 +35,13 @@ int frontend_getpid( ...@@ -35,13 +35,13 @@ int frontend_getpid(
strncpy(line, "getyawp\ngetyawi\ngetyawd\n", 24); strncpy(line, "getyawp\ngetyawi\ngetyawd\n", 24);
break; break;
case PID_PITCH_RATE : case PID_PITCH_RATE :
strncpy(line, "getpitchratep\ngetpitchratei\ngetpitchrated\n", 33); strncpy(line, "getpitchratep\ngetpitchratei\ngetpitchrated\n", 42);
break; break;
case PID_ROLL_RATE : case PID_ROLL_RATE :
strncpy(line, "getrollratep\ngetrollratei\ngetrollrated\n", 30); strncpy(line, "getrollratep\ngetrollratei\ngetrollrated\n", 39);
break; break;
case PID_YAW_RATE : case PID_YAW_RATE :
strncpy(line, "getyawratep\ngetyawratei\ngetyawrated\n", 27); strncpy(line, "getyawratep\ngetyawratei\ngetyawrated\n", 36);
break; break;
case PID_HEIGHT : case PID_HEIGHT :
strncpy(line, "getheightp\ngetheighti\ngetheightd\n", 33); strncpy(line, "getheightp\ngetheighti\ngetheightd\n", 33);
......
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