Framework for reading and writing variables in real time on any MBED platform.

DistantIO

This is the C implementation of the DistantIO slave framework.

Library is working but slight API breaks may occur in the future. C++ version is also in development.

To get the master-side implementation, see https://github.com/Overdrivr/DistantIO

distantio.h

Committer:
Overdrivr
Date:
2015-10-12
Revision:
3:135f55b5334e
Parent:
2:f2c816b681e3
Child:
4:d675ad9c57ff

File content as of revision 3:135f55b5334e:

/*
 * distantio.h
 *
 *  Created on: Oct 13, 2014
 *      Author: B48923
 */

#ifndef DISTANTIO_H_
#define DISTANTIO_H_

#include <stdint.h>

#define FRAMESIZE 20
#define DATASIZE 8
#define DATASTART 10
#define VARIABLES_AMOUNT 256
#define GROUPS_AMOUNT 128
#define NAMESIZE 14

typedef enum dio_type dio_type;
enum dio_type
{
	dio_type_FLOAT = 0x00,
	dio_type_UINT8 = 0x01,
	dio_type_UINT16 = 0x02,
	dio_type_UINT32 = 0x03,
	dio_type_INT8 = 0x04,
	dio_type_INT16 = 0x05,
	dio_type_INT32 = 0x06,
};

typedef struct variable variable;
struct variable
{
	uint8_t* ptr;
	uint16_t size;
	uint8_t writeable;
	uint16_t id;
	dio_type type;
	char name[NAMESIZE];
	uint8_t send;
	uint8_t groupID;
	float refresh_rate;
	float last_refreshed;
};

typedef struct group group;
struct group
{
	char name[NAMESIZE];
	uint8_t groupID;
};

//typedef struct log log;
struct log
{
	variable variables[VARIABLES_AMOUNT];
	group groups[GROUPS_AMOUNT];
	uint16_t amount;
	uint8_t current_group_id;
};

void init_distantio();

uint8_t register_var(void* ptr, uint16_t size, dio_type type, uint8_t writeable, char* name);
uint8_t register_var(void* ptr, uint16_t size, dio_type type, uint8_t writeable, char* name, float refresh_rate);
void start_group(char* groupname);

void distantio_decode(uint8_t* data,uint16_t datasize);

// To call often
void update(float current_time);
void send_alive();

#endif /* DISTANTIO_H_ */