Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Context ctx = new Context("10.44.2.241");
            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);

                if (dev is Trigger)
                {
                    Console.WriteLine("Found trigger! Rate=" + ((Trigger) dev).get_rate());
                }

                Console.WriteLine("\t\t" + dev.channels.Count + " channels found:");

                foreach (Channel chn in dev.channels)
                {
                    string type = "input";
                    if (chn.output)
                        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:");
                    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());
                        }
                    }
                    
                }

				/* If we find cf-ad9361-lpc, try to read a few bytes from the first channel */
                if (dev.name.CompareTo("cf-ad9361-lpc") == 0)
                {
                    Channel chn = dev.channels[0];
                    chn.enable();
                    IOBuffer buf = new IOBuffer(dev, 0x8000);
                    buf.refill();
                    
                    Console.WriteLine("Read " + chn.read(buf).Length + " bytes from hardware");
                    buf.Dispose();
                }

                if (dev.attrs.Count == 0)
                    continue;

                Console.WriteLine("\t\t" + dev.attrs.Count + " device-specific attributes found:");
                foreach (Attr attr in dev.attrs)
                    Console.WriteLine("\t\t\t" + attr.name);

            }

			/* Wait for user input */
            Console.ReadLine();
        }
Exemplo n.º 2
0
        internal Device(Context ctx, IntPtr dev)
        {
            this.ctx = ctx;
            this.dev = dev;
            channels = new List<Channel>();
            attrs = new List<Attr>();
            debug_attrs = new List<Attr>();

            uint nb_channels = iio_device_get_channels_count(dev),
                nb_attrs = iio_device_get_attrs_count(dev),
                nb_debug_attrs = iio_device_get_debug_attrs_count(dev);

            for (uint i = 0; i < nb_channels; i++)
                channels.Add(new Channel(iio_device_get_channel(dev, i)));

            for (uint i = 0; i < nb_attrs; i++)
                attrs.Add(new DeviceAttr(dev, Marshal.PtrToStringAnsi(iio_device_get_attr(dev, i))));
            for (uint i = 0; i < nb_debug_attrs; i++)
                debug_attrs.Add(new DeviceDebugAttr(dev, Marshal.PtrToStringAnsi(iio_device_get_debug_attr(dev, i))));

            id = Marshal.PtrToStringAnsi(iio_device_get_id(dev));

            IntPtr name_ptr = iio_device_get_name(dev);
            if (name_ptr == IntPtr.Zero)
                name = "";
            else
                name = Marshal.PtrToStringAnsi(name_ptr);
        }
Exemplo n.º 3
0
 internal Trigger(Context ctx, IntPtr ptr) : base(ctx, ptr) { }