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:
Thu Oct 08 13:14:32 2015 +0000
Revision:
2:f2c816b681e3
Parent:
1:aaffeb93f99b
Child:
3:135f55b5334e
*Fixed issues with variables/group names > 8; *Added timing management. Variables can either be send all the time, or only after a defined delta. Useful to reduce constraints on datarate for parameters not needed in real time

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 0:c4676d32d381 13 #define PAYLOAD_SIZE 14
Overdrivr 0:c4676d32d381 14 #define DATA_SIZE 8
Overdrivr 0:c4676d32d381 15 #define VARIABLES_AMOUNT 256
Overdrivr 0:c4676d32d381 16 #define GROUPS_AMOUNT 128
Overdrivr 0:c4676d32d381 17
Overdrivr 0:c4676d32d381 18 typedef enum dio_type dio_type;
Overdrivr 0:c4676d32d381 19 enum dio_type
Overdrivr 0:c4676d32d381 20 {
Overdrivr 0:c4676d32d381 21 dio_type_FLOAT = 0x00,
Overdrivr 0:c4676d32d381 22 dio_type_UINT8 = 0x01,
Overdrivr 0:c4676d32d381 23 dio_type_UINT16 = 0x02,
Overdrivr 0:c4676d32d381 24 dio_type_UINT32 = 0x03,
Overdrivr 0:c4676d32d381 25 dio_type_INT8 = 0x04,
Overdrivr 0:c4676d32d381 26 dio_type_INT16 = 0x05,
Overdrivr 0:c4676d32d381 27 dio_type_INT32 = 0x06,
Overdrivr 0:c4676d32d381 28 };
Overdrivr 0:c4676d32d381 29
Overdrivr 0:c4676d32d381 30 typedef struct variable variable;
Overdrivr 0:c4676d32d381 31 struct variable
Overdrivr 0:c4676d32d381 32 {
Overdrivr 0:c4676d32d381 33 uint8_t* ptr;
Overdrivr 0:c4676d32d381 34 uint16_t size;
Overdrivr 0:c4676d32d381 35 uint8_t writeable;
Overdrivr 0:c4676d32d381 36 uint16_t id;
Overdrivr 0:c4676d32d381 37 dio_type type;
Overdrivr 0:c4676d32d381 38 char name[8];
Overdrivr 0:c4676d32d381 39 uint8_t send;
Overdrivr 0:c4676d32d381 40 uint8_t groupID;
Overdrivr 2:f2c816b681e3 41 float refresh_rate;
Overdrivr 2:f2c816b681e3 42 float last_refreshed;
Overdrivr 0:c4676d32d381 43 };
Overdrivr 0:c4676d32d381 44
Overdrivr 0:c4676d32d381 45 typedef struct group group;
Overdrivr 0:c4676d32d381 46 struct group
Overdrivr 0:c4676d32d381 47 {
Overdrivr 0:c4676d32d381 48 char name[8];
Overdrivr 0:c4676d32d381 49 uint8_t groupID;
Overdrivr 0:c4676d32d381 50 };
Overdrivr 0:c4676d32d381 51
Overdrivr 0:c4676d32d381 52 //typedef struct log log;
Overdrivr 0:c4676d32d381 53 struct log
Overdrivr 0:c4676d32d381 54 {
Overdrivr 0:c4676d32d381 55 variable variables[VARIABLES_AMOUNT];
Overdrivr 0:c4676d32d381 56 group groups[GROUPS_AMOUNT];
Overdrivr 0:c4676d32d381 57 uint16_t amount;
Overdrivr 0:c4676d32d381 58 uint8_t current_group_id;
Overdrivr 0:c4676d32d381 59 };
Overdrivr 0:c4676d32d381 60
Overdrivr 0:c4676d32d381 61 void init_distantio();
Overdrivr 0:c4676d32d381 62
Overdrivr 0:c4676d32d381 63 uint8_t register_var(void* ptr, uint16_t size, dio_type type, uint8_t writeable, char* name);
Overdrivr 2:f2c816b681e3 64 uint8_t register_var(void* ptr, uint16_t size, dio_type type, uint8_t writeable, char* name, float refresh_rate);
Overdrivr 0:c4676d32d381 65 void start_group(char* groupname);
Overdrivr 0:c4676d32d381 66
Overdrivr 0:c4676d32d381 67 void distantio_decode(uint8_t* data,uint16_t datasize);
Overdrivr 0:c4676d32d381 68
Overdrivr 0:c4676d32d381 69 // To call often
Overdrivr 2:f2c816b681e3 70 void update(float current_time);
Overdrivr 0:c4676d32d381 71 void send_alive();
Overdrivr 0:c4676d32d381 72
Overdrivr 0:c4676d32d381 73 #endif /* DISTANTIO_H_ */