#include <stdio.h> #include <string.h> #include <stdlib.h> #include "frontend_getpid.h" #include "pid_common.h" /* Get a specified PID. * * Example: * * struct frontend_pid_data pid_data; * pid_data.pid = PID_PITCH; * if (frontend_getpid(conn, &pid_data)) { * error * } else { * pid_data.p, pid_data.i, and pid_data.d are filled * } * * Returns 0 on success, 1 on error */ int frontend_getpid( struct backend_conn * conn, struct frontend_pid_data * pid_data) { char line[100] = ""; switch (pid_data->controller) { case PID_PITCH : strncpy(line, "getpitchp\ngetpitchd\n", 20); break; case PID_ROLL : strncpy(line, "getrollp\ngetrolld\n", 18); break; case PID_YAW : strncpy(line, "getyawp\ngetyawd\n", 17); break; default : return 1; } int size; if((size = ucart_backendWrite(conn, line)) < 0 ) { return 1; } return 0; }