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)
{
const uint blocksize = 1024;
Console.WriteLine(
"* Scanned contexts: " + scan.
nb_results);
}
foreach (var entry in scan.results) {
Console.WriteLine("\t" + entry.Key + " " + entry.Value);
}
scan.Dispose();
try
{
ctx =
new Context(
"ip:192.168.2.1");
Console.WriteLine(ctx.
xml);
} catch (IIOException e)
{
Console.WriteLine(e.ToString());
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:");
{
string attr_name =
"\t\t\t\t" + attr.
name;
string attr_val = "";
try
{
if (attr.
name ==
"calibscale")
{
Console.WriteLine(attr_name + " " + val);
}
else
{
Console.WriteLine(attr_name + " " + attr_val);
}
}
catch (IIOException)
{
Console.WriteLine(attr_name);
}
}
}
if (dev.
name.CompareTo(
"cf-ad9361-lpc") == 0)
{
ChannelsMask chnmask =
new ChannelsMask((uint)dev.
channels.Count);
Console.WriteLine("* Sample size is " + sampleSize + "\n");
Console.WriteLine(
"\t\t\t" + buf.
attrs.Count +
" buffer-specific attributes found:");
foreach (
Attr attr
in buf.attrs)
{
Console.WriteLine(
"\t\t\t\t" + attr.
name +
" " + attr.
read());
}
iio.Stream stream =
new iio.
Stream(buf, chnmask, 4, blocksize);
for (int i=0; i < 10; i++) {
Block block = stream.next();
byte[] databuf = new byte[blocksize];
block.read(databuf);
Console.WriteLine("* ("+ i + ") Read " + databuf.Length + " bytes from hardware");
}
stream.Dispose();
chnmask.Dispose();
}
if (dev.
attrs.Count == 0)
{
continue;
}
Console.WriteLine(
"\n\t\t" + dev.
attrs.Count +
" device-specific attributes found:");
{
Console.WriteLine(
"\t\t\t" + attr.
name);
}
}
}
}
}
iio.Attr class: Contains the representation of an iio_attr.
Definition Attr.cs:22
string read()
Read the value of this attribute as a string.
Definition Attr.cs:57
double read_double()
Read the value of this attribute as a double.
Definition Attr.cs:103
readonly string name
The name of this attribute.
Definition Attr.cs:43
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:226
readonly List< Attr > attrs
A list of all the attributes that this channel has.
Definition Channel.cs:250
void enable(ChannelsMask mask)
Enable the current channel, so that it can be used for I/O operations.
Definition Channel.cs:298
readonly bool output
Contains true if the channel is an output channel, false otherwise.
Definition Channel.cs:241
readonly string id
An identifier of this channel.
Definition Channel.cs:234
iio.Context class: Contains the representation of an IIO context.
Definition Context.cs:56
readonly string name
The name of the current context.
Definition Context.cs:100
readonly string xml
A XML representation of the current context.
Definition Context.cs:97
readonly string description
Retrieve a human-readable information string about the current context.
Definition Context.cs:103
readonly List< Device > devices
A List of all the IIO devices present on the current context.
Definition Context.cs:108
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:95
readonly string id
An identifier of this device.
Definition Device.cs:77
readonly string name
The name of this device.
Definition Device.cs:80
uint get_sample_size(ChannelsMask mask)
Get the current sample size of the device.
Definition Device.cs:206
readonly List< Attr > attrs
A list of all the attributes that this device has.
Definition Device.cs:89
readonly List< IOBuffer > buffers
A list of all the iio.IOBuffer objects that this device possesses.
Definition Device.cs:98
iio.IOBuffer class: The class used for all I/O operations.
Definition IOBuffer.cs:18
readonly List< Attr > attrs
A list of all the attributes that this buffer has.
Definition IOBuffer.cs:33
iio.ScanContext class: Class for getting information about the available contexts.
Definition Scan.cs:19
readonly uint nb_results
The number of contexts scanned.
Definition Scan.cs:48
iio.Trigger class: Contains the representation of an IIO device that can act as a trigger.
Definition Trigger.cs:21