36 #ifndef _TINY_LIGHT_PROTOCOL_H_ 37 #define _TINY_LIGHT_PROTOCOL_H_ 43 #include <HardwareSerial.h> 93 inline void beginToSerial1()
95 begin([](
void *p,
const void *b,
int s) ->
int {
return Serial1.write((
const uint8_t *)b, s); },
96 [](
void *p,
void *b,
int s) ->
int {
return Serial1.readBytes((uint8_t *)b, s); });
100 #ifdef HAVE_HWSERIAL2 106 inline void beginToSerial2()
108 begin([](
void *p,
const void *b,
int s) ->
int {
return Serial2.write((
const uint8_t *)b, s); },
109 [](
void *p,
void *b,
int s) ->
int {
return Serial2.readBytes((uint8_t *)b, s); });
113 #ifdef HAVE_SERIALUSB 119 inline void beginToSerialUSB()
121 begin([](
void *p,
const void *b,
int s) ->
int {
return SerialUSB.write((
const char *)b, s); },
122 [](
void *p,
void *b,
int s) ->
int {
return SerialUSB.readBytes((
char *)b, s); });
141 int write(
char *buf,
int size);
151 int read(
char *buf,
int size);
218 hdlc_crc_t m_crc = HDLC_CRC_DEFAULT;
ProtoLight class incapsulates Protocol functionality.
Definition: TinyLightProtocol.h:61
void disableCrc()
Disable CRC field in the protocol.
Definition: TinyLightProtocol.cpp:78
This is Tiny protocol implementation for microcontrollers.
Describes packet entity and provides API methods to manipulate the packet.
Definition: TinyPacket.h:56
bool enableCrc16()
Enables CRC 16-bit field in the protocol.
Definition: TinyLightProtocol.cpp:98
void enableCrc(hdlc_crc_t crc)
Enables CRC by specified bit-size.
Definition: TinyLightProtocol.cpp:83
int(* read_block_cb_t)(void *pdata, void *buffer, int size)
The function reads data from communication channel.
Definition: tiny_types.h:185
bool enableCrc32()
Enables CRC 32-bit field in the protocol.
Definition: TinyLightProtocol.cpp:108
int write(char *buf, int size)
Sends data block over communication channel.
Definition: TinyLightProtocol.cpp:55
void end()
Resets protocol state.
Definition: TinyLightProtocol.cpp:50
This structure contains information about communication channel and its state.
Definition: tiny_light.h:66
int read(char *buf, int size)
Reads data block from communication channel.
Definition: TinyLightProtocol.cpp:60
This is Tiny Light protocol implementation for microcontrollers.
int(* write_block_cb_t)(void *pdata, const void *buffer, int size)
The function writes data to communication channel port.
Definition: tiny_types.h:174
Definition: TinySerial.cpp:22
bool enableCheckSum()
Enables CRC 8-bit field in the protocol.
Definition: TinyLightProtocol.cpp:88
void begin(write_block_cb_t writecb, read_block_cb_t readcb)
Initializes protocol internal variables.
Definition: TinyLightProtocol.cpp:44