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:
Tue Sep 15 15:27:55 2015 +0000
Revision:
0:c4676d32d381
Child:
1:aaffeb93f99b
Version not bug free (especially names should not be longer thant 8 characters or have spaces), but pretty reliable behavior. See github repo for tickets

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Overdrivr 0:c4676d32d381 1 /*
Overdrivr 0:c4676d32d381 2 * distantio.h
Overdrivr 0:c4676d32d381 3 *
Overdrivr 0:c4676d32d381 4 * Created on: Oct 13, 2014
Overdrivr 0:c4676d32d381 5 * Author: B48923
Overdrivr 0:c4676d32d381 6 */
Overdrivr 0:c4676d32d381 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 0:c4676d32d381 41 };
Overdrivr 0:c4676d32d381 42
Overdrivr 0:c4676d32d381 43 typedef struct group group;
Overdrivr 0:c4676d32d381 44 struct group
Overdrivr 0:c4676d32d381 45 {
Overdrivr 0:c4676d32d381 46 char name[8];
Overdrivr 0:c4676d32d381 47 uint8_t groupID;
Overdrivr 0:c4676d32d381 48 };
Overdrivr 0:c4676d32d381 49
Overdrivr 0:c4676d32d381 50 //typedef struct log log;
Overdrivr 0:c4676d32d381 51 struct log
Overdrivr 0:c4676d32d381 52 {
Overdrivr 0:c4676d32d381 53 variable variables[VARIABLES_AMOUNT];
Overdrivr 0:c4676d32d381 54 group groups[GROUPS_AMOUNT];
Overdrivr 0:c4676d32d381 55 uint16_t amount;
Overdrivr 0:c4676d32d381 56 uint8_t current_group_id;
Overdrivr 0:c4676d32d381 57 };
Overdrivr 0:c4676d32d381 58
Overdrivr 0:c4676d32d381 59 void init_distantio();
Overdrivr 0:c4676d32d381 60
Overdrivr 0:c4676d32d381 61 uint8_t register_var(void* ptr, uint16_t size, dio_type type, uint8_t writeable, char* name);
Overdrivr 0:c4676d32d381 62 void start_group(char* groupname);
Overdrivr 0:c4676d32d381 63
Overdrivr 0:c4676d32d381 64 void distantio_decode(uint8_t* data,uint16_t datasize);
Overdrivr 0:c4676d32d381 65
Overdrivr 0:c4676d32d381 66 // To call often
Overdrivr 0:c4676d32d381 67 void send_variables();
Overdrivr 0:c4676d32d381 68 void send_alive();
Overdrivr 0:c4676d32d381 69
Overdrivr 0:c4676d32d381 70 #endif /* DISTANTIO_H_ */
Overdrivr 0:c4676d32d381 71