Write() public method

public Write ( string attribute, string value ) : int
attribute string
value string
return int
Beispiel #1
0
    public static void Main(string[] args)
    {
        IIOCmdSrv srv  = new IIOCmdSrv();
        // Connect to IIO command server
        if (srv.Connect("10.44.2.243") == false)
        {
        Console.WriteLine("Connect Failed");
        return;
        }

        /* Show IIO Server Version Infromation */
        Console.WriteLine("Server Version: " + srv.Version());

        /* List Available IIO Devices on the Server */
        IIODevice [] iio_devices = srv.ListDevices();
        foreach (var device in iio_devices)
        Console.WriteLine("iio_devices are:" + device);

        /* A single server may handle multiple devices/drivers */
        IIODevice ad9467 = new IIODevice(srv, "cf-ad9643-core-lpc");

        /* Read the name attribute */
        Console.WriteLine("Device Name: " + ad9467.Read("name"));

        /* Read the in_voltage_scale_available attribute */
           	Console.WriteLine("in_voltage_scale_available: " + ad9467.Read("in_voltage_scale_available"));

        /* Set test modes for AD9467 Channel 0*/
        ad9467.Write("in_voltage0_test_mode", "checkerboard");

        /* Get For  Samples */
        byte[] buf = ad9467.Sample(10);
        for (var i = 0; i < buf.Length; i+=2)
        Console.Write(string.Format("0x{0:X}\n",BitConverter.ToInt16(buf, i)));

        /* Turn test modes off */
        ad9467.Write("in_voltage0_test_mode", "off");

        /* Get 10 Samples */
        buf = ad9467.Sample(10);
        for (var i = 0; i < buf.Length; i+=2)
        Console.Write(string.Format("0x{0:X}\n",BitConverter.ToInt16(buf, i)));

        /* Test Direct Register Access methods */
        Console.WriteLine("Device ID (dec): " + ad9467.RegRead(0x1));

        /* List all device attributes */
        string [] attributes = 	ad9467.ListAttributes();
        foreach (string s in attributes)
        Console.WriteLine("Attributes are: " + s);

        /* Disconnect Server */
        srv.Disconnect();
    }