Esempio n. 1
0
        public void ReadBytesTo()
        {
            DGSerial serial2 = new DGSerial(_portName2, _baudRate2);

            serial2.Open();

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

            thread.Start();
            byte[] bufferrx = serial2.ReadBytesTo(Convert.ToByte('1'), Convert.ToByte('4'), SerialPort.InfiniteTimeout);
            var    a        = DGSerialHelper.BytesToString(bufferrx);

            Assert.That(DGSerialHelper.BytesToString(bufferrx), Is.EqualTo("T4es1t"));

            Thread thread2 = new Thread(new ThreadStart(ReadBytesTo_ReadThread));

            thread2.Start();
            byte[] bufferrx2 = serial2.ReadBytesTo(Convert.ToByte('2'), Convert.ToByte('4'), 3000);
            Assert.That(DGSerialHelper.BytesToString(bufferrx2), Is.EqualTo("T4es1t1"));

            serial2.Close();
        }