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");
        }
        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");
        }
        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");
                }
            }
        }