C# bindings for libiio  0.24
C# bindings for libIIO
C# bindings for libiio Documentation

Back to libIIO


Libiio and the C# bindings have been developed and is released under the terms of the GNU Lesser General Public License, version 2 or (at your option) any later version. This open-source license allows anyone to use the library for C# proprietary or open-source, commercial or non-commercial applications. (if you change the bindings or library, send the source of the bindings and library along with the binary).

The full terms of the library license can be found at: http://opensource.org/licenses/LGPL-2.1 and the iio-utils license can be found at: https://opensource.org/licenses/GPL-2.0

Code Model

The basic bricks of the libiio API, and therefore the C# bindings are the the iio namespace, and the classes of that nameplace: iio.Channel, iio.Context, iio.Device, iio.IOBuffer, iio.Trigger, and iio.Attr (channel or device attributes).

Creating a context

Creating a context is quite easy with the iio.Context class:

Context ctx = new Context("ip:");


Device objects

foreach (Device dev in ctx.devices)
Console.WriteLine("\t" + dev.id + ": " + dev.name);

Channel objects

Each iio.Channel can be either input, or output. This information can be retrieved with iio.Channel.output As for the Device objects, the iio.Channel object features an ID and optionally a name The ID can be obtained with iio.Channel.id, and the name can be obtained with iio.Channel.name. Important note: two iio_channel can have the same ID, as long as one is input and the other is output.

foreach (Channel chn in dev.channels)
string type = "input";
if (chn.output)
type = "output";
Console.WriteLine("\t\t\t" + chn.id + ": " + chn.name + " (" + type + ")");


Different kinds of parameters are available: parameters that apply to a iio_device, and parameters that apply to one or more iio_channel.

for Channel attributes: iio.Channel.attrs

foreach (Attr attr in chn.attrs)
Console.WriteLine("\t\t\t\t" + attr.name);
if (attr.name.CompareTo("frequency") == 0)
Console.WriteLine("Attribute content: " + attr.read());

For Device Attributes: iio.Device.attrs

foreach (Attr attr in dev.attrs)
Console.WriteLine("\t\t\t" + attr.name);