Hi,
I'm making a project, where I need to write to the serial port and read response from it as fast as possible. So I have written this code:
serialPort.Open();
byte[] outBuf = new Byte[] { 59, (int)'4', (int)'3', (int)'1', 0, 0, 0 };
serialPort.Write(outBuf, 0, outBuf.Length);
byte a = Convert.ToByte(serialPort.ReadByte());
serialPort.Close();
But value of 'a' is always same as the first byte of outBuf (59 in this example).
If I close the port and open it again between reading and writing I get the correct value, but that takes to much time.
I also tried with serialPort.DiscardOutBuffer(); and it doesn't take any effect.
Does anybody know how to do that as fast as possible?
Thanks for help!