Tiny protocol  0.9.3
Tiny communication protocol for microcontrollers
Classes | Typedefs | Functions
Tiny Full Duplex API functions

Classes

struct  tiny_fd_init_t_
 
class  Tiny::IProtoFd
 

Typedefs

typedef struct tiny_fd_data_t * tiny_fd_handle_t
 
typedef struct tiny_fd_init_t_ tiny_fd_init_t
 

Functions

int tiny_fd_init (tiny_fd_handle_t *handle, tiny_fd_init_t *init)
 Initialized communication for Tiny Full Duplex protocol. More...
 
void tiny_fd_close (tiny_fd_handle_t handle)
 stops Tiny Full Duplex state machine More...
 
int tiny_fd_run_tx (tiny_fd_handle_t handle, uint16_t timeout)
 runs tx processing for specified period of time. More...
 
int tiny_fd_run_rx (tiny_fd_handle_t handle, uint16_t timeout)
 runs rx processing for specified period of time. More...
 
int tiny_fd_send (tiny_fd_handle_t handle, const void *buf, int len)
 Sends userdata over full-duplex protocol. More...
 
int tiny_fd_buffer_size_by_mtu (int mtu, int max_tx_frames)
 
void tiny_fd_set_ka_timeout (tiny_fd_handle_t handle, uint32_t keep_alive)
 

Detailed Description

Typedef Documentation

◆ tiny_fd_handle_t

typedef struct tiny_fd_data_t* tiny_fd_handle_t

This handle points to service data, required for full-duplex functioning.

◆ tiny_fd_init_t

This structure is used for initialization of Tiny Full Duplex protocol.

Function Documentation

◆ tiny_fd_buffer_size_by_mtu()

int tiny_fd_buffer_size_by_mtu ( int  mtu,
int  max_tx_frames 
)

Returns minimum required buffer size for specified parameters.

Parameters
mtusize of desired user payload in bytes.
max_tx_framesmaximum tx queue size of I-frames.

◆ tiny_fd_close()

void tiny_fd_close ( tiny_fd_handle_t  handle)

stops Tiny Full Duplex state machine

stops Tiny Full Duplex state machine.

Parameters
handlehandle of full-duplex protocol

◆ tiny_fd_init()

int tiny_fd_init ( tiny_fd_handle_t handle,
tiny_fd_init_t init 
)

Initialized communication for Tiny Full Duplex protocol.

The function initializes internal structures for Tiny Full Duplex state machine.

Parameters
handle- pointer to Tiny Full Duplex data
init- pointer to tiny_fd_init_t data.
Returns
TINY_NO_ERROR in case of success. TINY_ERR_FAILED if init parameters are incorrect.
Remarks
This function is not thread safe.

◆ tiny_fd_run_rx()

int tiny_fd_run_rx ( tiny_fd_handle_t  handle,
uint16_t  timeout 
)

runs rx processing for specified period of time.

Runs rx processing for specified period of time. After timeout happens, the function returns. If you need it to run in non-blocking mode, please using timeout 0 ms.

Parameters
handlehandle of full-duplex protocol
timeoutmaximum timeout in milliseconds to perform rx operations

◆ tiny_fd_run_tx()

int tiny_fd_run_tx ( tiny_fd_handle_t  handle,
uint16_t  timeout 
)

runs tx processing for specified period of time.

Runs tx processing for specified period of time. After timeout happens, the function returns. If you need it to run in non-blocking mode, please use timeout 0 ms.

Warning
this function actually sends data to the communication channel. tiny_fd_send() puts data to queue, but doesn't really send them.
Parameters
handlehandle of full-duplex protocol
timeoutmaximum timeout in milliseconds to perform tx operations

◆ tiny_fd_send()

int tiny_fd_send ( tiny_fd_handle_t  handle,
const void *  buf,
int  len 
)

Sends userdata over full-duplex protocol.

Sends userdata over full-duplex protocol. Note, that this command will return success, when data are copied to internal queue. That doesn't mean that data physically sent, but they are enqueued for sending.

When timeout happens, the data were not actually enqueued. Call this function once again. If TINY_ERR_DATA_TOO_LARGE is returned, try to send less data. If you don't want to care about data size, please, use different function tiny_fd_write()..

Parameters
handlepointer to tiny_fd_handle_t
bufdata to send
lenlength of data to send
Returns
Success result or error code:
  • TINY_SUCCESS if user data are put to internal queue.
  • TINY_ERR_TIMEOUT if no room in internal queue to put data. Retry operation once again.
  • TINY_ERR_FAILED if request was cancelled, by tiny_fd_close() or other error happened.
  • TINY_ERR_DATA_TOO_LARGE if user data are too big to fit in tx buffer.

◆ tiny_fd_set_ka_timeout()

void tiny_fd_set_ka_timeout ( tiny_fd_handle_t  handle,
uint32_t  keep_alive 
)

Sets keep alive timeout in milliseconds. This timeout is used to send special RR frames, when no user data queued for sending.

Parameters
handlepointer to tiny_fd_handle_t
keep_alivetimeout in milliseconds