This is basic class for C++ Link Layer objects.
More...
#include <TinyLinkLayer.h>
|
virtual bool | begin (on_frame_read_cb_t onReadCb, on_frame_send_cb_t onSendCb, void *udata)=0 |
| The method initializes the link layer protocol, and connects custom callbacks to link layer. More...
|
|
virtual void | end ()=0 |
| Stops link layer protocol.
|
|
virtual void | runRx ()=0 |
| Runs rx part of the protocol. More...
|
|
virtual void | runTx ()=0 |
| Runs tx part of the protocol. More...
|
|
virtual bool | put (void *buf, int size, uint32_t timeout)=0 |
| Puts new data for sending over the link layer. More...
|
|
virtual void | flushTx ()=0 |
| Flush tx operation if possible.
|
|
void | setTimeout (uint32_t timeout) |
| Sets timeout of Rx/Tx operations in milliseconds for the link layer protocol. More...
|
|
uint32_t | getTimeout () |
| Returns current timeout of Rx/Tx operations.
|
|
int | getMtu () |
| Returns current mtu for the link layer protocol in bytes.
|
|
void | setMtu (int mtu) |
| Set protocol mtu (maximum transmission unit) payload. More...
|
|
virtual | ~ILinkLayer ()=default |
| Default virtual destructor.
|
|
This is basic class for C++ Link Layer objects.
◆ begin()
The method initializes the link layer protocol, and connects custom callbacks to link layer.
Once the new frame is received, onReadCb will be called, once frame is sent onSendCb will be called.
- Parameters
-
onReadCb | callback to call when a frame is received. Remember that processing must be as quick as possible |
onSendCb | callback to call when a frame is sent. |
udata | user defined data, will be passed to callbacks |
- Returns
- true if successful, false is initialization error happened.
Implemented in tinyproto::SerialFdLink, tinyproto::SerialHdlcLink, tinyproto::IHdlcLinkLayer, and tinyproto::IFdLinkLayer.
◆ put()
virtual bool tinyproto::ILinkLayer::put |
( |
void * |
buf, |
|
|
int |
size, |
|
|
uint32_t |
timeout |
|
) |
| |
|
pure virtual |
Puts new data for sending over the link layer.
- Parameters
-
buf | pointer to the buffer with the data |
size | size of the data in the buffer |
timeout | timeout in milliseconds to wait for operation to complete |
- Returns
- true if the data is successfully put to the queue, false if timeout happened or error
Implemented in tinyproto::IHdlcLinkLayer, and tinyproto::IFdLinkLayer.
◆ runRx()
virtual void tinyproto::ILinkLayer::runRx |
( |
| ) |
|
|
pure virtual |
Runs rx part of the protocol.
This method is automatically called by the owner of the protocol (i.e. tinyproto::Proto) The actual implementation on runRx() method depends on hardware channel used.
◆ runTx()
virtual void tinyproto::ILinkLayer::runTx |
( |
| ) |
|
|
pure virtual |
Runs tx part of the protocol.
This method is automatically called by the owner of the protocol (i.e. tinyproto::Proto) The actual implementation on runTx() method depends on hardware channel used.
◆ setMtu()
void tinyproto::ILinkLayer::setMtu |
( |
int |
mtu | ) |
|
|
inline |
Set protocol mtu (maximum transmission unit) payload.
Allowable value depends on the resources of the controller used, and actual low layer protocol. mtu can be configured only before protocol initialization (before calling begin() method)
- Parameters
-
◆ setTimeout()
void tinyproto::ILinkLayer::setTimeout |
( |
uint32_t |
timeout | ) |
|
|
inline |
Sets timeout of Rx/Tx operations in milliseconds for the link layer protocol.
This is not the same timeout, as timeout used by put() method.
- Parameters
-
timeout | timeout in milliseconds for Tx/Rx operations |
The documentation for this class was generated from the following file: