Beispiel #1
0
        public void TimeOutWriteSuccess()
        {
            DGSerial serial1 = new DGSerial(_portName1, _baudRate1);
            DGSerial serial2 = new DGSerial(_portName2, _baudRate2);

            serial1.Open();
            serial2.Open();

            byte[] buffertx1 = new byte[serial1.Get().ReadBufferSize];
            Assert.IsTrue(serial1.WriteBytes(buffertx1));
            byte[] bufferrx1 = serial2.ReadBytes();

            byte[] buffertx2 = new byte[serial1.Get().ReadBufferSize - 5];
            Assert.IsTrue(serial1.WriteBytes(buffertx2));
            byte[] bufferrx2 = serial2.ReadBytes();

            serial1.Close();
            serial2.Close();
        }
Beispiel #2
0
        public void TimeOutReadSuccess()
        {
            DGSerial serial1 = new DGSerial(_portName1, _baudRate1);
            DGSerial serial2 = new DGSerial(_portName2, _baudRate2);

            serial1.Open();
            serial2.Open();

            byte[] buffertx1 = new byte[serial1.Get().ReadBufferSize];
            serial1.WriteBytes(buffertx1);
            byte[] bufferrx1 = serial2.ReadBytes();
            Assert.That(bufferrx1.Length, Is.EqualTo(serial1.Get().ReadBufferSize));

            byte[] buffertx2 = new byte[serial1.Get().ReadBufferSize - 5];
            serial1.WriteBytes(buffertx2);
            byte[] bufferrx2 = serial2.ReadBytes();
            Assert.That(bufferrx2.Length, Is.EqualTo(serial1.Get().ReadBufferSize - 5));

            serial1.Close();
            serial2.Close();
        }
Beispiel #3
0
        public void DiscardInBuffer()
        {
            DGSerial serial1 = new DGSerial(_portName1, _baudRate1);
            DGSerial serial2 = new DGSerial(_portName2, _baudRate2);

            serial1.Open();
            serial2.Open();

            byte[] buffertx = new byte[serial2.Get().ReadBufferSize];
            serial1.WriteBytes(buffertx);
            serial1.WriteBytes(buffertx);
            serial1.WriteBytes(buffertx);

            Assert.That(serial2.BytesToRead(), Is.EqualTo(serial2.Get().ReadBufferSize));

            serial2.DiscardInBuffer();

            Assert.That(serial2.BytesToRead(), Is.EqualTo(0));

            serial1.Close();
            serial2.Close();
        }
Beispiel #4
0
        private void ReadBytesBlocking_ReadThread()
        {
            Thread.Sleep(2000);

            DGSerial serial1 = new DGSerial(_portName1, _baudRate1);

            serial1.Open();

            byte[] buffertx = new byte[serial1.Get().ReadBufferSize];
            serial1.WriteBytes(buffertx);

            serial1.Close();
        }
Beispiel #5
0
        public void WriteBytesBlocking()
        {
            DGSerial serial1 = new DGSerial(_portName1, _baudRate1);

            Thread thread = new Thread(new ThreadStart(WriteBytesBlocking_ReadThread));

            serial1.Open();
            byte[]    buffertx = new byte[serial1.Get().WriteBufferSize];
            Stopwatch watch    = Stopwatch.StartNew();

            thread.Start();
            serial1.WriteBytesBlocking(buffertx);
            watch.Stop();
            Assert.That(watch.ElapsedMilliseconds, Is.AtLeast(1999));

            serial1.Close();
        }
Beispiel #6
0
        public void Get()
        {
            DGSerial serial = new DGSerial(_portName1, _baudRate1);

            Assert.That(serial.Get(), Is.Not.EqualTo(null));
        }