diff --git a/groundStation/src/backend/backend.c b/groundStation/src/backend/backend.c index 7d6af37b94f233d03603dc1b28a46ad677e3faed..82f698e2b9be6d5cd71dc600cc867a6707971be1 100644 --- a/groundStation/src/backend/backend.c +++ b/groundStation/src/backend/backend.c @@ -103,7 +103,7 @@ struct ucart_vrpn_tracker * tracker = NULL; #define MAX_CLIENTS 32 #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 int client_fds[MAX_CLIENTS]; static int client_pending_responses[MAX_CLIENTS][CLIENT_MAX_PENDING_RESPONSES]; diff --git a/groundStation/src/cli/cli_monitor.c b/groundStation/src/cli/cli_monitor.c index 2703b62ee49144794c0b80f1671df727eb0281c0..8242c45a0a2801599df2d30d948e3341179b8dda 100644 --- a/groundStation/src/cli/cli_monitor.c +++ b/groundStation/src/cli/cli_monitor.c @@ -9,11 +9,16 @@ #include "cli_monitor.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 c, result; int countFlag = 0; - int count, rate = 10; + int count; int forever = 0; static int needHelp = 0; @@ -96,33 +101,37 @@ int cli_monitor(struct backend_conn * conn, int argc, char **argv) { } int monitor(struct backend_conn * conn) { + static struct frontend_pid_data pid_data[PID_NUM_PIDS] = {0}; /* Get tracker data */ struct frontend_tracker_data td; + if (frontend_track(conn, &td)) { errx(1, "Error reading tracker data"); } - /* TODO: Get PID constants and status */ - /* It might be a good idea to only read the pid constants - * every few seconds, so count iterations and only do it if - * this is every (rate * 2 or 3) pass through the loop - */ - + pid_data[pidcounter].controller = pidcounter; + if (frontend_getpid(conn, &pid_data[pidcounter % PID_NUM_PIDS])) { + errx(1, "Error reading pid values"); + } /* Print stuff on screen */ /* Assuming a tab width of 8 columns */ printf("\033[2J"); printf("STATUS: NA\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", - 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", - 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", - 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(" :\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.pitch, td.roll, td.yaw); - + + pidcounter = ((pidcounter + 1) % PID_NUM_PIDS); return 0; } diff --git a/groundStation/src/frontend/frontend_getpid.c b/groundStation/src/frontend/frontend_getpid.c index 56188a2427199b1f96dce02245b367b715e635c2..2fd33c31116bf135a3c1f78cf94b2353bdbb8820 100644 --- a/groundStation/src/frontend/frontend_getpid.c +++ b/groundStation/src/frontend/frontend_getpid.c @@ -35,13 +35,13 @@ int frontend_getpid( strncpy(line, "getyawp\ngetyawi\ngetyawd\n", 24); break; case PID_PITCH_RATE : - strncpy(line, "getpitchratep\ngetpitchratei\ngetpitchrated\n", 33); + strncpy(line, "getpitchratep\ngetpitchratei\ngetpitchrated\n", 42); break; case PID_ROLL_RATE : - strncpy(line, "getrollratep\ngetrollratei\ngetrollrated\n", 30); + strncpy(line, "getrollratep\ngetrollratei\ngetrollrated\n", 39); break; case PID_YAW_RATE : - strncpy(line, "getyawratep\ngetyawratei\ngetyawrated\n", 27); + strncpy(line, "getyawratep\ngetyawratei\ngetyawrated\n", 36); break; case PID_HEIGHT : strncpy(line, "getheightp\ngetheighti\ngetheightd\n", 33);