libiio
Classes | Functions
Buffer

Classes

struct  iio_buffer
 An input or output buffer, used to read or write samples. More...
 

Functions

__api __check_ret __pure const struct iio_deviceiio_buffer_get_device (const struct iio_buffer *buf)
 Retrieve a pointer to the iio_device structure. More...
 
__api __check_ret struct iio_bufferiio_device_create_buffer (const struct iio_device *dev, unsigned int idx, const struct iio_channels_mask *mask)
 Create an input or output buffer associated to the given device. More...
 
__api void iio_buffer_set_data (struct iio_buffer *buf, void *data)
 Associate a pointer to an iio_buffer structure. More...
 
__api void * iio_buffer_get_data (const struct iio_buffer *buf)
 Retrieve a previously associated pointer of an iio_buffer structure. More...
 
__api void iio_buffer_destroy (struct iio_buffer *buf)
 Destroy the given buffer. More...
 
__api void iio_buffer_cancel (struct iio_buffer *buf)
 Cancel all buffer operations. More...
 
__api __check_ret int iio_buffer_enable (struct iio_buffer *buf)
 Enable the buffer. More...
 
__api int iio_buffer_disable (struct iio_buffer *buf)
 Disable the buffer. More...
 
__api const struct iio_channels_maskiio_buffer_get_channels_mask (const struct iio_buffer *buf)
 Retrieve a mask of the channels enabled for the given buffer. More...
 

Detailed Description

Function Documentation

◆ iio_buffer_cancel()

__api void iio_buffer_cancel ( struct iio_buffer buf)

Cancel all buffer operations.

Parameters
bufThe buffer for which operations should be canceled

This function cancels all outstanding buffer operations previously scheduled. This means that any pending iio_block_enqueue() or iio_block_dequeue() operation will abort and return immediately, any further invocation of these functions on the same buffer will return immediately with an error.

Usually iio_block_dequeue() will block until all data has been transferred or a timeout occurs. This can depending on the configuration take a significant amount of time. iio_buffer_cancel() is useful to bypass these conditions if the buffer operation is supposed to be stopped in response to an external event (e.g. user input).

To be able to transfer additional data after calling this function the buffer should be destroyed and then re-created.

This function can be called multiple times for the same buffer, but all but the first invocation will be without additional effect.

This function is thread-safe, but not signal-safe, i.e. it must not be called from a signal handler.

◆ iio_buffer_destroy()

__api void iio_buffer_destroy ( struct iio_buffer buf)

Destroy the given buffer.

Parameters
bufA pointer to an iio_buffer structure

◆ iio_buffer_disable()

__api int iio_buffer_disable ( struct iio_buffer buf)

Disable the buffer.

Parameters
bufA pointer to an iio_buffer structure
Returns
On success, 0
On error, a negative error code is returned

◆ iio_buffer_enable()

__api __check_ret int iio_buffer_enable ( struct iio_buffer buf)

Enable the buffer.

Parameters
bufA pointer to an iio_buffer structure
Returns
On success, 0
On error, a negative error code is returned

◆ iio_buffer_get_channels_mask()

__api const struct iio_channels_mask* iio_buffer_get_channels_mask ( const struct iio_buffer buf)

Retrieve a mask of the channels enabled for the given buffer.

Parameters
bufA pointer to an iio_buffer structure
Returns
A pointer to an iio_channels_mask structure

NOTE: The mask returned may contain more enabled channels than the mask used for creating the buffer.

◆ iio_buffer_get_data()

__api void* iio_buffer_get_data ( const struct iio_buffer buf)

Retrieve a previously associated pointer of an iio_buffer structure.

Parameters
bufA pointer to an iio_buffer structure
Returns
The pointer previously associated if present, or NULL

◆ iio_buffer_get_device()

__api __check_ret __pure const struct iio_device* iio_buffer_get_device ( const struct iio_buffer buf)

Retrieve a pointer to the iio_device structure.

Parameters
bufA pointer to an iio_buffer structure
Returns
A pointer to an iio_device structure

◆ iio_buffer_set_data()

__api void iio_buffer_set_data ( struct iio_buffer buf,
void *  data 
)

Associate a pointer to an iio_buffer structure.

Parameters
bufA pointer to an iio_buffer structure
dataThe pointer to be associated

◆ iio_device_create_buffer()

__api __check_ret struct iio_buffer* iio_device_create_buffer ( const struct iio_device dev,
unsigned int  idx,
const struct iio_channels_mask mask 
)

Create an input or output buffer associated to the given device.

Parameters
devA pointer to an iio_device structure
idxThe index of the hardware buffer. Should be 0 in most cases.
maskA pointer to an iio_channels_mask structure
Returns
On success, a pointer to an iio_buffer structure
On failure, a pointer-encoded error is returned