diff --git a/groundStation/src/backend/backend.c b/groundStation/src/backend/backend.c index 4ad1e7d95b96b7cf0b02d6feb2b340d56b419293..006ef0a9ae54ad40fb4c9993d2ec8f16ccb73145 100644 --- a/groundStation/src/backend/backend.c +++ b/groundStation/src/backend/backend.c @@ -34,7 +34,7 @@ #include "vrpn_tracker.hpp" #include "type_def.h" #include "packet.h" -#include "respcontrol.h" +#include "response.h" #include "update.h" #include "config.h" #include "cmHandler.h" @@ -77,7 +77,7 @@ static void quad_recv(); /* Checks to see if socket has disconnected. Returns 1 on disconnect, else returns 0 */ static int wasDisconnected(int fd); /* handle controller responses from quad to frontend */ -static void handleRespcontrol(struct metadata *m, uint8_t * data); +static void handleResponse(struct metadata *m, uint8_t * data); /* Thread-safe wrappers */ @@ -715,18 +715,18 @@ static void quad_recv() { printf("(Backend): Command '%s' ignored\n", MessageTypes[m.msg_type].cmdText); break; case RESPONSE_ID: - handleRespcontrol(&m, data); + handleResponse(&m, data); break; default: printf("(Backend): message type %d unrecognized\n", m.msg_type); } } -static void handleRespcontrol(struct metadata *m, uint8_t * data) +static void handleResponse(struct metadata *m, uint8_t * data) { struct controller_message cm; - if (DecodeRespcontrol(&cm, m, data) < 0) { - warnx("DecodeRespcontrol error"); + if (DecodeResponse(&cm, m, data) < 0) { + warnx("DecodeResponse error"); return; } diff --git a/groundStation/src/backend/getcontrol.h b/groundStation/src/backend/getcontrol.h deleted file mode 100644 index edbb8508184aad71ab392848d605cbac530b2a38..0000000000000000000000000000000000000000 --- a/groundStation/src/backend/getcontrol.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _getcontrol_h -#define _getcontrol_h - -#include "packet.h" -#include "controller.h" - -#include <sys/types.h> - - -/* Creates data and metadata for a getcontrol packet. - * Returns data size. - */ -ssize_t EncodeGetcontrol( - struct metadata *m, /* Out */ - uint8_t *data, /* Out */ - size_t data_size, /* Data buffer max size */ - const struct controller_message *cm); /* Value is not used; only IDs */ - -/* Decode a metadata and data to populate a message - * Returns 0 on success, -1 on failure - */ -int DecodeGetcontrol( - struct controller_message *cm, /* Out. Value is undefined */ - const struct metadata *m, /* In */ - const uint8_t * data); /* In */ - - -#endif diff --git a/groundStation/src/backend/getparam.c b/groundStation/src/backend/getparam.c index f20c5e17cec42317a429fe233a56991f7414557e..34c90fa289f35361d49a8b6e1920581b81b3b2a3 100644 --- a/groundStation/src/backend/getparam.c +++ b/groundStation/src/backend/getparam.c @@ -1,46 +1,46 @@ -#include "getcontrol.h" +#include "getparam.h" #include "commands.h" #include "bitwise.h" #include <sys/types.h> -enum GetcontrolData { +enum GetparamData { CTRL_ID, CTRLVAL_ID, - GC_DATA_SIZE + GP_DATA_SIZE }; /* Creates data and metadata for a respcontrol packet * Returns data size. */ -ssize_t EncodeGetcontrol( +ssize_t EncodeGetparam( struct metadata * m, /* data_len and msg_type will be populated*/ uint8_t * data, /* Output buffer */ size_t data_size, /* Max buffer size */ const struct controller_message * cm) /* Message to encode */ { m->msg_type = GETPARAM_ID; - m->data_len = GC_DATA_SIZE; + m->data_len = GP_DATA_SIZE; - if (data_size < GC_DATA_SIZE) { + if (data_size < GP_DATA_SIZE) { return -1; } data[CTRL_ID] = cm->id; data[CTRLVAL_ID] = cm->value_id; - return GC_DATA_SIZE; + return GP_DATA_SIZE; } /* Decode a metadata and data to populate a controller. * Returns 0 on success, -1 on failure. */ -int DecodeGetcontrol( +int DecodeGetparam( struct controller_message * cm, /* Decoded controller message */ const struct metadata * m, /* Metadata to aid in decoding */ const uint8_t * data) /* Data to decode */ { - if (m->data_len < GC_DATA_SIZE) { + if (m->data_len < GP_DATA_SIZE) { return -1; } if (m->msg_type != GETPARAM_ID) { diff --git a/groundStation/src/backend/getparam.h b/groundStation/src/backend/getparam.h index edbb8508184aad71ab392848d605cbac530b2a38..c9d9096df464aae6e802e68f9a84236f99009c16 100644 --- a/groundStation/src/backend/getparam.h +++ b/groundStation/src/backend/getparam.h @@ -1,5 +1,5 @@ -#ifndef _getcontrol_h -#define _getcontrol_h +#ifndef _getparam_h +#define _getparam_h #include "packet.h" #include "controller.h" @@ -10,7 +10,7 @@ /* Creates data and metadata for a getcontrol packet. * Returns data size. */ -ssize_t EncodeGetcontrol( +ssize_t EncodeGetparam( struct metadata *m, /* Out */ uint8_t *data, /* Out */ size_t data_size, /* Data buffer max size */ @@ -19,7 +19,7 @@ ssize_t EncodeGetcontrol( /* Decode a metadata and data to populate a message * Returns 0 on success, -1 on failure */ -int DecodeGetcontrol( +int DecodeGetparam( struct controller_message *cm, /* Out. Value is undefined */ const struct metadata *m, /* In */ const uint8_t * data); /* In */ diff --git a/groundStation/src/backend/response.c b/groundStation/src/backend/response.c index 604eb589949115ead608ae51240dd67b35300bf8..c85f5e4017b9f2844bc8545c104e4a28dfc95c92 100644 --- a/groundStation/src/backend/response.c +++ b/groundStation/src/backend/response.c @@ -1,32 +1,32 @@ -#include "respcontrol.h" +#include "response.h" #include "commands.h" #include "bitwise.h" #include <sys/types.h> -enum RespcontrolData { +enum ResponseData { CTRL_ID, CTRLVAL_ID, VAL_1, VAL_2, VAL_3, VAL_4, - RC_DATA_SIZE + RESP_DATA_SIZE }; /* Creates data and metadata for a respcontrol packet * Returns data size. */ -ssize_t EncodeRespcontrol( +ssize_t EncodeResponse( struct metadata * m, /* data_len and msg_type will be populated*/ uint8_t * data, /* Output buffer */ size_t data_size, /* Max buffer size */ const struct controller_message * cm) /* Message to encode */ { m->msg_type = RESPONSE_ID; - m->data_len = RC_DATA_SIZE; + m->data_len = RESP_DATA_SIZE; - if (data_size < RC_DATA_SIZE) { + if (data_size < RESP_DATA_SIZE) { return -1; } @@ -37,18 +37,18 @@ ssize_t EncodeRespcontrol( data[VAL_3] = FloatByte3(cm->value); data[VAL_4] = FloatByte4(cm->value); - return RC_DATA_SIZE; + return RESP_DATA_SIZE; } /* Decode a metadata and data to populate a controller. * Returns 0 on success, -1 on failure. */ -int DecodeRespcontrol( +int DecodeResponse( struct controller_message * cm, /* Decoded controller message */ const struct metadata * m, /* Metadata to aid in decoding */ const uint8_t * data) /* Data to decode */ { - if (m->data_len < RC_DATA_SIZE) { + if (m->data_len < RESP_DATA_SIZE) { return -1; } if (m->msg_type != RESPONSE_ID) { diff --git a/groundStation/src/backend/response.h b/groundStation/src/backend/response.h index a23c22550971dc0ccbe98727cbd6255b82c0627b..565458a8f11e9b5b592049f8bd65b2de523c7287 100644 --- a/groundStation/src/backend/response.h +++ b/groundStation/src/backend/response.h @@ -1,5 +1,5 @@ -#ifndef _respcontrol_h -#define _respcontrol_h +#ifndef _response_h +#define _response_h #include "packet.h" #include "controller.h" @@ -10,7 +10,7 @@ /* Creates data and metadata for a respcontrol packet. * Returns data size. */ -ssize_t EncodeRespcontrol( +ssize_t EncodeResponse( struct metadata *m, /* Out */ uint8_t *data, /* Out */ size_t data_size, /* Data buffer max size */ @@ -19,7 +19,7 @@ ssize_t EncodeRespcontrol( /* Decode a metadata and data to populate a message * Returns 0 on success, -1 on failure */ -int DecodeRespcontrol( +int DecodeResponse( struct controller_message *cm, /* Out */ const struct metadata *m, /* In */ const uint8_t * data); /* In */ diff --git a/groundStation/src/backend/setparam.c b/groundStation/src/backend/setparam.c index e088fe6579b50abde3aad48b96e72095a4ed0486..c97ed01f4d16d92ae18434d3dbf5d8da9c11b94a 100644 --- a/groundStation/src/backend/setparam.c +++ b/groundStation/src/backend/setparam.c @@ -1,32 +1,32 @@ -#include "setcontrol.h" +#include "setparam.h" #include "commands.h" #include "bitwise.h" #include <sys/types.h> -enum SetcontrolData { +enum SetparamData { CTRL_ID, CTRLVAL_ID, VAL_1, VAL_2, VAL_3, VAL_4, - SC_DATA_SIZE + SP_DATA_SIZE }; /* Creates data and metadata for a setcontrol packet * Returns data size. */ -ssize_t EncodeSetcontrol( +ssize_t EncodeSetparam( struct metadata * m, /* data_len and msg_type will be populated*/ uint8_t * data, /* Output buffer */ size_t data_size, /* Max buffer size */ const struct controller_message * cm) /* Message to encode */ { m->msg_type = SETPARAM_ID; - m->data_len = SC_DATA_SIZE; + m->data_len = SP_DATA_SIZE; - if (data_size < SC_DATA_SIZE) { + if (data_size < SP_DATA_SIZE) { return -1; } @@ -37,18 +37,18 @@ ssize_t EncodeSetcontrol( data[VAL_3] = FloatByte3(cm->value); data[VAL_4] = FloatByte4(cm->value); - return SC_DATA_SIZE; + return SP_DATA_SIZE; } /* Decode a metadata and data to populate a controller. * Returns 0 on success, -1 on failure. */ -int DecodeSetcontrol( +int DecodeSetparam( struct controller_message * cm, /* Decoded controller message */ const struct metadata * m, /* Metadata to aid in decoding */ const uint8_t * data) /* Data to decode */ { - if (m->data_len < SC_DATA_SIZE) { + if (m->data_len < SP_DATA_SIZE) { return -1; } if (m->msg_type != SETPARAM_ID) { diff --git a/groundStation/src/backend/setparam.h b/groundStation/src/backend/setparam.h index b7f880bce7e9f1f458752973142e42b39b6878b6..671d7aa240ef43c6bb82fc8eaa1b29826b70c36c 100644 --- a/groundStation/src/backend/setparam.h +++ b/groundStation/src/backend/setparam.h @@ -1,5 +1,5 @@ -#ifndef _setcontrol_h -#define _setcontrol_h +#ifndef _setparam_h +#define _setparam_h #include "packet.h" #include "controller.h" @@ -9,7 +9,7 @@ /* Creates data and metadata for a setcontrol packet * Returns data size. */ -ssize_t EncodeSetcontrol( +ssize_t EncodeSetparam( struct metadata * m, /* data_len and msg_type will be populated*/ uint8_t * data, /* Output buffer */ size_t data_size, /* Max buffer size */ @@ -18,7 +18,7 @@ ssize_t EncodeSetcontrol( /* Decode a metadata and data to populate a controller. * Returns 0 on success, -1 on failure. */ -int DecodeSetcontrol( +int DecodeSetparam( struct controller_message * cm, /* Decoded controller message */ const struct metadata * m, /* Metadata to aid in decoding */ const uint8_t * data); /* Data to decode */