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

Committer:
Overdrivr
Date:
Mon Oct 12 13:29:40 2015 +0000
Revision:
3:135f55b5334e
Parent:
2:f2c816b681e3
Child:
4:d675ad9c57ff
New protocol update. DistantIO Protocol now supports 2 extra identifier fields for sending time of recorded value and index for array support. Also, it will enable semi-manual data send for special debugging cases. Longer var/group names too.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Overdrivr 2:f2c816b681e3 1 /*
Overdrivr 2:f2c816b681e3 2 * distantio.h
Overdrivr 2:f2c816b681e3 3 *
Overdrivr 2:f2c816b681e3 4 * Created on: Oct 13, 2014
Overdrivr 2:f2c816b681e3 5 * Author: B48923
Overdrivr 2:f2c816b681e3 6 */
Overdrivr 1:aaffeb93f99b 7
Overdrivr 0:c4676d32d381 8 #ifndef DISTANTIO_H_
Overdrivr 0:c4676d32d381 9 #define DISTANTIO_H_
Overdrivr 0:c4676d32d381 10
Overdrivr 0:c4676d32d381 11 #include <stdint.h>
Overdrivr 0:c4676d32d381 12
Overdrivr 3:135f55b5334e 13 #define FRAMESIZE 20
Overdrivr 3:135f55b5334e 14 #define DATASIZE 8
Overdrivr 3:135f55b5334e 15 #define DATASTART 10
Overdrivr 0:c4676d32d381 16 #define VARIABLES_AMOUNT 256
Overdrivr 0:c4676d32d381 17 #define GROUPS_AMOUNT 128
Overdrivr 3:135f55b5334e 18 #define NAMESIZE 14
Overdrivr 0:c4676d32d381 19
Overdrivr 0:c4676d32d381 20 typedef enum dio_type dio_type;
Overdrivr 0:c4676d32d381 21 enum dio_type
Overdrivr 0:c4676d32d381 22 {
Overdrivr 0:c4676d32d381 23 dio_type_FLOAT = 0x00,
Overdrivr 0:c4676d32d381 24 dio_type_UINT8 = 0x01,
Overdrivr 0:c4676d32d381 25 dio_type_UINT16 = 0x02,
Overdrivr 0:c4676d32d381 26 dio_type_UINT32 = 0x03,
Overdrivr 0:c4676d32d381 27 dio_type_INT8 = 0x04,
Overdrivr 0:c4676d32d381 28 dio_type_INT16 = 0x05,
Overdrivr 0:c4676d32d381 29 dio_type_INT32 = 0x06,
Overdrivr 0:c4676d32d381 30 };
Overdrivr 0:c4676d32d381 31
Overdrivr 0:c4676d32d381 32 typedef struct variable variable;
Overdrivr 0:c4676d32d381 33 struct variable
Overdrivr 0:c4676d32d381 34 {
Overdrivr 0:c4676d32d381 35 uint8_t* ptr;
Overdrivr 0:c4676d32d381 36 uint16_t size;
Overdrivr 0:c4676d32d381 37 uint8_t writeable;
Overdrivr 0:c4676d32d381 38 uint16_t id;
Overdrivr 0:c4676d32d381 39 dio_type type;
Overdrivr 3:135f55b5334e 40 char name[NAMESIZE];
Overdrivr 0:c4676d32d381 41 uint8_t send;
Overdrivr 0:c4676d32d381 42 uint8_t groupID;
Overdrivr 2:f2c816b681e3 43 float refresh_rate;
Overdrivr 2:f2c816b681e3 44 float last_refreshed;
Overdrivr 0:c4676d32d381 45 };
Overdrivr 0:c4676d32d381 46
Overdrivr 0:c4676d32d381 47 typedef struct group group;
Overdrivr 0:c4676d32d381 48 struct group
Overdrivr 0:c4676d32d381 49 {
Overdrivr 3:135f55b5334e 50 char name[NAMESIZE];
Overdrivr 0:c4676d32d381 51 uint8_t groupID;
Overdrivr 0:c4676d32d381 52 };
Overdrivr 0:c4676d32d381 53
Overdrivr 0:c4676d32d381 54 //typedef struct log log;
Overdrivr 0:c4676d32d381 55 struct log
Overdrivr 0:c4676d32d381 56 {
Overdrivr 0:c4676d32d381 57 variable variables[VARIABLES_AMOUNT];
Overdrivr 0:c4676d32d381 58 group groups[GROUPS_AMOUNT];
Overdrivr 0:c4676d32d381 59 uint16_t amount;
Overdrivr 0:c4676d32d381 60 uint8_t current_group_id;
Overdrivr 0:c4676d32d381 61 };
Overdrivr 0:c4676d32d381 62
Overdrivr 0:c4676d32d381 63 void init_distantio();
Overdrivr 0:c4676d32d381 64
Overdrivr 0:c4676d32d381 65 uint8_t register_var(void* ptr, uint16_t size, dio_type type, uint8_t writeable, char* name);
Overdrivr 2:f2c816b681e3 66 uint8_t register_var(void* ptr, uint16_t size, dio_type type, uint8_t writeable, char* name, float refresh_rate);
Overdrivr 0:c4676d32d381 67 void start_group(char* groupname);
Overdrivr 0:c4676d32d381 68
Overdrivr 0:c4676d32d381 69 void distantio_decode(uint8_t* data,uint16_t datasize);
Overdrivr 0:c4676d32d381 70
Overdrivr 0:c4676d32d381 71 // To call often
Overdrivr 2:f2c816b681e3 72 void update(float current_time);
Overdrivr 0:c4676d32d381 73 void send_alive();
Overdrivr 0:c4676d32d381 74
Overdrivr 0:c4676d32d381 75 #endif /* DISTANTIO_H_ */