36 #ifndef _TINY_LIGHT_PROTOCOL_H_ 37 #define _TINY_LIGHT_PROTOCOL_H_ 43 #include <HardwareSerial.h> 96 inline void beginToSerial1()
98 begin([](
void *p,
const void *b,
int s) ->
int {
return Serial1.write((
const uint8_t *)b, s); },
99 [](
void *p,
void *b,
int s) ->
int {
return Serial1.readBytes((uint8_t *)b, s); });
103 #ifdef HAVE_HWSERIAL2 109 inline void beginToSerial2()
111 begin([](
void *p,
const void *b,
int s) ->
int {
return Serial2.write((
const uint8_t *)b, s); },
112 [](
void *p,
void *b,
int s) ->
int {
return Serial2.readBytes((uint8_t *)b, s); });
116 #ifdef HAVE_SERIALUSB 122 inline void beginToSerialUSB()
124 begin([](
void *p,
const void *b,
int s) ->
int {
return SerialUSB.write((
const char *)b, s); },
125 [](
void *p,
void *b,
int s) ->
int {
return SerialUSB.readBytes((
char *)b, s); });
144 int write(
char *buf,
int size);
154 int read(
char *buf,
int size);
221 hdlc_crc_t m_crc = HDLC_CRC_DEFAULT;
Light class encapsulates the Light protocol functionality.
Definition: TinyLightProtocol.h:64
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:81
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