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 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 chilling in the SEE ALSO section) πŸ’œ

πŸ” Scan 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

  • 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

  • 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 one-liner here, so we're just gonna say the name with love 🫢)
  • 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

  • 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 β€” 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 the iio_device struct it belongs to 🫢
  • iio_channel_get_id β€” gives u the channel ID
  • iio_channel_get_name β€” gives u the channel name
  • iio_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 element
  • iio_channel_get_attrs_count β€” counts up all the channel-specific attributes on this channel, i.e. enumerates them
  • iio_channel_get_attr β€” grabs the channel-specific attribute that's sitting at the index u asked for
  • iio_channel_find_attr β€” tries to find a channel-specific attribute by name πŸ”
  • iio_channel_attr_get_filename β€” retrieves the filename of an attribute
  • iio_channel_attr_read β€” reads the content of the channel-specific attribute u point at
  • iio_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 bool
  • iio_channel_attr_read_longlong β€” reads the content of that channel-specific attribute, as a longlong
  • iio_channel_attr_read_double β€” reads the content of that channel-specific attribute, as a double
  • iio_channel_attr_write β€” sets the value of the given channel-specific attribute
  • iio_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 once
  • iio_channel_attr_write_bool β€” sets that attribute's value, bool style
  • iio_channel_attr_write_longlong β€” sets that attribute's value, longlong style
  • iio_channel_attr_write_double β€” sets that attribute's value, double style
  • iio_channel_enable β€” enables the channel ⚑
  • iio_channel_disable β€” disables the channel πŸ’€
  • iio_channel_is_enabled β€” returns True if the channel is enabled
  • iio_channel_read_raw β€” demultiplexes the samples of a given channel
  • iio_channel_read β€” demultiplexes and converts the samples of a given channel
  • iio_channel_write_raw β€” multiplexes the samples of a given channel
  • iio_channel_write β€” converts and multiplexes the samples of a given channel
  • iio_channel_set_data β€” associates a pointer with an iio_channel structure
  • iio_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 channel
  • iio_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 the iio_device structure
  • iio_device_create_buffer β€” creates an input or output buffer tied to the given device (note the name switch-up, it's iio_device_create_buffer not iio_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 descriptor
  • iio_buffer_set_blocking_mode β€” makes iio_buffer_refill() and iio_buffer_push() blocking, or not blocking. ur call.
  • iio_buffer_refill β€” cancel all buffer operations
  • iio_buffer_push β€” cancel all buffer operations
  • iio_buffer_push_partial β€” sends a given number of samples to the hardware
  • iio_buffer_cancel β€” cancel all buffer operations
  • 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 u supply, once for each sample found in a buffer πŸ”
  • iio_buffer_set_data β€” associates a pointer with an iio_buffer structure
  • iio_buffer_get_data β€” retrieves a pointer u previously associated with an iio_buffer structure
ok so yes, iio_buffer_refill, iio_buffer_push and iio_buffer_cancel all 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 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 (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 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 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, again)
  • iio_device_debug_attr_write_all β€” sets the values of all debug attributes
  • 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 β€” 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