INTRO(3LIBIIO)

πŸ“¦
version 0.26 Β· 2 versions
, in fedora 43

πŸ’– 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 define IIO_CHECK_REG will 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 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 (they're in the SEE ALSO section). 🌈

πŸ” Scan Functions

functions for scanning available contexts 🧚

  • 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, the VIPs of the file πŸ’–

  • 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 functions, aka where it all starts 🫢

  • 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 β€” (the page gives no description for this one, bestie, so I'm not making one up)
  • 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 functions, the whole toolbox πŸ’œ

  • 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

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 the iio_device structure πŸ’–
  • 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 a longlong πŸ’…
  • 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, longlong edition 🌸
  • 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 an iio_channel structure, 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 the iio_device structure πŸ’œ
  • 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 β€” makes iio_buffer_refill() and iio_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 me
  • iio_buffer_push β€” the manpage says "Cancel all buffer operations" here too 😭 same energy, same words, I'm just the messenger
  • iio_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 an iio_buffer structure πŸ’–
  • iio_buffer_get_data β€” retrieves a pointer you previously associated with an iio_buffer structure 🫢

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, longlong flavoured πŸ’…
  • 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, longlong flavoured πŸ“
  • 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