Example #1
0
        public void I2CReadTest()
        {
            Console.WriteLine("Starting I2C read test...");

            byte[] InitialRead, SecondRead;

            I2CPreamble pre = new I2CPreamble();

            pre.DeviceAddress = 0xA0;
            pre.PreambleData.Add(0);
            pre.PreambleData.Add(0);
            pre.PreambleData.Add(0xA1);
            pre.StartMask = 4;

            for (uint readLen = 2; readLen < 256; readLen += 2)
            {
                Console.WriteLine("Testing " + readLen.ToString() + " byte read");
                InitialRead = FX3.I2CReadBytes(pre, readLen, 1000);
                SecondRead  = FX3.I2CReadBytes(pre, readLen, 1000);
                for (int i = 0; i < InitialRead.Count(); i++)
                {
                    Assert.AreEqual(InitialRead[i], SecondRead[i], "ERROR: Expected flash read data to match");
                }
            }
        }
Example #2
0
        private void TestI2CFunctionality()
        {
            byte[] InitialRead, SecondRead;

            I2CPreamble pre = new I2CPreamble();

            pre.DeviceAddress = 0xA0;
            pre.PreambleData.Add(0);
            pre.PreambleData.Add(0);
            pre.PreambleData.Add(0xA1);
            pre.StartMask = 4;

            InitialRead = FX3.I2CReadBytes(pre, 64, 1000);
            SecondRead  = FX3.I2CReadBytes(pre, 64, 1000);
            for (int i = 0; i < InitialRead.Count(); i++)
            {
                Assert.AreEqual(InitialRead[i], SecondRead[i], "ERROR: Expected flash read data to match");
            }
        }
Example #3
0
 protected override void OnReceive(object message)
 {
     if (message is FileWrite)
     {
         string text = fileStreamReader.ReadToEnd();
         if (!String.IsNullOrEmpty(text))
         {
             reporterActor.Tell("Currently running thread: " + Thread.CurrentThread.ManagedThreadId + " --> " + text);
             reporterActor.Tell(text);
         }
     }
     else if (message is FileError)
     {
         FileError msg = message as FileError;
         reporterActor.Tell(string.Format("Tail error: {0}", msg.Reason));
     }
     else if (message is InitialRead)
     {
         InitialRead msg = message as InitialRead;
         reporterActor.Tell(msg.Text);
     }
 }
Example #4
0
 public void Handle(InitialRead message)
 {
     _reporterActor.Tell(message.Text);
 }
Example #5
0
        public void I2CBitRateTest()
        {
            Console.WriteLine("Starting I2C bit rate test...");

            Console.WriteLine("Testing input validation...");
            uint startingBitRate;
            int  numExpections = 0;

            startingBitRate = FX3.I2CBitRate;
            Assert.AreEqual(100000, startingBitRate, "ERROR: Invalid default I2C bit rate");
            try
            {
                FX3.I2CBitRate = 99999;
            }
            catch (Exception e)
            {
                numExpections++;
                Console.WriteLine(e.Message);
            }
            Assert.AreEqual(1, numExpections, "ERROR: Expected exception to be thrown");
            Assert.AreEqual(startingBitRate, FX3.I2CBitRate, "ERROR: Expected I2C bit rate setting to be rejected");

            try
            {
                FX3.I2CBitRate = 1000001;
            }
            catch (Exception e)
            {
                numExpections++;
                Console.WriteLine(e.Message);
            }
            Assert.AreEqual(2, numExpections, "ERROR: Expected exception to be thrown");
            Assert.AreEqual(startingBitRate, FX3.I2CBitRate, "ERROR: Expected I2C bit rate setting to be rejected");

            Console.WriteLine("Testing reads across valid bit rate range...");

            I2CPreamble pre = new I2CPreamble();

            pre.DeviceAddress = 0xA0;
            pre.PreambleData.Add(0);
            pre.PreambleData.Add(0);
            pre.PreambleData.Add(0xA1);
            pre.StartMask = 4;

            byte[] InitialRead, SecondRead;

            Console.WriteLine("Performing initial flash read...");
            const uint READ_LEN = 1024;

            InitialRead = FX3.I2CReadBytes(pre, READ_LEN, 2000);
            for (uint bitrate = 100000; bitrate <= 1000000; bitrate += 100000)
            {
                Console.WriteLine("Testing " + bitrate.ToString() + "bits/s...");
                FX3.I2CBitRate = bitrate;
                Assert.AreEqual(bitrate, FX3.I2CBitRate, "ERROR: Setting bit rate failed");
                SecondRead = FX3.I2CReadBytes(pre, READ_LEN, 2000);
                for (int i = 0; i < InitialRead.Count(); i++)
                {
                    Assert.AreEqual(InitialRead[i], SecondRead[i], "ERROR: Expected flash read data to match");
                }
            }
        }