Tiny protocol  0.9.0
Tiny communication protocol for microcontrollers
Public Member Functions | List of all members
Tiny::ProtoHd Class Reference

#include <TinyProtocolHd.h>

Public Member Functions

 ProtoHd (void *buffer, int bufferSize, void(*onReceive)(uint8_t *buf, int len))
 
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)
 
int write (IPacket &pkt)
 
int run ()
 
void disableCrc ()
 
bool enableCheckSum ()
 
bool enableCrc16 ()
 
bool enableCrc32 ()
 

Detailed Description

ProtoHd class incapsulates Half Duplex Protocol functionality. Half Duplex 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.

Constructor & Destructor Documentation

◆ ProtoHd()

Tiny::ProtoHd::ProtoHd ( void *  buffer,
int  bufferSize,
void(*)(uint8_t *buf, int len)  onReceive 
)
inline

Initializes ProtoHd object

Parameters
buffer- buffer to store the frames being received.
bufferSize- size of the buffer
onReceive- callback to call when the frame is received completely.

Member Function Documentation

◆ begin()

void Tiny::ProtoHd::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

◆ beginToSerial()

void Tiny::ProtoHd::beginToSerial ( )
inline

Initializes protocol internal variables and redirects communication through Arduino Serial connection (Serial).

Returns
None

◆ beginToSerial1()

void Tiny::ProtoHd::beginToSerial1 ( )
inline

Initializes protocol internal variables and redirects communication through Arduino Serial1 connection (Serial1).

Returns
None

◆ beginToSerial2()

void Tiny::ProtoHd::beginToSerial2 ( )
inline

Initializes protocol internal variables and redirects communication through Arduino Serial2 connection (Serial2).

Returns
None

◆ beginToSerial3()

void Tiny::ProtoHd::beginToSerial3 ( )
inline

Initializes protocol internal variables and redirects communication through Arduino Serial3 connection (Serial3).

Returns
None

◆ disableCrc()

void Tiny::ProtoHd::disableCrc ( )

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

◆ enableCheckSum()

bool Tiny::ProtoHd::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.

◆ enableCrc16()

bool Tiny::ProtoHd::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::ProtoHd::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::ProtoHd::end ( )

Resets protocol state.

◆ run()

int Tiny::ProtoHd::run ( )

Checks communcation channel for incoming messages.

Returns
negative value in case of error zero if nothing is read positive - Packet is successfully received
Remarks
if Packet is receive during run execution callback is called.

◆ write() [1/2]

int Tiny::ProtoHd::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::ProtoHd::write ( 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 file: