diff --git a/groundStation/src/backend/backend.c b/groundStation/src/backend/backend.c index 3164913674fb7f71b7460ad5d93868e719a06eb0..2ae5219f759dc07013a31f06c0fa708f3206128e 100644 --- a/groundStation/src/backend/backend.c +++ b/groundStation/src/backend/backend.c @@ -221,31 +221,7 @@ int main(int argc, char **argv) } if (fd == fileno(stdin)) { - // break; - // unsigned char userCommand[CMD_MAX_LENGTH]; - // read(fileno(stdin), (char *)userCommand, sizeof(userCommand)); - // unsigned int cmdLen = strlen((char*) userCommand); - // // if the user simply hit enter then let them try again - // if((userCommand[0] != '\n') && (userCommand[0] != '\r')) - // { - // // remove newline and return line chars - // if((userCommand[cmdLen - 1] == '\n') || (userCommand[cmdLen - 1] == '\r')) - // userCommand[cmdLen - 1] = '\0'; - - // unsigned char *packet; - // formatCommand(userCommand, &packet); - - // printf("received input from cli: '%s'\n", userCommand); - - // // Write the command to the control_loop socket - // // int n = writeQuad(packet, ((packet[6] << 8) | packet[5]) + 8); - // // if(n < 0) { - // // printf("CLI: ERROR writing to socket\n"); - // // } - // } - // printf("$microcart> "); - // memset(userCommand, 0, cmdLen); } else if (fd == zyboSocket) { // Read the response from the control loop int available; @@ -281,6 +257,7 @@ int main(int argc, char **argv) } } } else if (get_client_index(fd) > -1) { + printf("receiving from client\n"); client_recv(fd); } } diff --git a/groundStation/src/backend/commands.c b/groundStation/src/backend/commands.c index cdbbbe8a1ea4b240d71f3dd0390ac60005e749d9..708a6ac98a154648d90b1e9ffbf7460d0ed15710 100644 --- a/groundStation/src/backend/commands.c +++ b/groundStation/src/backend/commands.c @@ -55,7 +55,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &yawset + &setyaw }, // yaw p constant subtype { @@ -66,7 +66,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &yawp + &setyawp }, // yaw d constant subtype { @@ -77,7 +77,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &yawd + &setyawd }, // roll setpoint subtype { @@ -88,7 +88,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &rollset + &setroll }, // roll p constant subtype { @@ -99,7 +99,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &rollp + &setrollp }, // roll d constant subtype { @@ -110,7 +110,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &rolld + &setrolld }, // pitch setpoint subtype { @@ -121,7 +121,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &pitchset + &setpitch }, // pitch p constant subtype { @@ -132,7 +132,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &pitchp + &setpitchp }, // pitch d constant subtype { @@ -143,7 +143,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &pitchd + &setpitchd }, // throttle setpoint subtype { @@ -154,7 +154,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &throttleset + &setthrottle }, // throttle p constant subtype { @@ -165,7 +165,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &throttlep + &setthrottlep }, // throttle i constant subtype { @@ -176,7 +176,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &throttlei + &setthrottlei }, // throttle d constant subtype { @@ -187,7 +187,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &throttled + &getthrottled } } }, @@ -204,44 +204,187 @@ struct MessageType MessageTypes[MAX_TYPE] = // ID 0x00, // Command text - "accelreq", + "getaccel", // Type of the command data floatType, // Function pointer - &accelreq + &getaccel }, // gyroscope subtype { // ID 0x01, // Command text - "gyroreq", + "getgyro", // Type of the command data floatType, // Function pointer - &gyroreq + &getgyro }, // pitch angle subtype { // ID 0x02, // Command text - "reqpitchangle", + "getpitchangle", // Type of the command data floatType, // Function pointer - &pitchanglereq + &getpitchangle }, // roll angle subtype { // ID 0x03, // Command text - "reqrollangle", + "getrollangle", // Type of the command data floatType, // Function pointer - &rollanglereq + &getrollangle + }, + // get yaw setpoint subtype + { + // ID + 0x04, + // Command text + "getyaw", + // Type of the command data + floatType, + // Function pointer + &setyaw + }, + // get yaw p constant subtype + { + // ID + 0x05, + // Command text + "getyawp", + // Type of the command data + floatType, + // Function pointer + &getyawp + }, + // get yaw d constant subtype + { + // ID + 0x06, + // Command text + "getyawd", + // Type of the command data + floatType, + // Function pointer + &getyawd + }, + // get roll setpoint subtype + { + // ID + 0x07, + // Command text + "getroll", + // Type of the command data + floatType, + // Function pointer + &getroll + }, + // get roll p constant subtype + { + // ID + 0x08, + // Command text + "getrollp", + // Type of the command data + floatType, + // Function pointer + &getrollp + }, + // getroll d constant subtype + { + // ID + 0x09, + // Command text + "getrolld", + // Type of the command data + floatType, + // Function pointer + &getrolld + }, + // get pitch setpoint subtype + { + // ID + 0x0A, + // Command text + "getpitch", + // Type of the command data + floatType, + // Function pointer + &getpitch + }, + // get pitch p constant subtype + { + // ID + 0x0B, + // Command text + "getpitchp", + // Type of the command data + floatType, + // Function pointer + &getpitchp + }, + // get pitch d constant subtype + { + // ID + 0x0C, + // Command text + "getpitchd", + // Type of the command data + floatType, + // Function pointer + &getpitchd + }, + // get throttle setpoint subtype + { + // ID + 0x0D, + // Command text + "getthrottle", + // Type of the command data + floatType, + // Function pointer + &getthrottle + }, + // get throttle p constant subtype + { + // ID + 0x0E, + // Command text + "getthrottlep", + // Type of the command data + floatType, + // Function pointer + &getthrottlep + }, + // get throttle i constant subtype + { + // ID + 0x0F, + // Command text + "getthrottlei", + // Type of the command data + floatType, + // Function pointer + &getthrottlei + }, + // get throttle d constant subtype + { + // ID + 0x10, + // Command text + "getthrottled", + // Type of the command data + floatType, + // Function pointer + &getthrottled } } }, @@ -262,7 +405,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &accelresp + &respaccel }, // gyroscope subtype { @@ -273,7 +416,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &gyroresp + &respgyro }, // pitch angle subtype { @@ -284,7 +427,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &pitchangleresp + &resppitchangle }, // roll angle subtype { @@ -295,7 +438,7 @@ struct MessageType MessageTypes[MAX_TYPE] = // Type of the command data floatType, // Function pointer - &rollangleresp + &resprollangle } } }, @@ -412,7 +555,7 @@ int response(unsigned char *packet, int dataLen, modular_structs_t *structs) // ------------------------------------------------------------------ -int yawset(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setyaw(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; @@ -422,203 +565,243 @@ int yawset(unsigned char *packet, int dataLen, modular_structs_t *structs) structs->setpoint_struct.desiredQuadPosition.yaw = value; - printf("function for yawset: %f\n", structs->setpoint_struct.desiredQuadPosition.yaw); + printf("function for setyaw: %f\n", structs->setpoint_struct.desiredQuadPosition.yaw); return 0; } -int yawp(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setyawp(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; memcpy(&value, ((float *)packet), dataLen); structs->parameter_struct.yaw_angle_pid.Kp = value; - printf("function for yawp: %f\n", structs->parameter_struct.yaw_angle_pid.Kp); + printf("function for setyawp: %f\n", structs->parameter_struct.yaw_angle_pid.Kp); return 0; } -int yawd(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setyawd(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; memcpy(&value, ((float *)packet), dataLen); structs->parameter_struct.yaw_angle_pid.Kd = value; - printf("function for yawd: %f\n", structs->parameter_struct.yaw_angle_pid.Kd); + printf("function for setyawd: %f\n", structs->parameter_struct.yaw_angle_pid.Kd); return 0; } -int rollset(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setroll(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; memcpy(&value, ((float *)packet), dataLen); structs->setpoint_struct.desiredQuadPosition.roll = value; - printf("function for rollset: %f\n", structs->setpoint_struct.desiredQuadPosition.roll); + printf("function for setroll: %f\n", structs->setpoint_struct.desiredQuadPosition.roll); return 0; } -int rollp(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setrollp(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; memcpy(&value, ((float *)packet), dataLen); structs->parameter_struct.local_y_pid.Kp = value; - printf("function for rollp: %f\n", structs->parameter_struct.local_y_pid.Kp); + printf("function for setrollp: %f\n", structs->parameter_struct.local_y_pid.Kp); return 0; } -int rolld(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setrolld(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; memcpy(&value, ((float *)packet), dataLen); structs->parameter_struct.local_y_pid.Kd = value; - printf("function for rolld: %f\n", structs->parameter_struct.local_y_pid.Kd); + printf("function for setrolld: %f\n", structs->parameter_struct.local_y_pid.Kd); return 0; } -int pitchset(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setpitch(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; memcpy(&value, ((float *)packet), dataLen); structs->setpoint_struct.desiredQuadPosition.pitch = value; - printf("function for pitchset: %f\n", structs->setpoint_struct.desiredQuadPosition.pitch); + printf("function for setpitch: %f\n", structs->setpoint_struct.desiredQuadPosition.pitch); return 0; } -int pitchp(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setpitchp(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; memcpy(&value, ((float *)packet), dataLen); structs->parameter_struct.local_x_pid.Kp = value; - printf("function for pitchp: %f\n", structs->parameter_struct.local_x_pid.Kp); + printf("function for setpitchp: %f\n", structs->parameter_struct.local_x_pid.Kp); return 0; } -int pitchd(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setpitchd(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; memcpy(&value, ((float *)packet), dataLen); structs->parameter_struct.local_x_pid.Kd = value; - printf("function for pitchd: %f\n", structs->parameter_struct.local_x_pid.Kd); + printf("function for setpitchd: %f\n", structs->parameter_struct.local_x_pid.Kd); return 0; } // ------------------------------------------------------------ // These should be renamed to altitude! -int throttleset(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setthrottle(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; memcpy(&value, ((float *)packet), dataLen); structs->setpoint_struct.desiredQuadPosition.alt_pos = value; - printf("function for throttleset: %f\n", structs->setpoint_struct.desiredQuadPosition.alt_pos); + printf("function for setthrottle: %f\n", structs->setpoint_struct.desiredQuadPosition.alt_pos); return 0; } -int throttlep(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setthrottlep(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; memcpy(&value, ((float *)packet), dataLen); structs->parameter_struct.alt_pid.Kp = value; - printf("function for throttlep: %f\n", structs->parameter_struct.alt_pid.Kp); + printf("function for setthrottlep: %f\n", structs->parameter_struct.alt_pid.Kp); return 0; } -int throttlei(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setthrottlei(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; memcpy(&value, ((float *)packet), dataLen); structs->parameter_struct.alt_pid.Ki = value; - printf("function for throttlei: %f\n", structs->parameter_struct.alt_pid.Ki); + printf("function for setthrottlei: %f\n", structs->parameter_struct.alt_pid.Ki); return 0; } -int throttled(unsigned char *packet, int dataLen, modular_structs_t *structs) +int setthrottled(unsigned char *packet, int dataLen, modular_structs_t *structs) { float value; memcpy(&value, ((float *)packet), dataLen); structs->parameter_struct.alt_pid.Kd = value; - printf("function for throttled: %f\n", structs->parameter_struct.alt_pid.Kd); + printf("function for setthrottled: %f\n", structs->parameter_struct.alt_pid.Kd); return 0; } +int getyaw(unsigned char *packet, int dataLen, modular_structs_t *structs){ + return 0; +} +int getyawp(unsigned char *packet, int dataLen, modular_structs_t *structs){ + return 0; +} +int getyawd(unsigned char *packet, int dataLen, modular_structs_t *structs) { + return 0; +} +int getroll(unsigned char *packet, int dataLen, modular_structs_t *structs){ + return 0; +} +int getrollp(unsigned char *packet, int dataLen, modular_structs_t *structs){ + return 0; +} +int getrolld(unsigned char *packet, int dataLen, modular_structs_t *structs){ + return 0; +} +int getpitch(unsigned char *packet, int dataLen, modular_structs_t *structs){ + return 0; +} +int getpitchp(unsigned char *packet, int dataLen, modular_structs_t *structs){ + return 0; +} +int getpitchd(unsigned char *packet, int dataLen, modular_structs_t *structs){ + return 0; +} +int getthrottle(unsigned char *packet, int dataLen, modular_structs_t *structs){ + return 0; +} +int getthrottlep(unsigned char *packet, int dataLen, modular_structs_t *structs){ + return 0; +} +int getthrottlei(unsigned char *packet, int dataLen, modular_structs_t *structs){ + return 0; +} +int getthrottled(unsigned char *packet, int dataLen, modular_structs_t *structs){ + return 0; +} + // These should be renamed to altitude! // ------------------------------------------------------------ -int accelreq(unsigned char *packet, int dataLen, modular_structs_t *structs) +int getaccel(unsigned char *packet, int dataLen, modular_structs_t *structs) { - printf("function for accelreq\n"); + printf("function for getaccel\n"); return 0; } -int gyroresp(unsigned char *packet, int dataLen, modular_structs_t *structs) +int respgyro(unsigned char *packet, int dataLen, modular_structs_t *structs) { - printf("function for accelreq\n"); + printf("function for respgyro\n"); return 0; } -int pitchangleresp(unsigned char *packet, int dataLen, modular_structs_t *structs) +int resppitchangle(unsigned char *packet, int dataLen, modular_structs_t *structs) { - printf("function for accelreq\n"); + printf("function for resppitchangle\n"); return 0; } -int rollangleresp(unsigned char *packet, int dataLen, modular_structs_t *structs) +int resprollangle(unsigned char *packet, int dataLen, modular_structs_t *structs) { - printf("function for accelreq\n"); + printf("function for resprollangle\n"); return 0; } -int gyroreq(unsigned char *packet, int dataLen, modular_structs_t *structs) +int getgyro(unsigned char *packet, int dataLen, modular_structs_t *structs) { - printf("function for accelreq\n"); + printf("function for getgyro\n"); return 0; } -int pitchanglereq(unsigned char *packet, int dataLen, modular_structs_t *structs) +int getpitchangle(unsigned char *packet, int dataLen, modular_structs_t *structs) { - printf("function for accelreq\n"); + printf("function for getpitchangle\n"); return 0; } -int rollanglereq(unsigned char *packet, int dataLen, modular_structs_t *structs) +int getrollangle(unsigned char *packet, int dataLen, modular_structs_t *structs) { - printf("function for accelreq\n"); + printf("function for getrollangle\n"); return 0; } -int accelresp(unsigned char *packet, int dataLen, modular_structs_t *structs) +int respaccel(unsigned char *packet, int dataLen, modular_structs_t *structs) { - printf("function for accelreq\n"); + printf("function for respaccel\n"); return 0; } \ No newline at end of file diff --git a/groundStation/src/backend/commands.h b/groundStation/src/backend/commands.h index 51c82bd705c6819b27c4ca27e7a74aed369344b7..3bb62fd8d84800ceb7710ad1a7a0c1b641029a19 100644 --- a/groundStation/src/backend/commands.h +++ b/groundStation/src/backend/commands.h @@ -44,27 +44,40 @@ int debug(unsigned char *c, int dataLen, modular_structs_t *structs); int update(unsigned char *c, int dataLen, modular_structs_t *structs); int logdata(unsigned char *c, int dataLen, modular_structs_t *structs); int response(unsigned char *packet, int dataLen, modular_structs_t *structs); -int yawset(unsigned char *c, int dataLen, modular_structs_t *structs); -int yawp(unsigned char *c, int dataLen, modular_structs_t *structs); -int yawd(unsigned char *c, int dataLen, modular_structs_t *structs); -int rollset(unsigned char *c, int dataLen, modular_structs_t *structs); -int rollp(unsigned char *c, int dataLen, modular_structs_t *structs); -int rolld(unsigned char *c, int dataLen, modular_structs_t *structs); -int pitchset(unsigned char *c, int dataLen, modular_structs_t *structs); -int pitchp(unsigned char *c, int dataLen, modular_structs_t *structs); -int pitchd(unsigned char *c, int dataLen, modular_structs_t *structs); -int throttleset(unsigned char *c, int dataLen, modular_structs_t *structs); -int throttlep(unsigned char *c, int dataLen, modular_structs_t *structs); -int throttlei(unsigned char *c, int dataLen, modular_structs_t *structs); -int throttled(unsigned char *c, int dataLen, modular_structs_t *structs); -int accelreq(unsigned char *c, int dataLen, modular_structs_t *structs); -int gyroresp(unsigned char *c, int dataLen, modular_structs_t *structs); -int pitchangleresp(unsigned char *c, int dataLen, modular_structs_t *structs); -int rollangleresp(unsigned char *c, int dataLen, modular_structs_t *structs); -int gyroreq(unsigned char *c, int dataLen, modular_structs_t *structs); -int pitchanglereq(unsigned char *c, int dataLen, modular_structs_t *structs); -int rollanglereq(unsigned char *c, int dataLen, modular_structs_t *structs); -int accelresp(unsigned char *c, int dataLen, modular_structs_t *structs); +int setyaw(unsigned char *c, int dataLen, modular_structs_t *structs); +int setyawp(unsigned char *c, int dataLen, modular_structs_t *structs); +int setyawd(unsigned char *c, int dataLen, modular_structs_t *structs); +int setroll(unsigned char *c, int dataLen, modular_structs_t *structs); +int setrollp(unsigned char *c, int dataLen, modular_structs_t *structs); +int setrolld(unsigned char *c, int dataLen, modular_structs_t *structs); +int setpitch(unsigned char *c, int dataLen, modular_structs_t *structs); +int setpitchp(unsigned char *c, int dataLen, modular_structs_t *structs); +int setpitchd(unsigned char *c, int dataLen, modular_structs_t *structs); +int setthrottle(unsigned char *c, int dataLen, modular_structs_t *structs); +int setthrottlep(unsigned char *c, int dataLen, modular_structs_t *structs); +int setthrottlei(unsigned char *c, int dataLen, modular_structs_t *structs); +int setthrottled(unsigned char *c, int dataLen, modular_structs_t *structs); +int getyaw(unsigned char *c, int dataLen, modular_structs_t *structs); +int getyawp(unsigned char *c, int dataLen, modular_structs_t *structs); +int getyawd(unsigned char *c, int dataLen, modular_structs_t *structs); +int getroll(unsigned char *c, int dataLen, modular_structs_t *structs); +int getrollp(unsigned char *c, int dataLen, modular_structs_t *structs); +int getrolld(unsigned char *c, int dataLen, modular_structs_t *structs); +int getpitch(unsigned char *c, int dataLen, modular_structs_t *structs); +int getpitchp(unsigned char *c, int dataLen, modular_structs_t *structs); +int getpitchd(unsigned char *c, int dataLen, modular_structs_t *structs); +int getthrottle(unsigned char *c, int dataLen, modular_structs_t *structs); +int getthrottlep(unsigned char *c, int dataLen, modular_structs_t *structs); +int getthrottlei(unsigned char *c, int dataLen, modular_structs_t *structs); +int getthrottled(unsigned char *c, int dataLen, modular_structs_t *structs); +int getaccel(unsigned char *c, int dataLen, modular_structs_t *structs); +int respgyro(unsigned char *c, int dataLen, modular_structs_t *structs); +int resppitchangle(unsigned char *c, int dataLen, modular_structs_t *structs); +int resprollangle(unsigned char *c, int dataLen, modular_structs_t *structs); +int getgyro(unsigned char *c, int dataLen, modular_structs_t *structs); +int getpitchangle(unsigned char *c, int dataLen, modular_structs_t *structs); +int getrollangle(unsigned char *c, int dataLen, modular_structs_t *structs); +int respaccel(unsigned char *c, int dataLen, modular_structs_t *structs); float getFloat(unsigned char* str, int pos); int getInt(unsigned char* str, int pos); diff --git a/groundStation/src/cli/cli.c b/groundStation/src/cli/cli.c index 17d9f8c8a865f9ae6f3705226cc53af54e161a06..556c6d649d3c12eddb59aca052e7c2a7cceb656e 100644 --- a/groundStation/src/cli/cli.c +++ b/groundStation/src/cli/cli.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <string.h> #include <err.h> +#include <unistd.h> #include "cli.h" @@ -46,6 +47,7 @@ int main(int argc, char **argv) }else { (*cli_functions[0]) (conn, argc-1, &argv[1]); } + sleep(1); ucart_backendDisconnect(conn); return 0; diff --git a/groundStation/src/frontend/frontend_common.c b/groundStation/src/frontend/frontend_common.c index 81e0c2eef2e8bf2ab84378fde6e6a6be39c46130..4fbe4f27992db4dd078e3e203a321529885a0f3f 100644 --- a/groundStation/src/frontend/frontend_common.c +++ b/groundStation/src/frontend/frontend_common.c @@ -43,14 +43,12 @@ struct backend_conn * ucart_backendConnect() goto fail_final; } - conn = malloc(sizeof(struct backend_conn)); if (conn == NULL) { perror("malloc"); goto fail_sock; } - conn->len = 0; conn->buf = NULL; conn->socket = fdopen(s, "rw"); @@ -86,7 +84,7 @@ char * ucart_backendGetline(struct backend_conn *conn) return conn->buf; } -size_t ucart_backendWrite(struct backend_conn *conn, const char * line) +int ucart_backendWrite(struct backend_conn *conn, const char * line) { return fputs(line, conn->socket); } diff --git a/groundStation/src/frontend/frontend_common.h b/groundStation/src/frontend/frontend_common.h index 095c06b817cf21483c1cfa957106c20f65a4ebd3..c8ea7877190c29ff41f02f9aa92a3987c80e2de6 100644 --- a/groundStation/src/frontend/frontend_common.h +++ b/groundStation/src/frontend/frontend_common.h @@ -17,6 +17,6 @@ void ucart_backendDisconnect(struct backend_conn * conn); char * ucart_backendGetline(struct backend_conn * conn); /* Write a line to the backend */ -size_t ucart_backendWrite(struct backend_conn * backend, const char * line); +int ucart_backendWrite(struct backend_conn * backend, const char * line); #endif diff --git a/groundStation/src/frontend/frontend_getpid.c b/groundStation/src/frontend/frontend_getpid.c index 8143f94006422f671e230d3213d4cd0bfb3ab74e..c1bb9b46444ad7e5dbd037c34747d51c6a040c94 100644 --- a/groundStation/src/frontend/frontend_getpid.c +++ b/groundStation/src/frontend/frontend_getpid.c @@ -1,4 +1,9 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + #include "frontend_getpid.h" +#include "pid_common.h" /* Get a specified PID. * @@ -16,5 +21,32 @@ */ int frontend_getpid( struct backend_conn * conn, struct frontend_pid_data * pid_data) { + + char line[10] = "getpid \0"; + char pid_option[2]; + switch (pid_data->pid) { + case PITCH : + strncpy(pid_option, "p\0", 2); + break; + case ROLL : + strncpy(pid_option, "i\0", 2); + break; + case YAW : + strncpy(pid_option, "d\0", 2); + break; + default : + return 1; + } + + strncat(line, pid_option, 2); + + int size; + if((size = ucart_backendWrite(conn, line)) < 0 ) { + printf("nope! %d \n", size); + return 1; + } + + printf("we send size bytes\n"); + return 0; -} \ No newline at end of file +} \ No newline at end of file