Exemplo n.º 1
0
        public void ErrorLogClearTest()
        {
            Console.WriteLine("Starting error log clear test...");

            List <FX3ErrorLog> initialLog, log;

            initialLog = FX3.GetErrorLog();
            Console.WriteLine("Initial error log count: " + initialLog.Count.ToString());
            foreach (FX3ErrorLog logEntry in initialLog)
            {
                Console.WriteLine(logEntry.ToString());
            }
            Console.WriteLine("Clearing error log...");
            FX3.ClearErrorLog();
            log = FX3.GetErrorLog();
            Console.WriteLine("Error log count: " + log.Count.ToString());
            foreach (FX3ErrorLog logEntry in log)
            {
                Console.WriteLine(logEntry.ToString());
            }
            Assert.AreEqual(0, log.Count, "ERROR: Error log failed to clear");
            Assert.AreEqual(0, FX3.GetErrorLogCount(), "ERROR: Error log failed to clear");

            Console.WriteLine("Rebooting FX3...");
            FX3.Disconnect();
            System.Threading.Thread.Sleep(1000);
            FX3.WaitForBoard(5);
            FX3.Connect(FX3.AvailableFX3s[0]);

            Assert.AreEqual(0, log.Count, "ERROR: Error log failed to clear");
            Assert.AreEqual(0, FX3.GetErrorLogCount(), "ERROR: Error log failed to clear");
        }
Exemplo n.º 2
0
        public void SerialNumberTest()
        {
            Console.WriteLine("Starting FX3 serial number test...");

            int exCount = 0;

            string sn = FX3.ActiveFX3SerialNumber;

            Assert.AreEqual(sn, FX3.GetTargetSerialNumber, "ERROR: Invalid target serial number");
            Assert.AreEqual(sn, FX3.ActiveFX3.SerialNumber, "ERRRO: Invalid active FX3 serial number");

            FX3.Disconnect();
            Assert.AreEqual(null, FX3.ActiveFX3SerialNumber, "ERROR: Expected null SN when board disconnected");
            try
            {
                /* This one communicates to board, should throw exception if board not connected */
                Console.WriteLine(FX3.GetTargetSerialNumber);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                exCount = 1;
            }
            Assert.AreEqual(1, exCount, "ERROR: Expected exception to be thrown");

            Assert.AreEqual(null, FX3.ActiveFX3, "ERROR: Expected null SN when board disconnected");

            FX3.WaitForBoard(5);

            FX3.Connect(sn);
            Assert.AreEqual(sn, FX3.ActiveFX3SerialNumber, "ERROR: serial number");
            Assert.AreEqual(sn, FX3.GetTargetSerialNumber, "ERROR: Invalid target serial number");
            Assert.AreEqual(sn, FX3.ActiveFX3.SerialNumber, "ERRRO: Invalid active FX3 serial number");
        }
Exemplo n.º 3
0
        public void BootStatusTest()
        {
            Console.WriteLine("Starting boot status retrieval test...");

            string sn = FX3.ActiveFX3.SerialNumber;
            string status;

            status = FX3.GetBootStatus;
            Console.WriteLine(status);
            Assert.False(status.Contains("Not"), "ERROR: Expected firmware to be running");
            Assert.True(FX3.FX3BoardAttached, "ERROR: Expected FX3 board to be attached");

            Console.WriteLine("Disconnecting FX3...");
            FX3.Disconnect();
            Assert.IsFalse(FX3.FX3BoardAttached, "ERROR: Expected FX3 board not to be attached");
            status = FX3.GetBootStatus;
            Console.WriteLine(status);
            Assert.True(status.Contains("Not"), "ERROR: Expected firmware to not be running");

            Console.WriteLine("Re-connecting FX3...");
            FX3.WaitForBoard(5);
            FX3.Connect(sn);
            status = FX3.GetBootStatus;
            Console.WriteLine(status);
            Assert.False(status.Contains("Not"), "ERROR: Expected firmware to be running");
        }
