void ScriptMain() { // SerialPort C# on google System.IO.Ports.SerialPort l_port = new System.IO.Ports.SerialPort("COM3", 9600, System.IO.Ports.Parity.Even, 8); l_port.StopBits = System.IO.Ports.StopBits.One; l_port.ReadTimeout = 3000; //3s l_port.Open(); // write on the port l_port.Write("Hello nice geek\r\n"); l_port.Write("Be sure you transmit CR+LF when enter is pressed on the terminal\r\n"); Dialog.ShowDialog("Enter a string on the terminal and press enter"); try { // will read until Enter is pressed (CR+LF) or 3s timeout string l_s = l_port.ReadLine(); Console.WriteLine(l_s); } catch (TimeoutException) { Console.WriteLine("Timeout while reading\n"); } l_port.Close(); }