CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
fifo_api.h File Reference

The declarations in this header file correspond to the definitions in fifo.c. More...

#include <stdbool.h>
#include <stdint.h>
#include "cdi_core_api.h"
#include "cdi_os_api.h"

Go to the source code of this file.

Data Structures

struct  CdiFifoFullCbData
 A structure of this type is passed as the parameter to CdiFifoFullCallback(). More...
 
struct  CdiFifoCbData
 A structure of this type is passed as the parameter to CdiFifoCallback(). It contains the state of a single FIFO read or write operation. More...
 

Typedefs

typedef struct CdiFifoStateCdiFifoHandle
 Type used as the handle (pointer to an opaque structure) for a FIFO. Each handle represents a instance of a FIFO.
 
typedef void(* CdiFifoFullCallback) (const CdiFifoFullCbData *cb_data_ptr)
 Prototype of FIFO write callback function. It is invoked whenever CdiFifoWrite() is used to write to a full FIFO.
 
typedef void(* CdiFifoCallback) (const CdiFifoCbData *data_ptr)
 Prototype of FIFO debug callback function.
 

Functions

CDI_INTERFACE bool CdiFifoCreate (const char *name_str, int item_count, int item_byte_size, CdiFifoFullCallback full_cb_ptr, CdiUserCbParameter full_user_cb_param, CdiFifoHandle *ret_handle_ptr)
 
CDI_INTERFACE bool CdiFifoRead (CdiFifoHandle handle, int timeout_ms, CdiSignalType abort_wait_signal, void *item_dest_ptr)
 
CDI_INTERFACE void CdiFifoFlush (CdiFifoHandle handle)
 
CDI_INTERFACE bool CdiFifoWrite (CdiFifoHandle handle, int timeout_ms, CdiSignalType abort_wait_signal, const void *item_ptr)
 
CDI_INTERFACE const char * CdiFifoGetName (CdiFifoHandle handle)
 
CDI_INTERFACE void CdiFifoDestroy (CdiFifoHandle handle)
 

Detailed Description

The declarations in this header file correspond to the definitions in fifo.c.

Typedef Documentation

◆ CdiFifoCallback

typedef void(* CdiFifoCallback) (const CdiFifoCbData *data_ptr)

Prototype of FIFO debug callback function.

This callback function is invoked whenever an item is written to or read from the FIFO.

Parameters
data_ptrA pointer to an CdiFifoCbData structure.

◆ CdiFifoFullCallback

typedef void(* CdiFifoFullCallback) (const CdiFifoFullCbData *cb_data_ptr)

Prototype of FIFO write callback function. It is invoked whenever CdiFifoWrite() is used to write to a full FIFO.

Parameters
cb_data_ptrA pointer to an CdiFifoFullCbData structure.

Function Documentation

◆ CdiFifoCreate()

CDI_INTERFACE bool CdiFifoCreate ( const char * name_str,
int item_count,
int item_byte_size,
CdiFifoFullCallback full_cb_ptr,
CdiUserCbParameter full_user_cb_param,
CdiFifoHandle * ret_handle_ptr )

Create a FIFO.

Parameters
name_strPointer to name of FIFO to copy to the new FIFO instance.
item_countNumber of items in the FIFO (FIFO depth).
item_byte_sizeSize of each item in bytes.
full_cb_ptrAddress of callback function invoked when the FIFO is full and CdiFifoWrite() is used. Specify NULL if not used.
full_user_cb_paramUser defined parameter used in structure passed to full_cb_ptr.
ret_handle_ptrPointer to returned handle of the new FIFO.
Returns
true if successful, otherwise false (not enough memory to allocate the FIFO).

◆ CdiFifoDestroy()

CDI_INTERFACE void CdiFifoDestroy ( CdiFifoHandle handle)

Destroy a FIFO.

Parameters
handleFIFO handle.

◆ CdiFifoFlush()

CDI_INTERFACE void CdiFifoFlush ( CdiFifoHandle handle)

Flush all entries from the FIFO.

Parameters
handleFIFO handle.

◆ CdiFifoGetName()

CDI_INTERFACE const char * CdiFifoGetName ( CdiFifoHandle handle)

Get name of FIFO that was defined when FIFO was created.

Parameters
handleFIFO handle.

◆ CdiFifoRead()

CDI_INTERFACE bool CdiFifoRead ( CdiFifoHandle handle,
int timeout_ms,
CdiSignalType abort_wait_signal,
void * item_dest_ptr )

Read an item from the FIFO buffer and copy to item_dest_ptr.

Parameters
handleFIFO handle.
timeout_msIf FIFO is empty, this is the number of milliseconds to wait for data before returning.
abort_wait_signalOptional signal used to abort the read if the FIFO is empty. Use NULL to specific no signal.
item_dest_ptrPointer to buffer where to copy the item to. Size of buffer must be large enough to hold the data. Data size was set when the FIFO was created (see item_byte_size).
Returns
true if successful, otherwise false (FIFO is empty).

◆ CdiFifoWrite()

CDI_INTERFACE bool CdiFifoWrite ( CdiFifoHandle handle,
int timeout_ms,
CdiSignalType abort_wait_signal,
const void * item_ptr )

Write an item to the FIFO.

Parameters
handleFIFO handle.
timeout_msIf FIFO is full, this is the number of milliseconds to wait for an open entry before returning.
abort_wait_signalOptional signal used to abort the write if the FIFO is full. Use NULL to specific no signal.
item_ptrPointer where to copy the item from.
Returns
true if successful, otherwise false (FIFO is full).