Newer
Older
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/* Get a specified PID.
*
* Example:
*
* struct frontend_pid_data pid_data;
* pid_data.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[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");