Hi guys,
I would like to ask for a little help.
I want to write a simple program in C#. Unfortunately, I get stuck at the beginning. I can't communicate with the device via serial port.
I always get a timeout exception error...
What am I doing wrong?
See my code
........
try
{
// Serial port setup
serialPort = new SerialPort("COM5", 57600, Parity.None, 8, StopBits.One)
{
Handshake = Handshake.RequestToSend,
ReadTimeout = 500,
WriteTimeout = 500
};
// Open Port
serialPort.Open();
// Stopping the device's own program(s6b0)
string stopCommand = ":s6b0\r\n";
serialPort.Write(stopCommand);
// waiting
System.Threading.Thread.Sleep(500);
// Simple inquiry
//:r1c returns :r1c323(firmware 3.23)
//:r2c returns :r2c015(last digits of P / N ?)
//:r0c returns :r0c52A(model #? 5200A?)
serialPort.Write(":r0c\r\n");
// waiting
System.Threading.Thread.Sleep(500);
// reading answer
string response = serialPort.ReadLine();
// We display the content of the response
MessageBox.Show($"Device response: {response}", "Response", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (TimeoutException)
.......
Thank you in advance for your answers.