public bool SwitchToMTK()
        {
            DUTSerialPort.WriteLine("AB");
            Thread.Sleep(100);
            string OuputACKNAC = DUTSerialPort.ReadExisting();

            return(OuputACKNAC.Contains("AB"));
        }
        private MTKTestError RunTestUART()
        {
            int PercentageComplete = 0;
            int DelayPerCommand = 10, msPerSecond = 1000;
            int TimeForEachPacket = 700;
            int TotalEstTime      = ((int)((int)this.NumberOfPackets * TimeForEachPacket) / msPerSecond);
            int TimeSlice         = (int)Math.Ceiling((double)TotalEstTime / 100.00);

            MTKTestError CommandRetVal;

            this.Log.PrintLog(this, GetDisplayText(), LogDetailLevel.LogRelevant);
            this.Log.PrintLog(this, "Pass criteria (PER): " + PERPassCriterion.ToString() + "%",
                              LogDetailLevel.LogRelevant);

            DUTSerialPort.DiscardInBuffer();
            DUTSerialPort.DiscardOutBuffer();
            MTKSerialPort.DiscardInBuffer();
            MTKSerialPort.DiscardOutBuffer();

            TestStatusUpdate(MTKTestMessageType.Information, PercentageComplete.ToString() + "%");

            //  Command #1
            string Command = "RRS";

            CommandRetVal = SendCommand(MTKSerialPort, Command, DelayPerCommand);
            if (CommandRetVal != MTKTestError.NoError)
            {
                return(CommandRetVal);
            }

            //  Command #1
            Command       = "SPL " + PacketLength.ToString();
            CommandRetVal = SendCommand(MTKSerialPort, Command, DelayPerCommand);
            if (CommandRetVal != MTKTestError.NoError)
            {
                return(CommandRetVal);
            }

            //  Command #2
            Command       = "SPT " + GetPacketType(PacketType).ToString();
            CommandRetVal = SendCommand(MTKSerialPort, Command, DelayPerCommand);
            if (CommandRetVal != MTKTestError.NoError)
            {
                return(CommandRetVal);
            }

            //  Command #1
            Command       = "RRS";
            CommandRetVal = SendCommand(DUTSerialPort, Command, DelayPerCommand);
            if (CommandRetVal != MTKTestError.NoError)
            {
                return(CommandRetVal);
            }

            //  Command #3
            Command       = "RXP " + ChannelNumber.ToString() + " " + NumberOfPackets.ToString();
            CommandRetVal = SendCommand(DUTSerialPort, Command, DelayPerCommand);
            if (CommandRetVal != MTKTestError.NoError)
            {
                return(CommandRetVal);
            }

            //  Command #4
            Command = "TXP " + ChannelNumber.ToString() + " " + PowerLevel.ToString() +
                      " " + NumberOfPackets.ToString();
            CommandRetVal = SendCommand(MTKSerialPort, Command, DelayPerCommand);
            if (CommandRetVal != MTKTestError.NoError)
            {
                return(CommandRetVal);
            }

            for (int i = 0; i <= 100; i++)
            {
                TestStatusUpdate(MTKTestMessageType.Information, PercentageComplete.ToString() + "%");
                Thread.Sleep(TimeSlice);
                PercentageComplete++;
            }

            //  Command #5
            Command       = "RRS";
            CommandRetVal = SendCommand(MTKSerialPort, Command, DelayPerCommand);
            if (CommandRetVal != MTKTestError.NoError)
            {
                return(CommandRetVal);
            }
            this.Log.PrintLog(this, "Number of packets transmitted: " + this.CommandResult, LogDetailLevel.LogEverything);
            int TxPacket = Int32.Parse(CommandResult);

            //  Command #6
            Command       = "RRS";
            CommandRetVal = SendCommand(DUTSerialPort, Command, DelayPerCommand);
            if (CommandRetVal != MTKTestError.NoError)
            {
                return(CommandRetVal);
            }
            this.Log.PrintLog(this, "Number of packets received: " + this.CommandResult, LogDetailLevel.LogEverything);
            int RxPacket = Int32.Parse(CommandResult);

            double PERPercent = ((double)(TxPacket - RxPacket) / (double)TxPacket) * 100.00;

            if (Double.IsInfinity(PERPercent))
            {
                PERPercent = 100.0;
            }
            TestResult.Measured = PERPercent.ToString();
            this.Log.PrintLog(this, "Measured PER: " + PERPercent.ToString() + "%", LogDetailLevel.LogRelevant);

            if (PERPercent < PERPassCriterion)
            {
                TestStatusUpdate(MTKTestMessageType.Success, "PASS");
                TestResult.Result = "PASS";
                this.Log.PrintLog(this, "Result: PASS", LogDetailLevel.LogRelevant);
            }
            else
            {
                TestStatusUpdate(MTKTestMessageType.Failure, "FAIL");
                TestResult.Result = "FAIL";
                this.Log.PrintLog(this, "Result: FAIL", LogDetailLevel.LogRelevant);
                return(MTKTestError.TestFailed);
            }
            return(MTKTestError.NoError);
        }