Skip to content
Snippets Groups Projects
Unverified Commit efbc858d authored by Jake Drahos's avatar Jake Drahos
Browse files

Finished renamification

There might be some lingering old uses of "xyzcontrol"
instead of "xyzparam", but whatever.
parent 9e06763d
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
#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
#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) {
......
#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 */
......
#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) {
......
#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 */
......
#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) {
......
#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 */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment