For more than 6 years, the LibIIO library has existed to ease the development of software interfacing Linux Industrial I/O (IIO) devices. It is part of the Linux Kernel and a subsystem that provides support for devices like analog to digital or digital to analog converters (ADCs, DACs). This subsystem includes ADCs, accelerometers, pressure sensors, color, light and proximity sensors, temperature sensors, RF transceivers, and many more.
You can use LibIIO natively on an embedded Linux target. It is cross-platform, supporting Linux, Windows, and Mac OS. Analog Devices Inc. was the main company behind LibIIO development, which is currently an active open-source library, which many people have contributed to.
LibIIO will identify the channels that belong to each device. It will assign specific attributes, one for the channels and one for the devices. Then, it will also create a context that is a place where all the devices exist, and you can browse through the channels, devices, and attributes.
The library composed of a single cross-platform API and several backends:
- Local backend, which interfaces the Linux kernel through the sysfs virtual filesystem. This is when LibIIO runs locally on target.
- Network backend, which interfaces the iiod server through a network link.
- USB backend, which interfaces the iiod server through a USB link.
- The XML backend, which parses the XML file.
- The serial backend, which interfaces tiny-iiod through a serial link. The serial backend can be used with tiny-iiod, which will run on an embedded system with a non-Linux framework.
The network, USB, and serial backend falls under the remote backend. The iiod and tiny-iiod are part of the LibIIO. This iiod server can run on a Linux host, this would then communicate to a LibIIO client over a network or USB. The server can also run on a deeply embedded, resource-constrained system (like Arduino) managed separately as tiny-iiod, this would typically communicate to a LibIIO client over a network or serial.
The IIO Daemon (IIOD) server is an example of an application that uses LibIIO. This software stack shows a client-server relation. Let us assume that the client application runs on Windows, then calls the high-level API (of LibIIO), and through the network backend sends a command to the IIOD server. This then recognizes the command, and through LibIIO’s high-level API and local backend interacts with the IIO devices. The IIOD server shares the local backend through the network with the clients.
If you are already using Linux, your distribution already includes LibIIO, so you just need to reference the iio.h header in your source code. But for other platforms, you should check the release builds.
If you prefer, you can also access the source code from GitHub. Once you have secured your access to the library and its header, please check the LibIIO API or the LibIIO examples.
Abhishek Jadhav is an engineering student, RISC-V Ambassador, freelance tech writer, and leader of the Open Hardware Developer Community.