Wiki

This version (27 Jan 2017 08:03) was approved by DragosB.The Previously approved version (15 Nov 2016 16:59) is available.Diff

What is libiio?

Libiio is a library that has been developed by Analog Devices to ease the development of software interfacing Linux Industrial I/O (IIO) devices.

The library abstracts the low-level details of the hardware, and provides a simple yet complete programming interface that can be used for advanced projects.

The library is composed by one high-level API, and several backends:

  • the “local” backend, which interfaces the Linux kernel through the sysfs virtual filesystem,
  • the “network” backend, which interfaces the iiod server through a network link.

The IIO Daemon (IIOD) server is a good example of an application that uses libiio. It creates a libiio context that uses the “local” backend, and then share it on the network to any client application using the “network” backend of libiio and connected to the server.

Network Backends

If you just want to use libiio and iiod, which may be on a pre-compiled image - there are many places you can stream data to.

Where to get libiio?

Download Libiio

The libiio library can be obtained on the Github page of the project.

Libiio installer for Windows

18 Mar 2016 15:24 · Lucian Sin

How to build it?

Building on the Linux/Zynq Target

Check out how to stay up to date. This will check out and build the latest version.

Building on the Linux Host Target

Building libiio is pretty straightforward.

The first step is to fetch the dependencies, which as of now is only libxml2. On a Debian-flavoured GNU/Linux distribution, like Ubuntu for instance:

rgetz@pinky:~$ sudo apt-get install libxml2 libxml2-dev bison flex libcdk5-dev cmake

Depending on the backend (how you want to attach the IIO device), you may need at least one of:

rgetz@pinky:~$ sudo apt-get install libaio-dev libusb-1.0-0-dev libserialport-dev libxml2-dev libavahi-client-dev

Then, you can clone the GIT repository:

rgetz@pinky:~$ git clone https://github.com/analogdevicesinc/libiio.git

Finally, in the libiio/ directory,

rgetz@pinky:~/libiio$ cmake ./
rgetz@pinky:~/libiio$ make all
rgetz@pinky:~/libiio$ sudo make install

This will build and install libiio to /usr. Note that it is possible to install to a different location by setting the PREFIX variable.

To build iio oscilloscope you'll have to make sure libiio directories can be found, one way to do this given it installed to /usr/lib is add it to your sessions PATH:

/libiio$ PATH=/usr/lib/:$PATH

Understanding which libiio is being used

During development, sometimes it can be a puzzle which version of libiio is being used. An easy way to tell is to do something like:

analog@imhotep:~/github/libiio$ git describe --tags
v0.8-13-g6847e22

To check what is running:

analog@imhotep:~/github/libiio/build$ iio_info
Library version: 0.8 (git tag: 6847e22)
Unable to create IIO context

If you are running an application, and want to find out:

analog@imhotep:~/github/libiio/build$ strace -ofoo iio_info
Library version: 0.8 (git tag: 6847e22)
Unable to create IIO context
analog@imhotep:~/github/libiio/build$ grep -e ^open  foo | grep libiio
open("./tls/x86_64/libiio.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("./tls/libiio.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("./x86_64/libiio.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("./libiio.so.0", O_RDONLY|O_CLOEXEC) = 3
analog@imhotep:~/github/libiio/build$ ls -l ./libiio.so.0
lrwxrwxrwx 1 analog analog 13 Nov 15 10:36 ./libiio.so.0 -> libiio.so.0.8
analog@imhotep:~/github/libiio/build$ ls -l ./libiio.so.0.8
-rwxr-xr-x 1 analog analog 408432 Nov 15 10:36 ./libiio.so.0.8

This found a version in the same directory.

analog@imhotep:~$ strace -ofoo iio_info
Library version: 0.8 (git tag: 6847e22)
Unable to create IIO context
analog@imhotep:~$ grep -e ^open  foo | grep libiio
open("./tls/x86_64/libiio.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("./tls/libiio.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("./x86_64/libiio.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("./libiio.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/libiio.so.0", O_RDONLY|O_CLOEXEC) = 3
analog@imhotep:~$ ls -l /usr/lib/x86_64-linux-gnu/libiio.so.0
lrwxrwxrwx 1 root root 13 Nov  9 21:05 /usr/lib/x86_64-linux-gnu/libiio.so.0 -> libiio.so.0.8
analog@imhotep:~$ ls -l /usr/lib/x86_64-linux-gnu/libiio.so.0.8
-rw-r--r-- 1 root root 408432 Nov 15 10:36 /usr/lib/x86_64-linux-gnu/libiio.so.0.8

This found the version in /usr/lib/x86_64-linux-gnu/libiio.so.0.

Cross-compilation

If you want to cross-compile libiio, you can do so by passing the corresponding toolchain information file to cmake. For instance, to cross-compile using a toolchain built by Buildroot:

rgetz@pinky:~/libiio$ cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_PATH}/usr/share/buildroot/toolchainfile.cmake .
rgetz@pinky:~/libiio$ make all
rgetz@pinky:~/libiio$ sudo make install DESTDIR=${TOOLCHAIN_PATH}

Set the ${TOOLCHAIN_PATH} environment variable (or replace it) to the root folder of your toolchain.

For examples of different programs using the libiio API, have a look in the tests/ and examples/ subfolders.

Building on Windows

The instructions for building libiio with Visual Studio are available here: http://wiki.analog.com/resources/tools-software/linux-software/building_libiio_for_windows

Documentation

API reference

An automatically generated documentation of the API can be found here: http://analogdevicesinc.github.com/libiio/

Libiio internals

See the dedicated page: About libiio.

libiio Examples

libiio - AD9361 IIO streaming example

Source Description
ad9361-iiostream.c Configures the AD9361 transceiver, receives samples, processes them and sends them back out.
resources/tools-software/linux-software/libiio.txt · Last modified: 02 Jan 2017 15:58 by rgetz

  沪ICP备09046653号