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

This file contains definitions and implementation for a simple FIFO. More...

#include "fifo_api.h"
#include <stddef.h>
#include <assert.h>
#include "configuration.h"
#include "cdi_os_api.h"

Data Structures

struct  CdiFifoState
 Structure used to hold state data for a single FIFO. More...
 

Functions

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)
 
void CdiFifoFlush (CdiFifoHandle handle)
 
bool CdiFifoRead (CdiFifoHandle handle, int timeout_ms, CdiSignalType abort_wait_signal, void *item_dest_ptr)
 
bool CdiFifoWrite (CdiFifoHandle handle, int timeout_ms, CdiSignalType abort_wait_signal, const void *data_ptr)
 
const char * CdiFifoGetName (CdiFifoHandle handle)
 
void CdiFifoDestroy (CdiFifoHandle handle)
 

Detailed Description

This file contains definitions and implementation for a simple FIFO.

Function Documentation

◆ CdiFifoCreate()

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()

void CdiFifoDestroy ( CdiFifoHandle handle)

Destroy a FIFO.

Parameters
handleFIFO handle.

◆ CdiFifoFlush()

void CdiFifoFlush ( CdiFifoHandle handle)

Flush all entries from the FIFO.

Parameters
handleFIFO handle.

◆ CdiFifoGetName()

const char * CdiFifoGetName ( CdiFifoHandle handle)

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

Parameters
handleFIFO handle.

◆ CdiFifoRead()

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()

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).