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 12:27:20 2015 +0000
Revision:
1:aaffeb93f99b
Parent:
0:c4676d32d381
Child:
2:f2c816b681e3
commit for publish

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Overdrivr 1:aaffeb93f99b 1 // Copyright (C) 2015 Rémi Bèges
Overdrivr 1:aaffeb93f99b 2 // For conditions of distribution and use, see copyright notice in the LICENSE.md file
Overdrivr 1:aaffeb93f99b 3
Overdrivr 0:c4676d32d381 4 /*
Overdrivr 1:aaffeb93f99b 5 * WARNING : IMPLEMENTATION FOR LITTLE-ENDIAN PROCESSOR
Overdrivr 1:aaffeb93f99b 6 * TODO : HANDLE BOTH
Overdrivr 0:c4676d32d381 7 */
Overdrivr 1:aaffeb93f99b 8
Overdrivr 0:c4676d32d381 9 #ifndef DISTANTIO_H_
Overdrivr 0:c4676d32d381 10 #define DISTANTIO_H_
Overdrivr 0:c4676d32d381 11
Overdrivr 0:c4676d32d381 12 #include <stdint.h>
Overdrivr 0:c4676d32d381 13
Overdrivr 0:c4676d32d381 14 #define PAYLOAD_SIZE 14
Overdrivr 0:c4676d32d381 15 #define DATA_SIZE 8
Overdrivr 0:c4676d32d381 16 #define VARIABLES_AMOUNT 256
Overdrivr 0:c4676d32d381 17 #define GROUPS_AMOUNT 128
Overdrivr 0:c4676d32d381 18
Overdrivr 0:c4676d32d381 19 typedef enum dio_type dio_type;
Overdrivr 0:c4676d32d381 20 enum dio_type
Overdrivr 0:c4676d32d381 21 {
Overdrivr 0:c4676d32d381 22 dio_type_FLOAT = 0x00,
Overdrivr 0:c4676d32d381 23 dio_type_UINT8 = 0x01,
Overdrivr 0:c4676d32d381 24 dio_type_UINT16 = 0x02,
Overdrivr 0:c4676d32d381 25 dio_type_UINT32 = 0x03,
Overdrivr 0:c4676d32d381 26 dio_type_INT8 = 0x04,
Overdrivr 0:c4676d32d381 27 dio_type_INT16 = 0x05,
Overdrivr 0:c4676d32d381 28 dio_type_INT32 = 0x06,
Overdrivr 0:c4676d32d381 29 };
Overdrivr 0:c4676d32d381 30
Overdrivr 0:c4676d32d381 31 typedef struct variable variable;
Overdrivr 0:c4676d32d381 32 struct variable
Overdrivr 0:c4676d32d381 33 {
Overdrivr 0:c4676d32d381 34 uint8_t* ptr;
Overdrivr 0:c4676d32d381 35 uint16_t size;
Overdrivr 0:c4676d32d381 36 uint8_t writeable;
Overdrivr 0:c4676d32d381 37 uint16_t id;
Overdrivr 0:c4676d32d381 38 dio_type type;
Overdrivr 0:c4676d32d381 39 char name[8];
Overdrivr 0:c4676d32d381 40 uint8_t send;
Overdrivr 0:c4676d32d381 41 uint8_t groupID;
Overdrivr 0:c4676d32d381 42 };
Overdrivr 0:c4676d32d381 43
Overdrivr 0:c4676d32d381 44 typedef struct group group;
Overdrivr 0:c4676d32d381 45 struct group
Overdrivr 0:c4676d32d381 46 {
Overdrivr 0:c4676d32d381 47 char name[8];
Overdrivr 0:c4676d32d381 48 uint8_t groupID;
Overdrivr 0:c4676d32d381 49 };
Overdrivr 0:c4676d32d381 50
Overdrivr 0:c4676d32d381 51 //typedef struct log log;
Overdrivr 0:c4676d32d381 52 struct log
Overdrivr 0:c4676d32d381 53 {
Overdrivr 0:c4676d32d381 54 variable variables[VARIABLES_AMOUNT];
Overdrivr 0:c4676d32d381 55 group groups[GROUPS_AMOUNT];
Overdrivr 0:c4676d32d381 56 uint16_t amount;
Overdrivr 0:c4676d32d381 57 uint8_t current_group_id;
Overdrivr 0:c4676d32d381 58 };
Overdrivr 0:c4676d32d381 59
Overdrivr 0:c4676d32d381 60 void init_distantio();
Overdrivr 0:c4676d32d381 61
Overdrivr 0:c4676d32d381 62 uint8_t register_var(void* ptr, uint16_t size, dio_type type, uint8_t writeable, char* name);
Overdrivr 0:c4676d32d381 63 void start_group(char* groupname);
Overdrivr 0:c4676d32d381 64
Overdrivr 0:c4676d32d381 65 void distantio_decode(uint8_t* data,uint16_t datasize);
Overdrivr 0:c4676d32d381 66
Overdrivr 0:c4676d32d381 67 // To call often
Overdrivr 0:c4676d32d381 68 void send_variables();
Overdrivr 0:c4676d32d381 69 void send_alive();
Overdrivr 0:c4676d32d381 70
Overdrivr 0:c4676d32d381 71 #endif /* DISTANTIO_H_ */
Overdrivr 0:c4676d32d381 72