libiio 0.24
Library for interfacing with IIO devices
Buffer

Data Structures

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, size_t samples_count, bool cyclic)
 Create an input or output buffer associated to the given device. More...
 
__api void iio_buffer_destroy (struct iio_buffer *buf)
 Destroy the given buffer. More...
 
__api __check_ret int iio_buffer_get_poll_fd (struct iio_buffer *buf)
 Get a pollable file descriptor. More...
 
__api __check_ret int iio_buffer_set_blocking_mode (struct iio_buffer *buf, bool blocking)
 Make iio_buffer_refill() and iio_buffer_push() blocking or not. More...
 
__api __check_ret ssize_t iio_buffer_refill (struct iio_buffer *buf)
 Fetch more samples from the hardware. More...
 
__api __check_ret ssize_t iio_buffer_push (struct iio_buffer *buf)
 Send the samples to the hardware. More...
 
__api __check_ret ssize_t iio_buffer_push_partial (struct iio_buffer *buf, size_t samples_count)
 Send a given number of samples to the hardware. More...
 
__api void iio_buffer_cancel (struct iio_buffer *buf)
 Cancel all buffer operations. More...
 
__api void * iio_buffer_start (const struct iio_buffer *buf)
 Get the start address of the buffer. More...
 
__api void * iio_buffer_first (const struct iio_buffer *buf, const struct iio_channel *chn)
 Find the first sample of a channel in a buffer. More...
 
__api __check_ret ptrdiff_t iio_buffer_step (const struct iio_buffer *buf)
 Get the step size between two samples of one channel. More...
 
__api void * iio_buffer_end (const struct iio_buffer *buf)
 Get the address that follows the last sample in a buffer. More...
 
__api __check_ret ssize_t iio_buffer_foreach_sample (struct iio_buffer *buf, ssize_t(*callback)(const struct iio_channel *chn, void *src, size_t bytes, void *d), void *data)
 Call the supplied callback for each sample found in a buffer. 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...
 

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 any pending iio_buffer_push() or iio_buffer_refill() operation will abort and return immediately, any further invocations of these functions on the same buffer will return immediately with an error.

Usually iio_buffer_push() and iio_buffer_refill() will block until either 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 capture 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