|
void | tiny_enable_uid (STinyData *handle, uint8_t on) |
| The function enables uid support. Enables uid support. The function affects on tiny_on_rx_byte and on_frame_cb_t behavior. More...
|
|
int | tiny_set_fcs_bits (STinyData *handle, uint8_t bits) |
|
int | tiny_on_rx_byte (STinyData *handle, uint8_t *pbuf, int len, uint8_t byte) |
| The function processes one rx byte. Used in event-based mode. This function processes single received byte. If new frame is completely received, read_cb handler is called and application can take actions on receive frame. Refer to tiny_set_callbacks. More...
|
|
int | tiny_send_start (STinyData *handle, uint8_t flags) |
| initiates sending of a new frame More...
|
|
int | tiny_send_buffer (STinyData *handle, uint8_t *pbuf, int len, uint8_t flags) |
| sends user provided data in the body of the frame More...
|
|
int | tiny_send_end (STinyData *handle, uint8_t flags) |
| completes sending of a new frame More...
|
|
void | tiny_send_terminate (STinyData *handle) |
| terminates send operation More...
|
|
int | tiny_read_start (STinyData *handle, uint8_t flags) |
| initiates receiving of a new frame More...
|
|
int | tiny_read_buffer (STinyData *handle, uint8_t *pbuf, int len, uint8_t flags) |
| reads frame payload to provided buffer More...
|
|
void | tiny_read_terminate (STinyData *handle) |
| terminates read operation More...
|
|
int | tiny_lock (STinyData *handle, uint8_t flags) |
| locks Tiny state machine for send operations More...
|
|
void | tiny_unlock (STinyData *handle) |
| unlock Tiny state machine for send operations More...
|
|
int | tiny_set_callbacks (STinyData *handle, on_frame_cb_t read_cb, on_frame_cb_t send_cb) |
| set callbacks for processing frames The function sets callback procs for specified Tiny channel. callbacks will receive all data being sent or received. More...
|
|
int | tiny_get_callbacks (STinyData *handle, on_frame_cb_t *read_cb, on_frame_cb_t *send_cb) |
| returns callbacks assigned for frame processing The function returns set callbacks. More...
|
|
int | tiny_get_stat (STinyData *handle, STinyStats *stat) |
|
int | tiny_clear_stat (STinyData *handle) |
|
int tiny_read_buffer |
( |
STinyData * |
handle, |
|
|
uint8_t * |
pbuf, |
|
|
int |
len, |
|
|
uint8_t |
flags |
|
) |
| |
reads frame payload to provided buffer
The function reads frame payload to provided buffer. Without TINY_FLAG_READ_ALL the function reads no more byte than len, passed to the function. If provided buffer is filled completely, but there are more bytes to read, then the function returns TINY_ERR_DATA_TOO_LARGE (indicating that tiny_read_buffer must be called once again for next portion of bytes). Otherwise, tiny_read_buffer() returns number of bytes contained in the received frame.
If frame payload is too big to fit to provided buffer, but it is required to read whole frame from the communication channel till the end marker, TINY_FLAG_READ_ALL can be specified. In this case, the function will fill provided buffer with frame bytes, and bytes in the end of frame will be lost. The function returns TINY_ERR_DATA_TOO_LARGE, but this means that frame data didn't fit to buffer, and frame is completely received.
If function is in non-blocking mode, it may return immediately with TINY_NO_ERROR. In this case a user should call this function later with the same parameters.
- Note
- if flags field is set to TINY_FLAG_NO_WAIT, then this function may remember pbuf pointer and return immediately. So, it is responsibility of the caller to make pbuf to be available all the time until block of data is received.
-
The read data can be considered as valid, only when last buffer is successfully read. That is tiny_read_buffer function returns length of read bytes (>0), or tiny_read_buffer function returns TINY_ERR_DATA_TOO_LARGE if TINY_FLAG_READ_ALL flag is specified.
- Parameters
-
handle | - pointer to Tiny data. |
pbuf | - pointer to buffer to read frame data to. |
len | - length of the provided buffer in bytes. |
flags | - TINY_FLAG_NO_WAIT or TINY_FLAG_WAIT_FOREVER, can be combined with TINY_FLAG_READ_ALL |
- Returns
- length in bytes of data received if executed successfully TINY_ERR_AGAIN if non-blocking operation is requested and the channel is busy TINY_ERR_FAILED if writing to the channel failed TINY_ERR_INVALID_DATA if invalid handle is passed TINY_ERR_DATA_TOO_LARGE if all data do not fit in buffer.
- See also
- TINY_SUCCESS
-
TINY_ERR_INVALID_DATA
-
TINY_ERR_FAILED
-
TINY_ERR_DATA_TOO_LARGE
-
TINY_FLAG_NO_WAIT
-
TINY_FLAG_WAIT_FOREVER
-
TINY_FLAG_READ_ALL
- Warning
- any failed read operation (tiny_read_buffer), except TINY_ERR_DATA_TOO_LARGE and TINY_ERR_AGAIN case, must be terminated with tiny_read_terminate.