I'm sending textual data to COM15 (via micro USB) using Arduino. On my desktop, I'm trying to read the data from my C# application. However, when I run it, the console simply shows nothing and the program stucks at the line "string s = myPort.ReadLine()".
The following is my C# program:
static void Main(string[] args)
{
var myPort = new SerialPort("COM15", 115200);
myPort.Open();
while (true)
{
var s = myPort.ReadLine(); // execution stucks here waiting forever!
Console.WriteLine(s);
}
}
The following is the Arduino code (sends data to COM15):
int counter = 1;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(" Data Loop = " + String(counter));
counter++;
delay(500);
}
The arduino serial monitor does show the data being received at COM15. I also tried other software that read COM ports and verified that the data is available at the port.