INTRO(3LIBIIO)
π NAME π
okay so bestie, this is INTRO(3LIBIIO) β the intro page for libiio-0.26, which is the library for interacting with the Linux IIO subsystem and devices. yes the manual name is baked right in, no boring header line for us, we're doing vibes instead. π
β¨ SYNOPSIS β¨
#include <iio.h>
cc file.c -liio
π OPTIONS π
IIO_CHECK_REGβ the defineIIO_CHECK_REGwill warn you if return values aren't being checked. most libiio functions, when a failure happens, hand back a negative error number, and this warning makes sure those error numbers actually get looked at. and honestly? there is nothing more frustrating than calling a function, debugging some hardware for ages, and then eventually realizing there was literally just a typo in an attribute name π. this option forces library users to at least capture the return value. periodt.
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). and the roster is stacked β it 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)
- 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. it's giving main character energy in every direction fr fr. π₯
πΈ DATA TYPES πΈ
the library makes use of C structures and typedefs to promote portability, and it's 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 contextiio_context_infoβ The information related to a discovered contextiio_contextβ Contains the representation of an IIO contextiio_deviceβ Represents a device in the IIO contextiio_channelβ Represents an input or output channel of a deviceiio_bufferβ An input or output buffer, used to read or write samplesiio_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 (they're in the SEE ALSO section). π
π Scan Functions
functions for scanning available contexts π§
iio_create_scan_contextβ Create a scan contextiio_scan_context_destroyβ Destroy the given scan contextiio_scan_context_get_info_listβ Enumerate available contextsiio_context_info_list_freeβ Free a context info listiio_context_info_get_descriptionβ Get a description of a discovered contextiio_context_info_get_uriβ Get the URI of a discovered contextiio_create_scan_blockβ Create a scan blockiio_scan_block_destroyβ Destroy the given scan blockiio_scan_block_scanβ Enumerate available contexts via scan blockiio_scan_block_get_infoβ Get theiio_context_infofor a particular context
π TopLevel
top-level functions, the VIPs of the file π
iio_library_get_versionβ Get the version of the libiio libraryiio_strerrorβ Get a string description of an error codeiio_has_backendβ Check if the specified backend is availableiio_get_backends_countβ Get the number of available backendsiio_get_backendβ Retrieve the name of a given backend
π Context
context functions, aka where it all starts π«Ά
iio_create_default_contextβ Create a context from local or remote IIO devicesiio_create_local_contextβ Create a context from local IIO devices (Linux only)iio_create_xml_contextβ Create a context from XML data in memoryiio_create_xml_context_memβ Create a context from XML data in memoryiio_create_network_contextβ Create a context from the networkiio_create_context_from_uriβ (the page gives no description for this one, bestie, so I'm not making one up)iio_context_cloneβ Duplicate a pre-existing IIO contextiio_context_destroyβ Destroy the given contextiio_context_get_versionβ Get the version of the backend in useiio_context_get_xmlβ Obtain a XML representation of the given contextiio_context_get_nameβ Get the name of the given contextiio_context_get_descriptionβ Get a description of the given contextiio_context_get_attrs_countβ Get the number of context-specific attributesiio_context_get_attrβ Retrieve the value of a context-specific attributeiio_context_get_attr_valueβ Retrieve the value of a context-specific attributeiio_context_get_devices_countβ Enumerate the devices found in the given contextiio_context_get_deviceβ Get the device present at the given indexiio_context_find_deviceβ Try to find a device structure by its ID, label or nameiio_context_set_timeoutβ Set a timeout for I/O operations
π§ Device
device functions, the whole toolbox π
iio_device_get_contextβ Retrieve a pointer to theiio_contextstructureiio_device_get_idβ Get whether or not the device is a hardware monitoring deviceiio_device_get_nameβ Retrieve the device nameiio_device_get_labelβ Retrieve the device labeliio_device_get_channels_countβ Enumerate the channels of the given deviceiio_device_get_attrs_countβ Enumerate the device-specific attributes of the given deviceiio_device_get_buffer_attrs_countβ Enumerate the buffer-specific attributes of the given deviceiio_device_get_channelβ Get the channel present at the given indexiio_device_get_attrβ Get the device-specific attribute present at the given indexiio_device_get_buffer_attrβ Get the buffer-specific attribute present at the given indexiio_device_find_channelβ Try to find a channel structure by its name of IDiio_device_find_attrβ Try to find a device-specific attribute by its nameiio_device_find_buffer_attrβ Try to find a buffer-specific attribute by its nameiio_device_attr_readβ Read the content of the given device-specific attributeiio_device_attr_read_allβ Read the content of all device-specific attributesiio_device_attr_read_boolβ Read the content of the given device-specific attributeiio_device_attr_read_longlongβ Read the content of the given device-specific attributeiio_device_attr_read_doubleβ Read the content of the given device-specific attributeiio_device_attr_writeβ Set the value of the given device-specific attributeiio_device_attr_write_rawβ Set the value of the given device-specific attributeiio_device_attr_write_allβ Set the values of all device-specific attributesiio_device_attr_write_boolβ Set the value of the given device-specific attributeiio_device_attr_write_longlongβ Set the value of the given device-specific attributeiio_device_attr_write_doubleβ Set the value of the given device-specific attributeiio_device_buffer_attr_readβ Read the content of the given buffer-specific attributeiio_device_buffer_attr_read_allβ Read the content of all buffer-specific attributesiio_device_buffer_attr_read_boolβ Read the content of the given buffer-specific attributeiio_device_buffer_attr_read_longlongβ Read the content of the given buffer-specific attributeiio_device_buffer_attr_read_doubleβ Read the content of the given buffer-specific attributeiio_device_buffer_attr_writeβ Set the value of the given buffer-specific attributeiio_device_buffer_attr_write_rawβ Set the value of the given buffer-specific attributeiio_device_buffer_attr_write_allβ Set the values of all buffer-specific attributesiio_device_buffer_attr_write_boolβ Set the value of the given buffer-specific attributeiio_device_buffer_attr_write_longlongβ Set the value of the given buffer-specific attributeiio_device_buffer_attr_write_doubleβ Set the value of the given buffer-specific attributeiio_device_set_dataβ Associate a pointer to aniio_devicestructureiio_device_get_dataβ Retrieve a previously associated pointer of aniio_devicestructureiio_device_get_triggerβ Retrieve the trigger of a given deviceiio_device_set_triggerβ Associate a trigger to a given deviceiio_device_is_triggerβ Return True if the given device is a trigger
to be continued, bestieβ¦ part 2 incoming πβ¨
iio_device_set_kernel_buffers_countβ sets how many kernel buffers a device gets to have. that's the last one from the device crew, moving on π
πΈ Channel
okay bestie, this is the Channel table and honestly? she's serving. every one of these takes a channel and does something adorable to it π¦
iio_channel_get_deviceβ grabs you a pointer to theiio_devicestructure πiio_channel_get_idβ retrieves the channel ID β¨iio_channel_get_nameβ retrieves the channel name πiio_channel_is_outputβ returns True if the channel you handed over is an output channel πiio_channel_is_scan_elementβ returns True if that channel is a scan element πiio_channel_get_attrs_countβ enumerates the channel-specific attributes of the given channel (yes, it counts them, no cap) π₯iio_channel_get_attrβ gets the channel-specific attribute sitting at the index you asked for π«Άiio_channel_find_attrβ tries to find a channel-specific attribute by its name π§iio_channel_attr_get_filenameβ retrieves the filename of an attribute πiio_channel_attr_readβ reads the content of the given channel-specific attribute πiio_channel_attr_read_allβ reads the content of all the channel-specific attributes, the whole buffet πiio_channel_attr_read_boolβ reads the content of the given channel-specific attribute, but make it a bool β¨iio_channel_attr_read_longlongβ reads the content of the given channel-specific attribute, but make it alonglongπiio_channel_attr_read_doubleβ reads the content of the given channel-specific attribute, but make it a double πiio_channel_attr_writeβ sets the value of the given channel-specific attribute βοΈiio_channel_attr_write_rawβ sets the value of the given channel-specific attribute, raw, no filter, no conversion π«Άiio_channel_attr_write_allβ sets the values of all the channel-specific attributes at once, icon behaviour πiio_channel_attr_write_boolβ sets the value of the given channel-specific attribute, bool edition π¦iio_channel_attr_write_longlongβ sets the value of the given channel-specific attribute,longlongedition πΈiio_channel_attr_write_doubleβ sets the value of the given channel-specific attribute, double edition πiio_channel_enableβ enables the given channel. she's ON πiio_channel_disableβ disables the given channel. she's OFF πiio_channel_is_enabledβ returns True if the channel is enabled βiio_channel_read_rawβ demultiplexes the samples of a given channel, raw, untouched, straight from the source πiio_channel_readβ demultiplexes and converts the samples of a given channel β¨iio_channel_write_rawβ multiplexes the samples of a given channel, raw π«Άiio_channel_writeβ converts and multiplexes the samples of a given channel π₯iio_channel_set_dataβ associates a pointer to aniio_channelstructure, so your data and your channel are official πiio_channel_get_dataβ gets a pointer to a channel's data format structure πiio_channel_get_typeβ gets the type of the given hwmon channel πΈiio_channel_get_modifierβ gets the modifier type of the given channel π§
π Buffer
the Buffer table, aka where the actual sample data lives. lowkey the main character section, no notes π
iio_buffer_get_deviceβ retrieves a pointer to theiio_devicestructure πiio_device_create_bufferβ creates an input or output buffer associated to the given device β¨iio_buffer_destroyβ destroys the given buffer. rip boo, you served well πiio_buffer_get_poll_fdβ gets a pollable file descriptor πiio_buffer_set_blocking_modeβ makesiio_buffer_refill()andiio_buffer_push()blocking, or not. your call bestie π«Άiio_buffer_refillβ the manpage says "Cancel all buffer operations" π yes really, I'm quoting her exactly, don't look at meiio_buffer_pushβ the manpage says "Cancel all buffer operations" here too π same energy, same words, I'm just the messengeriio_buffer_push_partialβ sends a given number of samples to the hardware πΈiio_buffer_cancelβ cancels all buffer operations. okay this one makes sense π¦iio_buffer_startβ gets the start address of the buffer βiio_buffer_firstβ finds the first sample of a channel in a buffer πiio_buffer_stepβ gets the step size between two samples of one channel π§iio_buffer_endβ gets the address that follows the last sample in a buffer πiio_buffer_foreach_sampleβ calls the callback you supplied for each sample found in a buffer. little loop, big power π₯iio_buffer_set_dataβ associates a pointer to aniio_bufferstructure πiio_buffer_get_dataβ retrieves a pointer you previously associated with aniio_bufferstructure π«Ά
and then there's this whole lil grab-bag of extras that don't fit neatly in the Channel or Buffer boxes, but they're iconic and they're staying β¨
iio_device_get_sample_sizeβ gets the current sample size πiio_channel_get_indexβ gets the index of the given channel πiio_channel_get_data_formatβ gets a pointer to a channel's data format structure πiio_channel_convertβ converts the sample from host format to hardware format π¦iio_channel_convert_inverseβ converts the sample from host format to hardware format. yes, the manpage gives the exact same sentence for both, I am not editorialising, I am just relaying πiio_device_get_debug_attrs_countβ enumerates the debug attributes of the given device πΈiio_device_get_debug_attrβ gets the debug attribute present at the given index βiio_device_find_debug_attrβ tries to find a debug attribute by its name π§iio_device_debug_attr_readβ reads the content of the given debug attribute πiio_device_debug_attr_read_allβ reads the content of all the debug attributes πiio_device_debug_attr_writeβ sets the value of the given debug attribute βοΈiio_device_debug_attr_write_rawβ sets the value of the given debug attribute, raw edition π«Άiio_device_debug_attr_write_allβ sets the values of all the debug attributes, all at once, no cap πiio_device_debug_attr_read_boolβ reads the content of the given debug attribute, bool flavoured β¨iio_device_debug_attr_read_longlongβ reads the content of the given debug attribute,longlongflavoured πiio_device_debug_attr_read_doubleβ reads the content of the given debug attribute, double flavoured πiio_device_debug_attr_write_boolβ sets the value of the given debug attribute, bool flavoured πiio_device_debug_attr_write_longlongβ sets the value of the given debug attribute,longlongflavoured πiio_device_debug_attr_write_doubleβ sets the value of the given debug attribute, double flavoured πΈiio_device_identify_filenameβ identifies the channel or the debug attribute that corresponds to a filename πiio_device_reg_writeβ sets the value of a hardware register. careful bestie, registers are not a vibe to poke blindly β οΈiio_device_reg_readβ gets the value of a hardware register π
π Hwmon
Compatibility with hardware monitoring (hwmon) devices. that's the section name and her whole tagline, she said it herself and I respect the brevity π§
that's the whole page, bestie!! you now know the entire INTRO(3LIBIIO) routine list top to bottom and I'm so proud of you π₯Ήπ
and that's a wrap on libiio-0.26, dated 19 September 2025 β this version of the page came out of that release, so if your local copy says something different, that's a different era. slay, go write some code, ily πβ¨
π¦ where this page comes from
- fedora 43: libiio 0.26-7.fc43 Β· LGPL-2.0-or-later
- fedora 43: libiio 0.26-7.fc43 Β· LGPL-2.0-or-later
- Copyright (c) 2018-2020 Robin Getz
- Copyright (c) 2018-2020 Analog Devices Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms