public void TimeOutWriteFail() { DGSerial serial1 = new DGSerial(_portName1, _baudRate1); serial1.Open(); byte[] buffertx1 = DGSerialHelper.StringToBytes("Test1"); Assert.IsTrue(serial1.WriteBytes(buffertx1)); byte[] buffertx2 = DGSerialHelper.StringToBytes("Test1"); Assert.IsFalse(serial1.WriteBytes(buffertx2)); serial1.Close(); }
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(); }
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(); }
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(); }
private void ReadBytesTo_ReadThread() { Thread.Sleep(2000); DGSerial serial1 = new DGSerial(_portName1, _baudRate1); serial1.Open(); byte[] buffertx = DGSerialHelper.StringToBytes("T44es41t1"); serial1.WriteBytes(buffertx); serial1.Close(); }
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(); }
public void ReadBytes() { 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(); Assert.That(buffertx, Is.EqualTo(bufferrx)); serial1.Close(); serial2.Close(); }
public void AttachDataReceived() { DGSerial serial1 = new DGSerial(_portName1, _baudRate1); DGSerial serial2 = new DGSerial(_portName2, _baudRate2); serial1.Open(); serial2.Open(); serial2.AttachDataReceived(WriteBytes_DataReceived); byte[] buffertx = DGSerialHelper.StringToBytes("Test1"); serial1.WriteBytes(buffertx); serial1.Close(); Thread.Sleep(1000); serial2.Close(); }