-
Notifications
You must be signed in to change notification settings - Fork 1
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 shares it on the network to any client application using the network backend of libiio and connected to the server.
If you just want to use libiio and iiod, which may be on a pre-compiled image - there are many places to which you can stream data
The libiio library can be obtained on the Github page of the project.
- Installer for latest stable build (Windows 32-bit/64-bit)
- Intaller for latest nightly build (Windows 32-bit/64-bit) (may be unstable/buggy)
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
$ 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:
$ sudo apt-get install libaio-dev libusb-1.0-0-dev libserialport-dev libxml2-dev libavahi-client-dev doxygen graphviz
Then, you can clone the GIT repository:
$ git clone https:%%//%%github.com/analogdevicesinc/libiio.git
Finally, in the libiio/ directory:
$ cmake ./
$ make all
$ 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 that its installed to /usr/lib is add it to your sessions' PATH:
$ PATH=/usr/lib/:$PATH
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 the following in the ~/github/libiio directory:
$ **git describe --tags
v0.8-13-g6847e22
To check what is running (from ~/githib/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:
$strace -ofoo iio_info
Library version: 0.8 (git tag: 6847e22)
Unable to create IIO context
$ 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.
$ strace -ofoo iio_info
Library version: 0.8 (git tag: 6847e22)
Unable to create IIO context
$ 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
$ 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
$ 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.
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 (in ~/libiio):
$ cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_PATH}/usr/share/buildroot/toolchainfile.cmake .
$ make all
$ 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.
The instructions for building libiio with Visual Studio are available here
In order to use the libIIO USB Backend, support must be built into IIOD. A simple check is shown below:
$ iiod -F foo
ERROR: IIOD was not compiled with USB support
In this case LibIIO / IIOD needs to be built with USBD support. (WITH_IIOD_USBD)
If all the dependencies are met, the USB Backend is built automatically. However the WITH_IIOD_USBD option is only available under certain conditions.
In the cmake log, if you see:
Check size of struct usb_functionfs_descs_head_v2 - failed
...your kernel itself is probably recent enough, your kernel headers are too old.
The fix:
- Download the file: https://raw.githubusercontent.com/torvalds/linux/master/include/uapi/linux/usb/functionfs.h
- And place it in /usr/include/linux/usb/functionsfs.h, overwriting the old one.
$ cd /usr/include/linux/usb
$ rm functionfs.h
$ wget https://raw.githubusercontent.com/torvalds/linux/master/include/uapi/linux/usb/functionfs.h
$ cd /usr/local/src
$ git clone https://github.com/analogdevicesinc/libiio.git
$ cd /usr/local/src/libiio/
$ git clean -d -f -x
$ cmake .
$ make
$ sudo make install
In order to use the libIIO USB Backend, the target must support USB Device Mode.
Kernel compiled with USB UDC Gadget support.
CONFIG_USB_CHIPIDEA=y CONFIG_USB_CHIPIDEA_UDC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_XILINX=y CONFIG_USB_CONFIGFS=y CONFIG_USB_CONFIGFS_F_FS=y |
Copy (and replace) iiod.conf upstart script into /etc/init
If everything works out well the USB context should be included in the available context list (e.g. in ~/devel/pshare/iiod_usb).
$ iio_info -s
Library version: 0.10 (git tag: c95ff6a)
Compiled with backends: local xml ip usb
Available contexts:
0: Local devices [local:]
1: 0456:b671 (Analog Devices Inc. Generic USB IIOD), serial=00000000 [usb:1.36.0]
An automatically generated documentation of the API can be found here: http://analogdevicesinc.github.com/libiio/
See the dedicated page: About libiio
ad9361-iiotream.c | Configures the AD9361 transceiver, receives samples, processes them and sends them back out.
Return to Arrow Highspeed Converter Platforms Home
Information on this site was obtained from |