INTRO(3LIBIIO)
πΈ INTRO(3LIBIIO) β libiio-0.26 π
okay bestie, pull up a chair, grab a boba, because this is the glow-up tour of libiio-0.26, the library that talks to the Linux IIO subsystem. this is part 1 of 2, so don't you dare close the tab, there's more coming β¨
π NAME π
libiio-0.26 β an introduction to libiio, a library for interacting with the Linux IIO subsystem and devices. (yes this is the INTRO(3LIBIIO) page, hi, hello, welcome π«Ά)
β¨ SYNOPSIS β¨
#include <iio.h>
cc file.c -liio
like, that's it. that's the whole vibe. include the header, link the lib, go off π
π OPTIONS π
IIO_CHECK_REG(a define, not a flag, iykyk) β turn this on and it warns you when return values aren't being checked. here's the tea: most libiio functions, when a failure happens, hand you back a negative error number. this warning makes sure those error numbers actually get looked at. and ngl, there is nothing more frustrating than calling a function, debugging your hardware for an hour, and then realizing there was a typo in an attribute name π. this option forces library users to at least capture the return value. periodt.
to use it, compile like this:
cc file.c -DIIO_CHECK_REG -liio
π DESCRIPTION π
libiio is a library used to interface to the Linux Industrial Input/Output (IIO) Subsystem. and the Linux IIO subsystem is out here providing support for devices that are, in some sense, analog-to-digital or digital-to-analog converters (ADCs, DACs).
and when we say "this includes, but is not limited to", bestie, we mean it's a whole roster π:
- 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
and the flex? you can use libiio natively on an embedded Linux target (local mode), or you can use libiio to communicate remotely to that same target from a host Linux, Windows or MAC over USB, Ethernet or Serial. main character energy fr fr π
π¦ 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 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 chilling in the SEE ALSO section) π
π Scan 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
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
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 one-liner here, so we're just gonna say the name with love π«Ά)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
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β returnTrueif the given device is a triggeriio_device_set_kernel_buffers_countβ sets how many kernel buffers a device gets to have π§Ί that's the last of the Device crew, thank u for coming to my ted talk
π Channel Channel
ok yes, the page says "Channel" twice. that's not me glitching, that's genuinely what's printed. double-tap to like, i guess. anyway β the Channel agenda, in order, no skips:
iio_channel_get_deviceβ hands u back a pointer to theiio_devicestruct it belongs to π«Άiio_channel_get_idβ gives u the channel IDiio_channel_get_nameβ gives u the channel nameiio_channel_is_outputβ returns True if this channel is an output channel (yes bestie, some of them write back π)iio_channel_is_scan_elementβ returns True if this channel is a scan elementiio_channel_get_attrs_countβ counts up all the channel-specific attributes on this channel, i.e. enumerates themiio_channel_get_attrβ grabs the channel-specific attribute that's sitting at the index u asked foriio_channel_find_attrβ tries to find a channel-specific attribute by name πiio_channel_attr_get_filenameβ retrieves the filename of an attributeiio_channel_attr_readβ reads the content of the channel-specific attribute u point atiio_channel_attr_read_allβ reads the content of literally every channel-specific attribute, all of them, the whole fit β¨iio_channel_attr_read_boolβ reads the content of that channel-specific attribute, as a booliio_channel_attr_read_longlongβ reads the content of that channel-specific attribute, as a longlongiio_channel_attr_read_doubleβ reads the content of that channel-specific attribute, as a doubleiio_channel_attr_writeβ sets the value of the given channel-specific attributeiio_channel_attr_write_rawβ also sets the value of the given channel-specific attribute (raw edition)iio_channel_attr_write_allβ sets the values of every channel-specific attribute at onceiio_channel_attr_write_boolβ sets that attribute's value, bool styleiio_channel_attr_write_longlongβ sets that attribute's value, longlong styleiio_channel_attr_write_doubleβ sets that attribute's value, double styleiio_channel_enableβ enables the channel β‘iio_channel_disableβ disables the channel πiio_channel_is_enabledβ returns True if the channel is enablediio_channel_read_rawβ demultiplexes the samples of a given channeliio_channel_readβ demultiplexes and converts the samples of a given channeliio_channel_write_rawβ multiplexes the samples of a given channeliio_channel_writeβ converts and multiplexes the samples of a given channeliio_channel_set_dataβ associates a pointer with aniio_channelstructureiio_channel_get_dataβ gets a pointer to a channel's data format structure (that's literally how the page words it, i'm just the messenger π )iio_channel_get_typeβ gets the type of the given hwmon channeliio_channel_get_modifierβ gets the modifier type of the given channel
π Buffer Buffer
again with the double word. the page is committed to the bit. the Buffer roster:
iio_buffer_get_deviceβ retrieves a pointer to theiio_devicestructureiio_device_create_bufferβ creates an input or output buffer tied to the given device (note the name switch-up, it'siio_device_create_buffernotiio_buffer_createβ she's quirky like that) πΈiio_buffer_destroyβ destroys the given buffer, bye bye π¦iio_buffer_get_poll_fdβ gets u a pollable file descriptoriio_buffer_set_blocking_modeβ makesiio_buffer_refill()andiio_buffer_push()blocking, or not blocking. ur call.iio_buffer_refillβ cancel all buffer operationsiio_buffer_pushβ cancel all buffer operationsiio_buffer_push_partialβ sends a given number of samples to the hardwareiio_buffer_cancelβ cancel all buffer operationsiio_buffer_startβ gets the start address of the bufferiio_buffer_firstβ finds the first sample of a channel in a bufferiio_buffer_stepβ gets the step size between two samples of one channeliio_buffer_endβ gets the address that follows the last sample in a bufferiio_buffer_foreach_sampleβ calls the callback u supply, once for each sample found in a buffer πiio_buffer_set_dataβ associates a pointer with aniio_bufferstructureiio_buffer_get_dataβ retrieves a pointer u previously associated with aniio_bufferstructure
ok so yes,iio_buffer_refill,iio_buffer_pushandiio_buffer_cancelall have the exact same description on the page β "Cancel all buffer operations", three times, no notes. i'm not editing that, i'm just reporting it. the source said what it said π
and then the page just keeps listing stuff with no group label at all β no header, no divider, nothing. she simply continues. so here's the rest, bestie, exactly as it's written π«Ά
iio_device_get_sample_sizeβ gets the current sample sizeiio_channel_get_indexβ gets the index of the given channeliio_channel_get_data_formatβ gets a pointer to a channel's data format structureiio_channel_convertβ converts the sample from host format to hardware formatiio_channel_convert_inverseβ converts the sample from host format to hardware format (the page gives it the identical description as the one above, and yes, the function is called_inverse. that is a whole situation. i am only relaying facts β)iio_device_get_debug_attrs_countβ enumerates the debug attributes of the given deviceiio_device_get_debug_attrβ gets the debug attribute present at the given indexiio_device_find_debug_attrβ tries to find a debug attribute by its nameiio_device_debug_attr_readβ reads the content of the given debug attributeiio_device_debug_attr_read_allβ reads the content of all debug attributesiio_device_debug_attr_writeβ sets the value of the given debug attributeiio_device_debug_attr_write_rawβ sets the value of the given debug attribute (raw, again)iio_device_debug_attr_write_allβ sets the values of all debug attributesiio_device_debug_attr_read_boolβ reads the content of the given debug attribute, bool flavourediio_device_debug_attr_read_longlongβ reads the content of the given debug attribute, longlong flavourediio_device_debug_attr_read_doubleβ reads the content of the given debug attribute, double flavourediio_device_debug_attr_write_boolβ sets the value of the given debug attribute, bool flavourediio_device_debug_attr_write_longlongβ sets the value of the given debug attribute, longlong flavourediio_device_debug_attr_write_doubleβ sets the value of the given debug attribute, double flavourediio_device_identify_filenameβ figures out which channel or debug attribute a filename actually corresponds to π΅οΈiio_device_reg_writeβ sets the value of a hardware register, careful bestie, that's hardware π₯iio_device_reg_readβ gets the value of a hardware register
π‘οΈ Hwmon
Compatibility with hardware monitoring (hwmon) devices π
and that's it. that is genuinely the whole section β a title, a subtitle, and zero body text. she said what she said and left, queen behaviour π
and that's a wrap on INTRO(3LIBIIO) π thank u for reading my little lecture, ur doing amazing, ur channels will demultiplex beautifully. this page came to u from libiio-0.26, dated 06 February 2026, and it's the INTRO(3LIBIIO) manual page β go forth and read ur samples, bestie πβ¨π¦
π¦ where this page comes from
- ubuntu resolute: libiio-utils 0.26-2build2 Β· LGPL-2.1-or-later
- ubuntu stonking: libiio-utils 0.26-2build2 Β· LGPL-2.1-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