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

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

            byte[] buffertx = DGSerialHelper.StringToBytes("Test1");
            serial1.WriteBytes(buffertx);

            byte[] bufferrx = serial2.ReadBytes(5);
            serial2.ReadBytes();
            Assert.That(serial2.BytesToRead(), Is.EqualTo(0));

            serial1.Close();
            serial2.Close();
        }
Exemple #2
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();
        }
Exemple #3
0
        public void TimeOutReadFail()
        {
            DGSerial serial2 = new DGSerial(_portName2, _baudRate2);

            serial2.Open();

            byte[] bufferrx1 = serial2.ReadBytes();
            Assert.That(bufferrx1.Length, Is.EqualTo(0));

            serial2.Close();
        }
Exemple #4
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();
        }
Exemple #5
0
        private void WriteBytesBlocking_ReadThread()
        {
            Thread.Sleep(2000);

            DGSerial serial2 = new DGSerial(_portName2, _baudRate2);

            serial2.Open();

            byte[] bufferrx = serial2.ReadBytes();

            serial2.Close();
        }