Exemplo n.º 4
0
        public void FirmwareLoadTest()
        {
            Console.WriteLine("Starting firmware load test...");

            const int RESET_TRIALS = 4;

            string sn = FX3.ActiveFX3.SerialNumber;

            int exCount = 0;

            for (int trial = 0; trial < RESET_TRIALS; trial++)
            {
                Console.WriteLine("Disconnecting FX3...");
                FX3.Disconnect();
                Assert.IsNull(FX3.ActiveFX3, "ERROR: Active board should be null after disconnect");
                FX3.WaitForBoard(5);
                Assert.AreEqual(1, FX3.AvailableFX3s.Count, "ERROR: Expected only 1 FX3 to be available...");
                Console.WriteLine("Connecting to FX3...");
                FX3.Connect(sn);
            }

            try
            {
                FX3.Disconnect();
                exCount = 0;
                FX3.Connect("Bad SN");
            }
            catch (Exception e)
            {
                Assert.True(e is FX3ProgrammingException, "ERROR: Expected FX3 programming exception to be thrown");
                exCount++;
            }
            Assert.AreEqual(1, exCount, "ERROR: No exception throw for connecting to invalid board");
        }
Exemplo n.º 5
0
        public void BoardInfoTest()
        {
            Console.WriteLine("Starting FX3 board info test...");

            FX3Board startInfo = FX3.ActiveFX3;

            Console.WriteLine("Board: " + startInfo.ToString());
            Assert.IsFalse(startInfo.VerboseMode, "ERROR: FX3 firmware should not be in verbose mode");
            Console.WriteLine("Disconnecting FX3...");
            FX3.Disconnect();
            Assert.IsNull(FX3.ActiveFX3, "ERROR: Expected FX3 object to be null after disconnect");
            FX3.WaitForBoard(10);
            Console.WriteLine("Reconnecting...");
            FX3.Connect(FX3.AvailableFX3s[0]);
            Console.WriteLine("Board: " + FX3.ActiveFX3.ToString());
            Assert.AreEqual(startInfo.SerialNumber, FX3.ActiveFX3.SerialNumber, "ERROR: Invalid serial number");
            Assert.AreEqual(startInfo.FirmwareVersionNumber, FX3.ActiveFX3.FirmwareVersionNumber, "ERROR: Invalid firmware version number");
            Assert.AreEqual(startInfo.VerboseMode, FX3.ActiveFX3.VerboseMode, "ERROR: Invalid verbose mode setting");
            Assert.AreEqual(FX3.GetFX3ApiInfo.VersionNumber, FX3.ActiveFX3.FirmwareVersionNumber, "ERROR: FX3 Firmware version does not match API");

            Console.WriteLine("Testing board up-time setting...");
            Stopwatch timer = new Stopwatch();

            long startTime = FX3.ActiveFX3.Uptime;

            timer.Start();
            while (timer.ElapsedMilliseconds < 3000)
            {
                Assert.AreEqual(timer.ElapsedMilliseconds + startTime, FX3.ActiveFX3.Uptime, 50, "ERROR: Invalid FX3 Uptime");
                System.Threading.Thread.Sleep(10);
            }
        }
