tinyproto
Public Member Functions | List of all members
tinyproto::Light Class Reference

ProtoLight class incapsulates Protocol functionality. More...

#include <TinyLightProtocol.h>

Public Member Functions

void begin (write_block_cb_t writecb, read_block_cb_t readcb)
 Initializes protocol internal variables. More...
 
void end ()
 Resets protocol state.
 
int write (char *buf, int size)
 Sends data block over communication channel. More...
 
int read (char *buf, int size)
 Reads data block from communication channel. More...
 
int write (const IPacket &pkt)
 Sends packet over communication channel. More...
 
int read (IPacket &pkt)
 Reads packet from communication channel. More...
 
void disableCrc ()
 Disable CRC field in the protocol. More...
 
void enableCrc (hdlc_crc_t crc)
 Enables CRC by specified bit-size. More...
 
bool enableCheckSum ()
 Enables CRC 8-bit field in the protocol. More...
 
bool enableCrc16 ()
 Enables CRC 16-bit field in the protocol. More...
 
bool enableCrc32 ()
 Enables CRC 32-bit field in the protocol. More...
 

Detailed Description

ProtoLight class incapsulates Protocol functionality.

Remember that you may use always C-style API functions instead C++. Please refer to documentation.

Member Function Documentation

◆ begin()

void tinyproto::Light::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().

Parameters
writecb- write function to some physical channel
readcb- read function from some physical channel
Returns
None

◆ disableCrc()

void tinyproto::Light::disableCrc ( )

Disable CRC field in the protocol.

If CRC field is OFF, then the frame looks like this: 0x7E databytes 0x7E.

◆ enableCheckSum()

bool tinyproto::Light::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()

void tinyproto::Light::enableCrc ( hdlc_crc_t  crc)

Enables CRC by specified bit-size.

8-bit is supported by Nano version of Tiny library.

Parameters
crccrc type

◆ enableCrc16()

bool tinyproto::Light::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 tinyproto::Light::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.

◆ read() [1/2]

int tinyproto::Light::read ( char *  buf,
int  size 
)

Reads data block from communication channel.

Parameters
buf- buffer to place data read from communication channel
size- maximum size of the buffer in bytes.
Returns
negative value in case of error zero if nothing is read positive - number of bytes read from the channel

◆ read() [2/2]

int tinyproto::Light::read ( IPacket pkt)

Reads packet from communication channel.

Parameters
pkt- Packet object to put data to
See also
Packet
Returns
negative value in case of error zero if nothing is read positive - Packet is successfully received

◆ write() [1/2]

int tinyproto::Light::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 tinyproto::Light::write ( const IPacket pkt)

Sends packet over communication channel.

Parameters
pkt- Packet to send
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 files: