2

I'm currently trying to pass a specific command from an example test application written in VB6. In VB6 the command looks like:

Comm1.Output = "UUT_SEND ""REMS\n"" " + Chr(10)

Currently I'm trying to figure out how to pass that same data via C#'s SerialPort class.

0

1 Answer 1

3

sending stuff out the serialport is relatively straight forward....

var serialPort = new SerialPort("COM1", 9600);
serialPort.Write("UUT_SEND \"REMS\\n\" \n");

To get any responses you will have to hook the DataReceived event.

Sign up to request clarification or add additional context in comments.

7 Comments

Quote from the manual: For example, “UUT_SEND ““REMS\n”” ”. Note the use of \n, which indicates a Carriage Return (CR) as the end-of-line character. Other characters include \r (Line Feed), \t (Tab), \b (Backspace) and \f (Form Feed). Also note the double quotes around <uut command> to show embedded quotes.
Did you mean whether \n is literal or a carriage return?
I'm rather terribly confused. The manual refers to \n as Carriage Return and \r as Line Feed. Is this correct? I believe \r is Carriage Return and \n is New Line in C#.
just looked it up ... msdn.microsoft.com/en-us/library/4edbef7e.aspx \n = NL = Ascii 10 decimal \r = CR = Ascii 13 decimal. In this case the Chr(10) = \n
also looked up VB6, apparently the \n in your string is literal
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.