DOKK / manpages / debian 11 / libiio-utils / libiio.3libiio.en
INTRO(3LIBIIO) INTRO(3LIBIIO)

libiio-0.21 - introduction to libiio, a library for interacting with the Linux IIO subsystem and devices

#include <iio.h>

cc file.c -liio

The define IIO_CHECK_REG will warn if return values are not checked. Most libiio functions, if/when a failure occurs will return a negative error number. this warning will ensure these error numbers are looked at. There is nothing more frustraining than calling a function, debugging some hardware, and then eventually realizing there was a typo in an attribute name. This option will force libraries users to at least capture the return value.

cc file.c -DIIO_CHECK_REG -liio

libiio is a library used to interface to the Linux Industrial Input/Output (IIO) Subsystem. The Linux IIO subsystem is intended to provide support for devices that in some sense are analog to digital or digital to analog converters (ADCs, DACs). This includes, but is not limited to ADCs, Accelerometers, Gyros, IMUs, Capacitance to Digital Converters (CDCs), Pressure Sensors, Color, Light and Proximity Sensors, Temperature Sensors, Magnetometers, DACs, DDS (Direct Digital Synthesis), PLLs (Phase Locked Loops), Variable/Programmable Gain Amplifiers (VGA, PGA), and RF transceivers. You can use libiio natively on an embedded Linux target (local mode), or use libiio to communicate remotely to that same target from a host Linux, Windows or MAC over USB, Ethernet or Serial.

The library makes use of C structures and typedefs to promote portability, and is known to run on various GNU/Linux distributions, macOS, Windows, and mbed (via tiny-iiod). The main C structures are:

The scanning context
The information related to a discovered context
Contains the representation of an IIO context
Represents a device in the IIO context
Represents an input or output channel of a device
An input or output buffer, used to read or write samples
Contains the format of a data sample.


The following routines are part of the library. Consult the Doxygen pages for details on their operation (in the SEE ALSO section).

Scan Functions for scanning available contexts

Description
Create a scan context
Destroy the given scan context
Enumerate available contexts
Free a context info list
Get a description of a discovered context
Get the URI of a discovered context
Create a scan block
Destroy the given scan block
Enumerate available contexts via scan block
Get the iio_context_info for a particular context

TopLevel Top-level functions

Description
Get the version of the libiio library
Get a string description of an error code
Check if the specified backend is available
Get the number of available backends
Retrieve the name of a given backend

Context Context

Description
Create a context from local or remote IIO devices
Create a context from local IIO devices (Linux only)
Create a context from XML data in memory
Create a context from XML data in memory
Create a context from the network
Create a context from a URI description
Duplicate a pre-existing IIO context
Destroy the given context
Get the version of the backend in use
Obtain a XML representation of the given context
Get the name of the given context
Get a description of the given context
Get the number of context-specific attributes
Retrieve the value of a context-specific attribute
Retrieve the value of a context-specific attribute
Enumerate the devices found in the given context
Get the device present at the given index
Try to find a device structure by its name of ID
Set a timeout for I/O operations

Device Device

Description
Retrieve a pointer to the iio_context structure
Retrieve the device ID
Retrieve the device name
Enumerate the channels of the given device
Enumerate the device-specific attributes of the given device
Enumerate the buffer-specific attributes of the given device
Get the channel present at the given index
Get the device-specific attribute present at the given index
Get the buffer-specific attribute present at the given index
Try to find a channel structure by its name of ID
Try to find a device-specific attribute by its name
Try to find a buffer-specific attribute by its name
Read the content of the given device-specific attribute
Read the content of all device-specific attributes
Read the content of the given device-specific attribute
Read the content of the given device-specific attribute
Read the content of the given device-specific attribute
Set the value of the given device-specific attribute
Set the value of the given device-specific attribute
Set the values of all device-specific attributes
Set the value of the given device-specific attribute
Set the value of the given device-specific attribute
Set the value of the given device-specific attribute
Read the content of the given buffer-specific attribute
Read the content of all buffer-specific attributes
Read the content of the given buffer-specific attribute
Read the content of the given buffer-specific attribute
Read the content of the given buffer-specific attribute
Set the value of the given buffer-specific attribute
Set the value of the given buffer-specific attribute
Set the values of all buffer-specific attributes
Set the value of the given buffer-specific attribute
Set the value of the given buffer-specific attribute
Set the value of the given buffer-specific attribute
Associate a pointer to an iio_device structure
Retrieve a previously associated pointer of an iio_device structure
Retrieve the trigger of a given device
Associate a trigger to a given device
Return True if the given device is a trigger
Configure the number of kernel buffers for a device

