Receiving messages part by part from serial port using c#

Posted by karthik on Stack Overflow See other posts from Stack Overflow or by karthik
Published on 2010-04-09T03:25:25Z Indexed on 2010/04/09 3:33 UTC
Read the original article Hit count: 431

Filed under:
|

I am using the below code to receive the messages from serial port using c#

    void comPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
        if (comPort.IsOpen == true)
        {
            string msg = comPort.ReadExisting();
            MessageBox.Show(msg.Trim());
        }
    }

The problem is, i am getting the messages part by part. Like, if u send "Hello, How are you" I am receiving it word by word. I want that in a single stretch. How can i do ??

Also, is it possible to retrieve the port name from which the application is sending and receiving messages ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about serial-port