tinyproto
Classes | Macros | Functions
Tiny light protocol API functions

Classes

struct  STinyLightData
 This structure contains information about communication channel and its state. More...
 
class  tinyproto::Light
 ProtoLight class incapsulates Protocol functionality. More...
 

Macros

#define LIGHT_BUF_SIZE   (sizeof(uintptr_t) * 18)
 This macro defines buffer size required for tiny light protocol.
 

Functions

int tiny_light_init (STinyLightData *handle, write_block_cb_t write_func, read_block_cb_t read_func, void *pdata)
 The function initializes internal structures for Tiny channel and return handle to be used with all Tiny and IPC functions. More...
 
int tiny_light_close (STinyLightData *handle)
 The function closes channel. More...
 
int tiny_light_send (STinyLightData *handle, const uint8_t *pbuf, int len)
 sends frame with user payload to communication channel in blocking mode More...
 
int tiny_light_read (STinyLightData *handle, uint8_t *pbuf, int len)
 reads frame from the channel in blocking mode. More...
 
hdlc_ll_handle_t tiny_light_get_hdlc (STinyLightData *handle)
 returns lower level hdlc handle. More...
 

Detailed Description

Function Documentation

◆ tiny_light_close()

int tiny_light_close ( STinyLightData handle)

The function closes channel.

Parameters
handle- pointer to Tiny Light data.
See also
tiny_init()
Returns
TINY_ERR_INVALID_DATA, TINY_NO_ERROR.
Remarks
This function is not thread safe.

◆ tiny_light_get_hdlc()

hdlc_ll_handle_t tiny_light_get_hdlc ( STinyLightData handle)

returns lower level hdlc handle.

Returns lower level hdlc handle to use with low level function. If you use high level light API, please be careful with low-level hdlc functions in case you mix the calls.

Parameters
handle- pointer to Tiny Light data.
Returns
hdlc handle or NULL

◆ tiny_light_init()

int tiny_light_init ( STinyLightData handle,
write_block_cb_t  write_func,
read_block_cb_t  read_func,
void *  pdata 
)

The function initializes internal structures for Tiny channel and return handle to be used with all Tiny and IPC functions.

Parameters
handle- pointer to Tiny Light data
write_func- pointer to write data function (to communication channel).
read_func- pointer to read function (from communication channel). read_func is not required and should be NULL, if event-based API of Tiny Protocol is used.
pdata- pointer to a user private data. This pointer is passed to write_func/read_func.
See also
write_block_cb_t
read_block_cb_t
Returns
TINY_NO_ERROR or error code.
Remarks
This function is not thread safe.

◆ tiny_light_read()

int tiny_light_read ( STinyLightData handle,
uint8_t *  pbuf,
int  len 
)

reads frame from the channel in blocking mode.

The function reads user data from communication channel

Parameters
handle- pointer to Tiny Light data.
pbufa const pointer to unsigned char - buffer with data to send
lenan integer argument - length of data to send
See also
TINY_ERR_INVALID_DATA
TINY_ERR_FAILED
TINY_ERR_DATA_TOO_LARGE
TINY_ERR_OUT_OF_SYNC
TINY_ERR_BUSY
Returns
TINY_ERR_INVALID_DATA, TINY_ERR_FAILED, TINY_ERR_OUT_OF_SYNC, TINY_ERR_BUSY, TINY_ERR_DATA_TOO_LARGE or number of sent bytes.
Note
TINY_ERR_DATA_TOO_LARGE can be returned in successful case. If frame is received, but passed buffer to the function is too small to fit all.
Remarks
This function is not thread safe.

◆ tiny_light_send()

int tiny_light_send ( STinyLightData handle,
const uint8_t *  pbuf,
int  len 
)

sends frame with user payload to communication channel in blocking mode

The function sends data to communication channel. The function works in blocking mode, i.e. it returns control only if user data are successfully sent, or in case of error.

Parameters
handle- pointer to Tiny Light data.
pbuf- a const pointer to unsigned char - buffer with data to send
len- an integer argument - length of data to send
See also
TINY_ERR_INVALID_DATA
TINY_ERR_FAILED
Returns
TINY_ERR_INVALID_DATA, TINY_ERR_FAILED or number of sent bytes.
Remarks
This function is thread safe.