From bd916f39a718c342dc40e0a69ad5f1ff87090fb6 Mon Sep 17 00:00:00 2001 From: Jake Drahos <j@kedrahos.com> Date: Thu, 10 Nov 2016 13:03:51 -0600 Subject: [PATCH] Added basic frontend_getpid.h --- groundStation/src/frontend/frontend_common.h | 3 ++- groundStation/src/frontend/frontend_getpid.h | 26 ++++++++++++++++++++ groundStation/src/frontend/pid_common.h | 20 +++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 groundStation/src/frontend/frontend_getpid.h create mode 100644 groundStation/src/frontend/pid_common.h diff --git a/groundStation/src/frontend/frontend_common.h b/groundStation/src/frontend/frontend_common.h index dd2eb7e3b..095c06b81 100644 --- a/groundStation/src/frontend/frontend_common.h +++ b/groundStation/src/frontend/frontend_common.h @@ -1,5 +1,6 @@ #ifndef FRONTEND_COMMON_H #define FRONTEND_COMMON_H +#include <stdlib.h> struct backend_conn; @@ -16,6 +17,6 @@ void ucart_backendDisconnect(struct backend_conn * conn); char * ucart_backendGetline(struct backend_conn * conn); /* Write a line to the backend */ -void ucart_backendWrite(struct backend_conn * backend, const char * line); +size_t ucart_backendWrite(struct backend_conn * backend, const char * line); #endif diff --git a/groundStation/src/frontend/frontend_getpid.h b/groundStation/src/frontend/frontend_getpid.h new file mode 100644 index 000000000..977ae97f3 --- /dev/null +++ b/groundStation/src/frontend/frontend_getpid.h @@ -0,0 +1,26 @@ +#ifndef FRONTEND_GETPID_H +#define FRONTEND_GETPID_H + +#include "frontend_common.h" +#include "pid_common.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); + + +#endif diff --git a/groundStation/src/frontend/pid_common.h b/groundStation/src/frontend/pid_common.h new file mode 100644 index 000000000..c1dac6535 --- /dev/null +++ b/groundStation/src/frontend/pid_common.h @@ -0,0 +1,20 @@ +#ifndef PID_COMMON_H +#define PID_COMMON_H + +enum frontend_pid { + PITCH, + ROLL, + YAW, + NUM_PIDS +}; + +struct frontend_pid_data { + enum frontend_pid pid; + + float p; + float i; + float d; +}; + + +#endif -- GitLab