libiio - Man Page
introduction to libiio, a library for interacting with the Linux IIO subsystem and devices
Synopsis
#include <iio.h>
cc file.c -liio
Options
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
Description
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.
Data Types
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:
- iio_scan_context
The scanning context
- iio_context_info
The information related to a discovered context
- iio_context
Contains the representation of an IIO context
- iio_device
Represents a device in the IIO context
- iio_channel
Represents an input or output channel of a device
- iio_buffer
An input or output buffer, used to read or write samples
- iio_data_format
Contains the format of a data sample.
List of Routines
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
- Function
Description
- iio_create_scan_context
Create a scan context
- iio_scan_context_destroy
Destroy the given scan context
- iio_scan_context_get_info_list
Enumerate available contexts
- iio_context_info_list_free
Free a context info list
- iio_context_info_get_description
Get a description of a discovered context
- iio_context_info_get_uri
Get the URI of a discovered context
- iio_create_scan_block
Create a scan block
- iio_scan_block_destroy
Destroy the given scan block
- iio_scan_block_scan
Enumerate available contexts via scan block
- iio_scan_block_get_info
Get the iio_context_info for a particular context
TopLevel Top-level functions
- Function
Description
- iio_library_get_version
Get the version of the libiio library
- iio_strerror
Get a string description of an error code
- iio_has_backend
Check if the specified backend is available
- iio_get_backends_count
Get the number of available backends
- iio_get_backend
Retrieve the name of a given backend
Context Context
- Function
Description
- iio_create_default_context
Create a context from local or remote IIO devices
- iio_create_local_context
Create a context from local IIO devices (Linux only)
- iio_create_xml_context
Create a context from XML data in memory
- iio_create_xml_context_mem
Create a context from XML data in memory
- iio_create_network_context
Create a context from the network
- iio_create_context_from_uri
- iio_context_clone
Duplicate a pre-existing IIO context
- iio_context_destroy
Destroy the given context
- iio_context_get_version
Get the version of the backend in use
- iio_context_get_xml
Obtain a XML representation of the given context
- iio_context_get_name
Get the name of the given context
- iio_context_get_description
Get a description of the given context
- iio_context_get_attrs_count
Get the number of context-specific attributes
- iio_context_get_attr
Retrieve the value of a context-specific attribute
- iio_context_get_attr_value
Retrieve the value of a context-specific attribute
- iio_context_get_devices_count
Enumerate the devices found in the given context
- iio_context_get_device
Get the device present at the given index
- iio_context_find_device
Try to find a device structure by its ID, label or name
- iio_context_set_timeout
Set a timeout for I/O operations
Device Device
- Function
Description
- iio_device_get_context
Retrieve a pointer to the iio_context structure
- iio_device_get_id
Get whether or not the device is a hardware monitoring device
- iio_device_get_name
Retrieve the device name
- iio_device_get_label
Retrieve the device label
- iio_device_get_channels_count
Enumerate the channels of the given device
- iio_device_get_attrs_count
Enumerate the device-specific attributes of the given device
- iio_device_get_buffer_attrs_count
Enumerate the buffer-specific attributes of the given device
- iio_device_get_channel
Get the channel present at the given index
- iio_device_get_attr
Get the device-specific attribute present at the given index
- iio_device_get_buffer_attr
Get the buffer-specific attribute present at the given index
- iio_device_find_channel
Try to find a channel structure by its name of ID
- iio_device_find_attr
Try to find a device-specific attribute by its name
- iio_device_find_buffer_attr
Try to find a buffer-specific attribute by its name
- iio_device_attr_read
Read the content of the given device-specific attribute
- iio_device_attr_read_all
Read the content of all device-specific attributes
- iio_device_attr_read_bool
Read the content of the given device-specific attribute
- iio_device_attr_read_longlong
Read the content of the given device-specific attribute
- iio_device_attr_read_double
Read the content of the given device-specific attribute
- iio_device_attr_write
Set the value of the given device-specific attribute
- iio_device_attr_write_raw
Set the value of the given device-specific attribute
- iio_device_attr_write_all
Set the values of all device-specific attributes
- iio_device_attr_write_bool
Set the value of the given device-specific attribute
- iio_device_attr_write_longlong
Set the value of the given device-specific attribute
- iio_device_attr_write_double
Set the value of the given device-specific attribute
- iio_device_buffer_attr_read
Read the content of the given buffer-specific attribute
- iio_device_buffer_attr_read_all
Read the content of all buffer-specific attributes
- iio_device_buffer_attr_read_bool
Read the content of the given buffer-specific attribute
- iio_device_buffer_attr_read_longlong
Read the content of the given buffer-specific attribute
- iio_device_buffer_attr_read_double
Read the content of the given buffer-specific attribute
- iio_device_buffer_attr_write
Set the value of the given buffer-specific attribute
- iio_device_buffer_attr_write_raw
Set the value of the given buffer-specific attribute
- iio_device_buffer_attr_write_all
Set the values of all buffer-specific attributes
- iio_device_buffer_attr_write_bool
Set the value of the given buffer-specific attribute
- iio_device_buffer_attr_write_longlong
Set the value of the given buffer-specific attribute
- iio_device_buffer_attr_write_double
Set the value of the given buffer-specific attribute
- iio_device_set_data
Associate a pointer to an iio_device structure
- iio_device_get_data
Retrieve a previously associated pointer of an iio_device structure
- iio_device_get_trigger
Retrieve the trigger of a given device
- iio_device_set_trigger
Associate a trigger to a given device
- iio_device_is_trigger
Return True if the given device is a trigger
- iio_device_set_kernel_buffers_count
Configure the number of kernel buffers for a device
Channel Channel
- Function
Description
- iio_channel_get_device
Retrieve a pointer to the iio_device structure
- iio_channel_get_id
Retrieve the channel ID
- iio_channel_get_name
Retrieve the channel name
- iio_channel_is_output
Return True if the given channel is an output channel
- iio_channel_is_scan_element
Return True if the given channel is a scan element
- iio_channel_get_attrs_count
Enumerate the channel-specific attributes of the given channel
- iio_channel_get_attr
Get the channel-specific attribute present at the given index
- iio_channel_find_attr
Try to find a channel-specific attribute by its name
- iio_channel_attr_get_filename
Retrieve the filename of an attribute
- iio_channel_attr_read
Read the content of the given channel-specific attribute
- iio_channel_attr_read_all
Read the content of all channel-specific attributes
- iio_channel_attr_read_bool
Read the content of the given channel-specific attribute
- iio_channel_attr_read_longlong
Read the content of the given channel-specific attribute
- iio_channel_attr_read_double
Read the content of the given channel-specific attribute
- iio_channel_attr_write
Set the value of the given channel-specific attribute
- iio_channel_attr_write_raw
Set the value of the given channel-specific attribute
- iio_channel_attr_write_all
Set the values of all channel-specific attributes
- iio_channel_attr_write_bool
Set the value of the given channel-specific attribute
- iio_channel_attr_write_longlong
Set the value of the given channel-specific attribute
- iio_channel_attr_write_double
Set the value of the given channel-specific attribute
- iio_channel_enable
Enable the given channel
- iio_channel_disable
Disable the given channel
- iio_channel_is_enabled
Returns True if the channel is enabled
- iio_channel_read_raw
Demultiplex the samples of a given channel
- iio_channel_read
Demultiplex and convert the samples of a given channel
- iio_channel_write_raw
Multiplex the samples of a given channel
- iio_channel_write
Convert and multiplex the samples of a given channel
- iio_channel_set_data
Associate a pointer to an iio_channel structure
- iio_channel_get_data
Get a pointer to a channel's data format structure
- iio_channel_get_type
Get the type of the given hwmon channel
- iio_channel_get_modifier
Get the modifier type of the given channel
Buffer Buffer
- Function
Description
- iio_buffer_get_device
Retrieve a pointer to the iio_device structure
- iio_device_create_buffer
Create an input or output buffer associated to the given device
- iio_buffer_destroy
Destroy the given buffer
- iio_buffer_get_poll_fd
Get a pollable file descriptor
- iio_buffer_set_blocking_mode
Make iio_buffer_refill() and iio_buffer_push() blocking or not
- iio_buffer_refill
Cancel all buffer operations
- iio_buffer_push
Cancel all buffer operations
- iio_buffer_push_partial
Send a given number of samples to the hardware
- iio_buffer_cancel
Cancel all buffer operations
- iio_buffer_start
Get the start address of the buffer
- iio_buffer_first
Find the first sample of a channel in a buffer
- iio_buffer_step
Get the step size between two samples of one channel
- iio_buffer_end
Get the address that follows the last sample in a buffer
- iio_buffer_foreach_sample
Call the supplied callback for each sample found in a buffer
- iio_buffer_set_data
Associate a pointer to an iio_buffer structure
- iio_buffer_get_data
Retrieve a previously associated pointer of an iio_buffer structure
- iio_device_get_sample_size
Get the current sample size
- iio_channel_get_index
Get the index of the given channel
- iio_channel_get_data_format
Get a pointer to a channel's data format structure
- iio_channel_convert
Convert the sample from host format to hardware format
- iio_channel_convert_inverse
Convert the sample from host format to hardware format
- iio_device_get_debug_attrs_count
Enumerate the debug attributes of the given device
- iio_device_get_debug_attr
Get the debug attribute present at the given index
- iio_device_find_debug_attr
Try to find a debug attribute by its name
- iio_device_debug_attr_read
Read the content of the given debug attribute
- iio_device_debug_attr_read_all
Read the content of all debug attributes
- iio_device_debug_attr_write
Set the value of the given debug attribute
- iio_device_debug_attr_write_raw
Set the value of the given debug attribute
- iio_device_debug_attr_write_all
Set the values of all debug attributes
- iio_device_debug_attr_read_bool
Read the content of the given debug attribute
- iio_device_debug_attr_read_longlong
Read the content of the given debug attribute
- iio_device_debug_attr_read_double
Read the content of the given debug attribute
- iio_device_debug_attr_write_bool
Set the value of the given debug attribute
- iio_device_debug_attr_write_longlong
Set the value of the given debug attribute
- iio_device_debug_attr_write_double
Set the value of the given debug attribute
- iio_device_identify_filename
Identify the channel or debug attribute corresponding to a filename
- iio_device_reg_write
Set the value of a hardware register
- iio_device_reg_read
Get the value of a hardware register
Hwmon Compatibility with hardware monitoring (hwmon) devices
Referenced By
iio_attr(1), iio_genxml(1), iio_info(1), iio_readdev(1), iio_reg(1), iio_stresstest(1), iio_writedev(1).