Exemplo n.º 6
0
        public void ErrorLogCountTest()
        {
            Console.WriteLine("Starting error log count test...");

            uint count, firstCount;

            List <FX3ErrorLog> log;

            firstCount = FX3.GetErrorLogCount();
            for (int trial = 0; trial < 5; trial++)
            {
                count = FX3.GetErrorLogCount();
                Console.WriteLine("Error log count: " + count.ToString());
                Assert.AreEqual(firstCount, count, "ERROR: Invalid error log count");
            }

            if (firstCount > 1500)
            {
                Console.WriteLine("ERROR: Error log full. Clearing...");
                FX3.ClearErrorLog();
                Assert.AreEqual(0, FX3.GetErrorLogCount(), "ERROR: Error log count clear failed");
                firstCount = 0;
            }

            log = FX3.GetErrorLog();
            Assert.AreEqual(firstCount, log.Count(), "ERROR: Invalid error log size");

            Console.WriteLine("Rebooting FX3...");
            FX3.Disconnect();
            System.Threading.Thread.Sleep(1000);
            Connect();

            count = FX3.GetErrorLogCount();
            Console.WriteLine("Error log count: " + count.ToString());
            Assert.AreEqual(firstCount, count, "ERROR: Invalid error log count");

            log = FX3.GetErrorLog();
            Assert.AreEqual(firstCount, log.Count(), "ERROR: Invalid error log size");
        }
Exemplo n.º 7
0
        public void BoardDetectionTest()
        {
            Console.WriteLine("Starting FX3 board detection test...");

            string sn = FX3.ActiveFX3SerialNumber;

            Assert.AreEqual(0, FX3.AvailableFX3s.Count(), "ERROR: Expected no available FX3s");
            Assert.AreEqual(1, FX3.BusyFX3s.Count(), "ERROR: Expected 1 busy FX3");
            Assert.AreEqual(sn, FX3.BusyFX3s[0], "Invalid busy FX3 SN");

            Console.WriteLine("Rebooting FX3...");
            FX3.Disconnect();
            FX3.WaitForBoard(10);
            Assert.AreEqual(1, FX3.AvailableFX3s.Count(), "ERROR: Expected 1 available FX3");
            Assert.AreEqual(sn, FX3.AvailableFX3s[0], "Invalid available FX3 SN");
            Assert.AreEqual(0, FX3.BusyFX3s.Count(), "ERROR: Expected 0 busy FX3s");

            FX3.Connect(sn);
            Assert.AreEqual(0, FX3.AvailableFX3s.Count(), "ERROR: Expected no available FX3s");
            Assert.AreEqual(1, FX3.BusyFX3s.Count(), "ERROR: Expected 1 busy FX3");
            Assert.AreEqual(sn, FX3.BusyFX3s[0], "Invalid busy FX3 SN");
        }
