using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IIOCSharp
{
class ExampleProgram
{
static void Main(string[] args)
{
if (ctx == null)
{
Console.WriteLine("Unable to create IIO context");
return;
}
Console.WriteLine(
"IIO context created: " + ctx.
name);
Console.WriteLine(
"IIO context description: " + ctx.
description);
Console.WriteLine(
"IIO context has " + ctx.
devices.Count +
" devices:");
foreach (
Device dev
in ctx.devices) {
Console.WriteLine(
"\t" + dev.
id +
": " + dev.
name);
{
Console.WriteLine(
"Found trigger! Rate=" + ((
Trigger) dev).get_rate());
}
Console.WriteLine(
"\t\t" + dev.
channels.Count +
" channels found:");
{
string type = "input";
{
type = "output";
}
Console.WriteLine(
"\t\t\t" + chn.
id +
": " + chn.
name +
" (" + type +
")");
if (chn.
attrs.Count == 0)
{
continue;
}
Console.WriteLine(
"\t\t\t" + chn.
attrs.Count +
" channel-specific attributes found:");
{
Console.WriteLine(
"\t\t\t\t" + attr.
name);
if (attr.
name.CompareTo(
"frequency") == 0)
{
Console.WriteLine(
"Attribute content: " + attr.
read());
}
}
}
if (dev.
name.CompareTo(
"cf-ad9361-lpc") == 0)
{
Console.WriteLine(
"Read " + chn.
read(buf).Length +
" bytes from hardware");
}
if (dev.
attrs.Count == 0)
{
continue;
}
Console.WriteLine(
"\t\t" + dev.
attrs.Count +
" device-specific attributes found:");
{
Console.WriteLine(
"\t\t\t" + attr.
name);
}
}
Console.ReadLine();
}
}
}
iio.Attr class: Contains the representation of a channel or device attribute.
Definition Attr.cs:21
readonly string name
The name of this attribute.
Definition Attr.cs:23
abstract string read()
Read the value of this attribute as a string.
iio.Channel class: Contains the representation of an input or output channel.
Definition Channel.cs:22
readonly string name
The name of this channel.
Definition Channel.cs:258
readonly List< Attr > attrs
A list of all the attributes that this channel has.
Definition Channel.cs:276
void enable()
Enable the current channel, so that it can be used for I/O operations.
Definition Channel.cs:320
readonly bool output
Contains true if the channel is an output channel, false otherwise.
Definition Channel.cs:267
readonly string id
An identifier of this channel.
Definition Channel.cs:263
byte[] read(IOBuffer buffer, bool raw=false)
Extract the samples corresponding to this channel from the given iio.IOBuffer object.
Definition Channel.cs:344
iio.Context class: Contains the representation of an IIO context.
Definition Context.cs:35
readonly string name
The name of the current context.
Definition Context.cs:104
readonly string description
Retrieve a human-readable information string about the current context.
Definition Context.cs:107
readonly List< Device > devices
A List of all the IIO devices present on the current context.
Definition Context.cs:112
iio.Device class: Contains the representation of an IIO device.
Definition Device.cs:21
readonly List< Channel > channels
A list of all the iio.Channel objects that this device possesses.
Definition Device.cs:226
readonly string id
An identifier of this device.
Definition Device.cs:205
readonly string name
The name of this device.
Definition Device.cs:208
readonly List< Attr > attrs
A list of all the attributes that this device has.
Definition Device.cs:217
iio.IOBuffer class: The class used for all I/O operations.
Definition IOBuffer.cs:23
void refill()
Fetch a new set of samples from the hardware.
Definition IOBuffer.cs:103
void Dispose()
Releases all resource used by the iio.IOBuffer object.
Definition IOBuffer.cs:140
iio.Trigger class: Contains the representation of an IIO device that can act as a trigger.
Definition Trigger.cs:21