Channel Channel

Description
Retrieve a pointer to the iio_device structure
Retrieve the channel ID
Retrieve the channel name
Return True if the given channel is an output channel
Return True if the given channel is a scan element
Enumerate the channel-specific attributes of the given channel
Get the channel-specific attribute present at the given index
Try to find a channel-specific attribute by its name
Retrieve the filename of an attribute
Read the content of the given channel-specific attribute
Read the content of all channel-specific attributes
Read the content of the given channel-specific attribute
Read the content of the given channel-specific attribute
Read the content of the given channel-specific attribute
Set the value of the given channel-specific attribute
Set the value of the given channel-specific attribute
Set the values of all channel-specific attributes
Set the value of the given channel-specific attribute
Set the value of the given channel-specific attribute
Set the value of the given channel-specific attribute
Enable the given channel
Disable the given channel
Returns True if the channel is enabled
Demultiplex the samples of a given channel
Demultiplex and convert the samples of a given channel
Multiplex the samples of a given channel
Convert and multiplex the samples of a given channel
Associate a pointer to an iio_channel structure
Get a pointer to a channel's data format structure
Get the type of the given channel
Get the modifier type of the given channel

Buffer Buffer

Description
Retrieve a pointer to the iio_device structure
Create an input or output buffer associated to the given device
Destroy the given buffer
Get a pollable file descriptor
Make iio_buffer_refill() and iio_buffer_push() blocking or not
Cancel all buffer operations
Cancel all buffer operations
Send a given number of samples to the hardware
Cancel all buffer operations
Get the start address of the buffer
Find the first sample of a channel in a buffer
Get the step size between two samples of one channel
Get the address that follows the last sample in a buffer
Call the supplied callback for each sample found in a buffer
Associate a pointer to an iio_buffer structure
Retrieve a previously associated pointer of an iio_buffer structure

Debug Debug and low-level functions

Description
Get the current sample size
Get the index of the given channel
Get a pointer to a channel's data format structure
Convert the sample from host format to hardware format
Convert the sample from host format to hardware format
Enumerate the debug attributes of the given device
Get the debug attribute present at the given index
Try to find a debug attribute by its name
Read the content of the given debug attribute
Read the content of all debug attributes
Set the value of the given debug attribute
Set the value of the given debug attribute
Set the values of all debug attributes
Read the content of the given debug attribute
Read the content of the given debug attribute
Read the content of the given debug attribute
Set the value of the given debug attribute
Set the value of the given debug attribute
Set the value of the given debug attribute
Identify the channel or debug attribute corresponding to a filename
Set the value of a hardware register
Get the value of a hardware register

All error codes are returned as negative number return codes. In these cases, the value can be passed to the iio_strerror routine.

iio_attr(1), iio_info(1), iio_readdev(1), iio_writedev(1), iio_reg(1)

libiio home page:
https://wiki.analog.com/resources/tools-software/linux-software/libiio

libiio code:
https://github.com/analogdevicesinc/libiio

Doxygen for libiio:
https://analogdevicesinc.github.io/libiio/

Kernel Doc:
https://www.kernel.org/doc/html/latest/driver-api/iio/index.html https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-iio

All bugs are tracked at: https://github.com/analogdevicesinc/libiio/issues

The libiio source code and resulting binaries (libraries) are released and distributed under the GNU Lesser General Public License, v2.1 or (at your option) any later version.
The libiio test and example application(s) source code and resulting binaries (executables) are released and distributed under the GNU General Public License, v2.0 or (at your option) any later version.
The libiio man pages are released and distributed under the Creative Commons Attribution-ShareAlike 4.0 International Public License.

19 November 2020 libiio-0.21