Tiny protocol
0.7.0
Tiny communication protocol for microcontrollers
|
#include <TinyProtocol.h>
Public Member Functions | |
void | begin (write_block_cb_t writecb, read_block_cb_t readcb) |
void | beginToSerial () |
void | beginToSerial1 () |
void | beginToSerial2 () |
void | beginToSerial3 () |
void | end () |
int | write (char *buf, int size, uint8_t flags=TINY_FLAG_WAIT_FOREVER) |
int | read (char *buf, int size, uint8_t flags=TINY_FLAG_WAIT_FOREVER) |
int | write (Packet &pkt, uint8_t flags=TINY_FLAG_WAIT_FOREVER) |
int | read (Packet &pkt, uint8_t flags=TINY_FLAG_WAIT_FOREVER) |
void | disableCrc () |
bool | enableCheckSum () |
bool | enableCrc16 () |
bool | enableCrc32 () |
void | enableUid () |
void | disableUid () |
Proto class incapsulates Protocol functionality. Remember that you may use always C-style API functions instead C++. Please refer to documentation.
void Tiny::Proto::begin | ( | write_block_cb_t | writecb, |
read_block_cb_t | readcb | ||
) |
Initializes protocol internal variables. If you need to switch communication with other destination point, you can call this method one again after calling end().
writecb | - write function to some physical channel |
readcb | - read function from some physical channel |
|
inline |
Initializes protocol internal variables and redirects communication through Arduino Serial connection (Serial).
|
inline |
Initializes protocol internal variables and redirects communication through Arduino Serial1 connection (Serial1).
|
inline |
Initializes protocol internal variables and redirects communication through Arduino Serial2 connection (Serial2).
|
inline |
Initializes protocol internal variables and redirects communication through Arduino Serial3 connection (Serial3).
void Tiny::Proto::disableCrc | ( | ) |
Disable CRC field in the protocol. If CRC field is OFF, then the frame looks like this: 0x7E databytes 0x7E.
|
inline |
Disables Uid field in the protocol. If enabled this 16-bit field with packet identifier is added before each payload data. Frame with uid: 0x7E 16-bituid payload 0x7E Frame without uid: 0x7E payload 0x7E
bool Tiny::Proto::enableCheckSum | ( | ) |
Enables CRC 8-bit field in the protocol. This field contains sum of all data bytes in the packet. 8-bit field is supported by Nano version of Tiny library.
bool Tiny::Proto::enableCrc16 | ( | ) |
Enables CRC 16-bit field in the protocol. This field contains FCS 16-bit CCITT like defined in RFC 1662. 16-bit field is not supported by Nano version of Tiny library.
bool Tiny::Proto::enableCrc32 | ( | ) |
Enables CRC 32-bit field in the protocol. This field contains FCS 32-bit CCITT like defined in RFC 1662. 32-bit field is not supported by Nano version of Tiny library.
|
inline |
Enables Uid field in the protocol. If enabled this 16-bit field with packet identifier is added before each payload data. Frame with uid: 0x7E 16-bituid payload 0x7E Frame without uid: 0x7E payload 0x7E
void Tiny::Proto::end | ( | ) |
Resets protocol state.
int Tiny::Proto::read | ( | char * | buf, |
int | size, | ||
uint8_t | flags = TINY_FLAG_WAIT_FOREVER |
||
) |
Reads data block from communication channel.
buf | - buffer to place data read from communication channel |
size | - maximum size of the buffer in bytes. |
flags | - Flags for Tiny API functions |
int Tiny::Proto::read | ( | Packet & | pkt, |
uint8_t | flags = TINY_FLAG_WAIT_FOREVER |
||
) |
Reads packet from communication channel.
pkt | Packet object to put data to |
flags | Flags for Tiny API functions |
int Tiny::Proto::write | ( | char * | buf, |
int | size, | ||
uint8_t | flags = TINY_FLAG_WAIT_FOREVER |
||
) |
Sends data block over communication channel.
buf | - data to send |
size | - length of the data in bytes |
flags | - flags. Flags for Tiny API functions |
int Tiny::Proto::write | ( | Packet & | pkt, |
uint8_t | flags = TINY_FLAG_WAIT_FOREVER |
||
) |
Sends packet over communication channel.
pkt | - Packet to send |
flags | - Flags for Tiny API functions |