Exemplo n.º 8
0
        public void ErrorLogContentsTest()
        {
            Console.WriteLine("Starting error contents test...");

            List <FX3ErrorLog> initialLog, log;

            uint count;

            count = FX3.GetErrorLogCount();
            if (count > 1500)
            {
                Console.WriteLine("Error log count of " + count.ToString() + " exceeds log capacity. Clearing log...");
                FX3.ClearErrorLog();
                Assert.AreEqual(0, FX3.GetErrorLogCount(), "ERROR: Error log count clear failed");
            }

            initialLog = FX3.GetErrorLog();
            Console.WriteLine("Initial error log count: " + initialLog.Count.ToString());
            foreach (FX3ErrorLog logEntry in initialLog)
            {
                Console.WriteLine(logEntry.ToString());
            }

            for (int trial = 0; trial < 5; trial++)
            {
                Console.WriteLine("Reading error log...");
                log = FX3.GetErrorLog();
                Assert.AreEqual(initialLog.Count, log.Count, "ERROR: Invalid error log count");
                for (int i = 0; i < log.Count; i++)
                {
                    Assert.AreEqual(initialLog[i], log[i], "ERROR: Invalid log entry");
                }
            }

            Console.WriteLine("Adding a new item to the error log...");
            string version = FX3.GetFirmwareVersion;
            long   uptime  = FX3.ActiveFX3.Uptime;

            GenerateErrorLog();
            log = FX3.GetErrorLog();
            Console.WriteLine(log[log.Count - 1].ToString());
            Assert.AreEqual(initialLog.Count + 1, log.Count, "ERROR: Error log count not incremented correctly");
            count = (uint)log.Count;
            for (int i = 0; i < initialLog.Count; i++)
            {
                Assert.AreEqual(initialLog[i], log[i], "ERROR: Invalid older log entries");
            }
            /* Check new log entry */
            Assert.AreEqual(uptime, log[log.Count - 1].OSUptime, 1000, "ERROR: Invalid error log uptime");
            /*Check boot time stamp */
            uint expectedTimestamp = (uint)((DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds - (uptime / 1000));

            Assert.AreEqual(log[log.Count - 1].BootTimeStamp, expectedTimestamp, 120, "ERROR: Invalid boot time stamp");
            /* Check file (should have originated in HelperFunctions (10)) */
            Assert.AreEqual(10, log[log.Count - 1].FileIdentifier, "ERROR: Invalid file identifier. Expected error to have originated in HelperFunctions.c");

            initialLog = FX3.GetErrorLog();
            Assert.AreEqual(count, log.Count, "ERROR: Invalid log count");

            /* Reboot FX3 and check contents */
            Console.WriteLine("Rebooting FX3...");
            FX3.Disconnect();
            Connect();

            for (int trial = 0; trial < 5; trial++)
            {
                Console.WriteLine("Reading error log...");
                log = FX3.GetErrorLog();
                Assert.AreEqual(initialLog.Count, log.Count, "ERROR: Invalid error log count");
                for (int i = 0; i < log.Count; i++)
                {
                    Assert.AreEqual(initialLog[i], log[i], "ERROR: Invalid log entry");
                }
            }
        }
Exemplo n.º 9
0
        public void ErrorLogRobustnessTest()
        {
            Console.WriteLine("Starting error log robustness test...");

            List <FX3ErrorLog> initialLog, log;

            I2CPreamble preRead = new I2CPreamble();

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

            I2CPreamble preWrite = new I2CPreamble();

            preWrite.DeviceAddress = 0;
            preWrite.PreambleData.Add(0);
            preWrite.StartMask = 0;

            Console.WriteLine("Rebooting FX3...");
            FX3.Disconnect();
            System.Threading.Thread.Sleep(500);
            Connect();

            Console.WriteLine("Getting initial error log...");
            initialLog = FX3.GetErrorLog();
            foreach (FX3ErrorLog entry in initialLog)
            {
                Console.WriteLine(entry.ToString());
            }

            Console.WriteLine("Starting I2C Read...");
            try
            {
                FX3.I2CReadBytes(preRead, 32, 1000);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("Getting error log...");
            log = FX3.GetErrorLog();
            CheckLogEquality(initialLog, log, false);

            Console.WriteLine("Starting invalid I2C write...");
            try
            {
                FX3.I2CWriteBytes(preWrite, new byte[] { 1, 2, 3, 4 }, 1000);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("Getting error log...");
            log = FX3.GetErrorLog();
            CheckLogEquality(initialLog, log, true);

            initialLog.Clear();
            foreach (FX3ErrorLog entry in log)
            {
                initialLog.Add(entry);
            }

            Console.WriteLine("Starting I2C stream...");
            FX3.StartI2CStream(preRead, 64, 10);
            System.Threading.Thread.Sleep(2000);

            Console.WriteLine("Getting error log...");
            log = FX3.GetErrorLog();
            CheckLogEquality(initialLog, log, false);

            Console.WriteLine("Rebooting FX3...");
            FX3.Disconnect();
            System.Threading.Thread.Sleep(500);
            Connect();

            Console.WriteLine("Getting error log...");
            log = FX3.GetErrorLog();
            CheckLogEquality(initialLog, log, false);

            Console.WriteLine("Starting I2C Read...");
            try
            {
                FX3.I2CReadBytes(preRead, 32, 1000);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("Generating new error log...");
            GenerateErrorLog();

            Console.WriteLine("Getting error log...");
            log = FX3.GetErrorLog();
            Assert.AreEqual(initialLog.Count + 1, log.Count, "ERROR: Invalid log count");
            CheckLogEquality(initialLog, log, true);
        }