Products > Test Equipment
MHS-5200A Serial port communication error
(1/2) > >>
trebi:
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
   
--- 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)
      .......

--- End code ---

Thank you in advance for your answers.
NE666:
I think you're more likely to get an informed answer here, given the subject matter; https://www.eevblog.com/forum/testgear/mhs-5200a-serial-protocol-reverse-engineered/50/

However, if you'd like a guess - are you sure that a) hardware flow control is really being used (instead of software/XonXoff) and b) if so, you're wired up correctly?
Kean:
I'd suggest first trying no handshake in case of a cable problem.

--- Code: ---serialPort.Handsake = Handshake.None;
--- End code ---

Also, if the line endings are always CRLF, you can set

--- Code: ---serialPort.Newline = "\r\n";
--- End code ---
and then use WriteLine() without including the line ending.
ReadLine() will also expect the same line ending which is sometimes a problem.
trebi:
Thanks for the answer.
I have tried all the suggested options but no change. The cable must be good, it communicates with added software. However, I noticed that the factory software sees it as MHS-5212A.
NE666:
If it were me, and I'd not done so already, I'd put my own code aside and verify whether or not I could access the device using a "proven" serial terminal program (e.g. putty) using the same serial settings. Eliminate any possible serial misconfiguration issues first ahead of suspecting a problem with your code or libaries.
Navigation
Message Index
Next page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod