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
protocol.h@0:c4676d32d381, 2015-09-15 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
Overdrivr | 0:c4676d32d381 | 1 | /* |
Overdrivr | 0:c4676d32d381 | 2 | * serial_protocol.h |
Overdrivr | 0:c4676d32d381 | 3 | * |
Overdrivr | 0:c4676d32d381 | 4 | * Created on: Oct 22, 2014 |
Overdrivr | 0:c4676d32d381 | 5 | * Author: B48923 |
Overdrivr | 0:c4676d32d381 | 6 | */ |
Overdrivr | 0:c4676d32d381 | 7 | |
Overdrivr | 0:c4676d32d381 | 8 | #ifndef SERIAL_PROTOCOL_H_ |
Overdrivr | 0:c4676d32d381 | 9 | #define SERIAL_PROTOCOL_H_ |
Overdrivr | 0:c4676d32d381 | 10 | |
Overdrivr | 0:c4676d32d381 | 11 | #include <stdint.h> |
Overdrivr | 0:c4676d32d381 | 12 | |
Overdrivr | 0:c4676d32d381 | 13 | #define ENCODING_BUFFER_SIZE 64 |
Overdrivr | 0:c4676d32d381 | 14 | #define DECODING_BUFFER_SIZE 256 |
Overdrivr | 0:c4676d32d381 | 15 | |
Overdrivr | 0:c4676d32d381 | 16 | typedef void (*callback_t)(uint8_t* data, uint16_t size); |
Overdrivr | 0:c4676d32d381 | 17 | |
Overdrivr | 0:c4676d32d381 | 18 | void init_protocol(void (*encoding_done_callback)(uint8_t*,uint16_t),void (*decoding_done_callback)(uint8_t*,uint16_t)); |
Overdrivr | 0:c4676d32d381 | 19 | /* |
Overdrivr | 0:c4676d32d381 | 20 | * Encodes new data with byte stuffing algorithm to delimit frame. |
Overdrivr | 0:c4676d32d381 | 21 | * @input framedata : the raw data to process |
Overdrivr | 0:c4676d32d381 | 22 | * @input framesize : size of the raw data to process (amount of bytes) |
Overdrivr | 0:c4676d32d381 | 23 | */ |
Overdrivr | 0:c4676d32d381 | 24 | void encode(uint8_t* framedata, uint16_t framesize); |
Overdrivr | 0:c4676d32d381 | 25 | |
Overdrivr | 0:c4676d32d381 | 26 | /* |
Overdrivr | 0:c4676d32d381 | 27 | * Append new byte to current decoding sequence. If a valid frame is detected, |
Overdrivr | 0:c4676d32d381 | 28 | * the decoding_done_callback function is called and the valid frame is sent as parameter |
Overdrivr | 0:c4676d32d381 | 29 | * @input received_byte : the new byte to add to the current decoding sequence |
Overdrivr | 0:c4676d32d381 | 30 | */ |
Overdrivr | 0:c4676d32d381 | 31 | void decode(uint8_t received_byte); |
Overdrivr | 0:c4676d32d381 | 32 | |
Overdrivr | 0:c4676d32d381 | 33 | #endif /* SERIAL_PROTOCOL_H_ */ |
Overdrivr | 0:c4676d32d381 | 34 |