I have two Arduinos that allow messages exchange via Serial Port using Serial Monitor.
If I use Serial Monitor in both sides everything works fine. If I use my C# application nothing happens. I tried to send from Serial Monitor for C# App and it works but not the reverse.
// ...
comPort1.Open();
// ...
private void comPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
this.Invoke(new EventHandler(processData));
}
private void processData(object sender, EventArgs e)
{
string inData = comPort1.ReadExisting();
msgBoxLog.AppendText(inData);
}
// ...
private void sendButton_Click(object sender, EventArgs e)
{
string my_str = "my string";
msgBoxLog.AppendText(msgBox.Text + my_str);
comPort1.Write(msgBox.Text);
}
RtsEnable and DtrEnable are both Enabled
Well, with
Console.Write(msgBox.Text);
I realized it was just a silly problem, I was not sending msgBox.Text as I wanted. It should be: