SerialPort

G

Guest

I am using C# 2005 and System.IO.Ports.

private void SendData()
{
SerialPort m_Com;
m_Com = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.Two);
m_Com.NewLine = "\r";
m_Com.Open();
m_Com.WriteLine("VER");
m_Com.ReadLine();
}

The problem I have now is that the ReadLine just hang there forever. The
string sent back to the serial port starts with a non-readable character with
ASCII value 10. There's something (a property of SerialPort) that I need to
set so the ReadLine can read the entire ASCII table, but I don't know what
the property is. Please help.

Thanks.
 
G

Guest

ASCII 10 is LF (line feed), I think that when 'readLine' encounters this
character, it skips the rest of the line and moves to the next one. Since
there's no next line, it hangs. I use 'read' instead of 'readLine,' it works.

Thanks.

Michael Voss said:
John said:
Solved. Thanks.
[...snip...]

Would you mind sharing the solution ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top