示例#1
0
        public MFTestResults VerifyValidChars()
        {
            if (!IsLoopback)
            {
                return(MFTestResults.Skip);
            }

            result = MFTestResults.Pass;
            try
            {
                using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
                {
                    serialPort.Open();
                    for (int i = 1; i < 255; i++)
                    {
                        string data = new string((char)i, 10);
                        Log.FilteredComment("i = " + i + " chars: " + data);
                        serialPort.VerifyWrite(data);
                    }
                }
            }
            catch (Exception ex)
            {
                result = MFTestResults.Fail;
                Log.Exception(ex.Message);
            }
            return(result);
        }
示例#2
0
 public MFTestResults GetSetHandShake()
 {
     result = MFTestResults.Pass;
     try
     {
         using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
         {
             serialPort.Eval(serialPort.Handshake, Handshake.None);
             serialPort.Handshake = Handshake.RequestToSend;
             serialPort.EvalOpenClose(serialPort.Handshake, Handshake.RequestToSend);
             serialPort.Handshake = Handshake.XOnXOff;
             serialPort.EvalOpenClose(serialPort.Handshake, Handshake.XOnXOff);
         }
         if (portCount > 0)
         {
             // Validate we can re-reserve all pins
             using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
             {
                 serialPort.Handshake = Handshake.RequestToSend;
                 serialPort.EvalOpenClose(serialPort.Handshake, Handshake.RequestToSend);
                 serialPort.Open();
             }
         }
         // TODO: Write Desktop tests to validate proper function of RTS/XonXoff
     }
     catch (Exception ex)
     {
         result = MFTestResults.Fail;
         Log.Exception(ex.Message);
     }
     return(result);
 }
示例#3
0
        public MFTestResults LargeSendBuffer()
        {
            if (!IsLoopback)
            {
                return(MFTestResults.Skip);
            }

            result = MFTestResults.Pass;
            try
            {
                using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
                {
                    serialPort.Handshake = Handshake.RequestToSend;
                    serialPort.Open();
                    serialPort.AsyncRead = true;
                    string start = MFUtilities.GetRandomSafeString(10000);
                    byte[] buff  = Encoding.UTF8.GetBytes(start);
                    serialPort.Write(buff, 0, buff.Length);

                    // wait for data to drain
                    while (serialPort.AsyncResult.Length < start.Length && (serialPort.BytesToWrite > 0 || serialPort.BytesToRead > 0))
                    {
                        Thread.Sleep(100);
                    }
                    if (serialPort.AsyncResult != start)
                    {
                        Log.Exception("Failed: " + serialPort.AsyncResult + " != " + start);
                        result = MFTestResults.Fail;
                    }
                    // wait to make sure AsyncReader is closed;
                    serialPort.AsyncRead = false;
                    while (serialPort.IsAsyncReading)
                    {
                        Thread.Sleep(100);
                    }
                }
            }
            catch (Exception ex)
            {
                result = MFTestResults.Fail;
                Log.Exception(ex.Message);
            }
            return(result);
        }
示例#4
0
        public MFTestResults VerifyValidChars()
        {
            if (!IsLoopback)
                return MFTestResults.Skip;

            result = MFTestResults.Pass;
            try
            {
                using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
                {
                    serialPort.Open();
                    for (int i = 1; i < 255; i++)
                    {
                        string data = new string((char)i, 10);
                        Log.FilteredComment("i = " + i + " chars: " + data);
                        serialPort.VerifyWrite(data);
                    }
                }
            }
            catch (Exception ex)
            {
                result = MFTestResults.Fail;
                Log.Exception(ex.Message);
            }
            return result;
        }
示例#5
0
        public MFTestResults LargeSendBuffer()
        {
            if (!IsLoopback)
                return MFTestResults.Skip;

            result = MFTestResults.Pass;
            try
            {
                using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
                {
                    serialPort.Handshake = Handshake.RequestToSend;
                    serialPort.Open();
                    serialPort.AsyncRead = true;
                    string start = MFUtilities.GetRandomSafeString(10000);
                    byte[] buff = Encoding.UTF8.GetBytes(start);
                    serialPort.Write(buff, 0, buff.Length);

                    // wait for data to drain
                    while (serialPort.AsyncResult.Length < start.Length && (serialPort.BytesToWrite > 0 || serialPort.BytesToRead > 0))
                    {
                        Thread.Sleep(100);
                    }
                    if (serialPort.AsyncResult != start)
                    {
                        Log.Exception("Failed: " + serialPort.AsyncResult + " != " + start);
                        result = MFTestResults.Fail;
                    }
                    // wait to make sure AsyncReader is closed;
                    serialPort.AsyncRead = false;
                    while (serialPort.IsAsyncReading)
                    {
                        Thread.Sleep(100);
                    }
                }
            }
            catch (Exception ex)
            {
                result = MFTestResults.Fail;
                Log.Exception(ex.Message);
            }
            return result;
        }
示例#6
0
 public MFTestResults GetSetHandShake()
 {
     result = MFTestResults.Pass;
     try
     {
         using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
         {
             serialPort.Eval(serialPort.Handshake, Handshake.None);
             serialPort.Handshake = Handshake.RequestToSend;
             serialPort.EvalOpenClose(serialPort.Handshake, Handshake.RequestToSend);
             serialPort.Handshake = Handshake.XOnXOff;
             serialPort.EvalOpenClose(serialPort.Handshake, Handshake.XOnXOff);
         }
         if (portCount > 0)
         {
             // Validate we can re-reserve all pins
             using (TestSerialPort serialPort = new TestSerialPort(Serial.COM1))
             {
                 serialPort.Handshake = Handshake.RequestToSend;
                 serialPort.EvalOpenClose(serialPort.Handshake, Handshake.RequestToSend);
                 serialPort.Open();
             }
         }
         // TODO: Write Desktop tests to validate proper function of RTS/XonXoff
     }
     catch (Exception ex)
     {
         result = MFTestResults.Fail;
         Log.Exception(ex.Message);
     }
     return result;
 }