lundi 16 mars 2015

Read \r sent by serial port in C#?

I'm sending a text by serial port to C#. This text contains \r and it will become a new line in HyperTerminal. Now I want to read this \r in C#. How can I do this?



private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
RxString = serialPort1.ReadLine();

this.Invoke(new EventHandler(DisplayText));
}

private void DisplayText(object sender, EventArgs e)
{
string str = RxString;

if(str == "\r")
{
MessageBox.Show("This is a new line");
}
}

Aucun commentaire:

Enregistrer un commentaire