Commit f94335d0 authored by bertucci's avatar bertucci

Adding frontend->backend on backend side communication files

parent 391b921b
#include <sys/types.h>
#include <inttypes.h>
#include "output.h"
#include "commands.h"
#include "bitwise.h"
enum FlagData {
FLAG_VALUE_LL,
FLAG_VALUE_LH,
FLAG_VALUE_HL,
FLAG_VALUE_HH,
FLAG_DATA_SIZE
};
/* Creates data and metadata for a setcontrol packet
* Returns data size.
*/
ssize_t EncodeFlags(
struct metadata * m, /* data_len and msg_type will be populated*/
uint8_t * data, /* Output buffer */
size_t data_size, /* Max buffer size */
const char * msg) /* Message to encode */
{
m->msg_type = FLAG_ID;
m->data_len = FLAG_DATA_SIZE;
if (data_size < GO_DATA_SIZE) {
return -1;
}
uint32_t values;
sscanf(msg, "setFlags %" SCNd32 " %x", &values);
data[FLAG_VALUE_LL] = (uint8_t)(values >> 24); //FOURTH LEFT MOST BYTE
data[FLAG_VALUE_LH] = (uint8_t)(values >> 16); //THIRD LEFT MOST BYTE
data[FLAG_VALUE_HL] = (uint8_t)(values >> 8); //SECOND LEFT MOST BYTE
data[FLAG_VALUE_HH] = (uint8_t)(values); //LEFT MOST BYTE
return FLAG_DATA_SIZE;
}
#ifndef _getoutput_h
#define _getoutput_h
#include "packet.h"
#include <sys/types.h>
/* Creates data and metadata for a getcontrol packet.
* Returns data size.
*/
ssize_t EncodeGetOutput(
struct metadata *m, /* Out */
uint8_t *data, /* Out */
size_t data_size, /* Data buffer max size */
const char * msg); /* Value is not used; only IDs */
/* Decode a metadata and data to populate a controller.
* Returns bytes written to msg, -1 on failure.
*/
int DecodeResponseOutput(
char * msg, /* Out */
size_t max_len, /* msg buffer max size */
const struct metadata *m, /* In */
const uint8_t * data); /* In */
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment