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

This is special class for Full duplex protocol, which allocates buffers dynamically. More...

#include <TinyProtocolFd.h>

Inheritance diagram for tinyproto::FdD:
Inheritance graph
[legend]
Collaboration diagram for tinyproto::FdD:
Collaboration graph
[legend]

Public Member Functions

 FdD (int size)
 Creates instance of Full duplex protocol with dynamically allocated buffer. More...
 
- Public Member Functions inherited from tinyproto::IFd
 IFd (void *buffer, int bufferSize)
 Initializes IFd object. More...
 
void begin ()
 Initializes protocol internal variables. More...
 
void end ()
 Resets protocol state.
 
int write (const char *buf, int size)
 Sends data block over communication channel. More...
 
int write (const IPacket &pkt)
 Sends packet over communication channel. More...
 
int run_rx (const void *data, int len)
 Processes incoming rx data, specified by a user. More...
 
int run_rx (read_block_cb_t read_func)
 Read data from communication channel using read_func and parses bytes to find hdlc messages. More...
 
int run_tx (write_block_cb_t write_func)
 Attempts to send out data via write_func function. More...
 
int run_tx (void *data, int max_size)
 Force protocol to generate tx data for you. 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...
 
void setReceiveCallback (void(*on_receive)(void *userData, uint8_t addr, IPacket &pkt)=nullptr)
 Sets receive callback for incoming messages. More...
 
void setSendCallback (void(*on_send)(void *userData, uint8_t addr, IPacket &pkt)=nullptr)
 Sets send callback for outgoing messages. More...
 
void setConnectEventCallback (void(*on_connect)(void *userData, uint8_t addr, bool connected)=nullptr)
 Sets connect/disconnect callback. More...
 
void setWindowSize (uint8_t window)
 Sets desired window size. More...
 
void setSendTimeout (uint16_t timeout)
 Sets send timeout in milliseconds. More...
 
void setUserData (void *userData)
 Sets user data to pass to callbacks. More...
 
tiny_fd_handle_t getHandle ()
 Returns low-level handle for full duplex protocol.
 
int getStatus ()
 Returns status of the protocol.
 

Additional Inherited Members

- Protected Member Functions inherited from tinyproto::IFd
virtual void onReceive (uint8_t addr, uint8_t *pdata, int size)
 Method called by hdlc protocol upon receiving new frame. More...
 
virtual void onSend (uint8_t addr, const uint8_t *pdata, int size)
 Method called by hdlc protocol upon sending next frame. More...
 
virtual void onConnectEvent (uint8_t addr, bool connected)
 Method called by fd protocol when connect/disconnect event takes place. More...
 

Detailed Description

This is special class for Full duplex protocol, which allocates buffers dynamically.

We need to have separate class for this, as on small microcontrollers dynamic allocation in basic class increases flash consumption, even if dynamic memory is not used.

Constructor & Destructor Documentation

◆ FdD()

tinyproto::FdD::FdD ( int  size)
inlineexplicit

Creates instance of Full duplex protocol with dynamically allocated buffer.

Use this class only on powerful microcontrollers.


The documentation for this class was generated from the following file: