#include <TinyProtocolHdlc.h>
|
virtual void | onReceive (uint8_t *pdata, int size) |
|
virtual void | onSend (const uint8_t *pdata, int size) |
|
ProtoHdlc class incapsulates hdlc Protocol functionality. hdlc version of the Protocol allows to send messages with confirmation. Remember that you may use always C-style API functions instead C++. Please refer to documentation.
◆ ProtoHdlc()
Tiny::ProtoHdlc::ProtoHdlc |
( |
void * |
buffer, |
|
|
int |
bufferSize |
|
) |
| |
|
inline |
Initializes ProtoHdlc object
- Parameters
-
buffer | - buffer to store the frames being received. |
bufferSize | - size of the buffer |
◆ begin() [1/2]
Initializes protocol internal variables. If you need to switch communication with other destination point, you can call this method one again after calling end().
- Parameters
-
writecb | - write function to some physical channel |
readcb | - read function from some physical channel |
- Returns
- None
◆ begin() [2/2]
void Tiny::ProtoHdlc::begin |
( |
| ) |
|
Initializes protocol internal variables. If you need to switch communication with other destination point, you can call this method one again after calling end().
- Returns
- None
◆ beginToSerial()
void Tiny::ProtoHdlc::beginToSerial |
( |
| ) |
|
|
inline |
Initializes protocol internal variables and redirects communication through Arduino Serial connection (Serial).
- Returns
- None
◆ beginToSerial1()
void Tiny::ProtoHdlc::beginToSerial1 |
( |
| ) |
|
|
inline |
Initializes protocol internal variables and redirects communication through Arduino Serial1 connection (Serial1).
- Returns
- None
◆ beginToSerial2()
void Tiny::ProtoHdlc::beginToSerial2 |
( |
| ) |
|
|
inline |
Initializes protocol internal variables and redirects communication through Arduino Serial2 connection (Serial2).
- Returns
- None
◆ beginToSerial3()
void Tiny::ProtoHdlc::beginToSerial3 |
( |
| ) |
|
|
inline |
Initializes protocol internal variables and redirects communication through Arduino Serial3 connection (Serial3).
- Returns
- None
◆ disableCrc()
void Tiny::ProtoHdlc::disableCrc |
( |
| ) |
|
Disable CRC field in the protocol. If CRC field is OFF, then the frame looks like this: 0x7E databytes 0x7E.
◆ enableCheckSum()
bool Tiny::ProtoHdlc::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.
- Returns
- true if successful false in case of error.
◆ enableCrc()
Enables CRC by specified bit-size. 8-bit is supported by Nano version of Tiny library.
- Parameters
-
◆ enableCrc16()
bool Tiny::ProtoHdlc::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.
- Returns
- true if successful false in case of error.
◆ enableCrc32()
bool Tiny::ProtoHdlc::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.
- Returns
- true if successful false in case of error.
◆ end()
void Tiny::ProtoHdlc::end |
( |
| ) |
|
◆ onReceive()
virtual void Tiny::ProtoHdlc::onReceive |
( |
uint8_t * |
pdata, |
|
|
int |
size |
|
) |
| |
|
inlineprotectedvirtual |
Method called by hdlc protocol upon receiving new frame. Can be redefined in derived classes.
- Parameters
-
pdata | pointer to received data |
size | size of received payload in bytes |
◆ onSend()
virtual void Tiny::ProtoHdlc::onSend |
( |
const uint8_t * |
pdata, |
|
|
int |
size |
|
) |
| |
|
inlineprotectedvirtual |
Method called by hdlc protocol upon sending next frame. Can be redefined in derived classes.
- Parameters
-
pdata | pointer to sent data |
size | size of sent payload in bytes |
◆ run_rx()
int Tiny::ProtoHdlc::run_rx |
( |
const void * |
data, |
|
|
int |
len |
|
) |
| |
Processes incoming rx data, specified by a user.
- Returns
- TINY_SUCCESS
◆ run_tx()
int Tiny::ProtoHdlc::run_tx |
( |
void * |
data, |
|
|
int |
max_len |
|
) |
| |
Generates data for tx channel
- Parameters
-
data | buffer to fill |
max_len | length of buffer |
- Returns
- number of bytes generated
◆ setReceiveCallback()
void Tiny::ProtoHdlc::setReceiveCallback |
( |
void(*)(IPacket &pkt) |
on_receive = nullptr | ) |
|
|
inline |
Sets receive callback for incoming messages
- Parameters
-
on_receive | user callback to process incoming messages. The processing must be non-blocking |
◆ setSendCallback()
void Tiny::ProtoHdlc::setSendCallback |
( |
void(*)(IPacket &pkt) |
on_send = nullptr | ) |
|
|
inline |
Sets send callback for outgoing messages
- Parameters
-
on_send | user callback to process outgoing messages. The processing must be non-blocking |
◆ write() [1/2]
int Tiny::ProtoHdlc::write |
( |
char * |
buf, |
|
|
int |
size |
|
) |
| |
Sends data block over communication channel.
- Parameters
-
buf | - data to send |
size | - length of the data in bytes |
- Returns
- negative value in case of error zero if nothing is sent positive - should be equal to size parameter
◆ write() [2/2]
int Tiny::ProtoHdlc::write |
( |
IPacket & |
pkt | ) |
|
Sends packet over communication channel.
- Parameters
-
- See also
- Packet
- Returns
- negative value in case of error zero if nothing is sent positive - Packet is successfully sent
The documentation for this class was generated from the following file: