public void WaitForMessageReceived(string message) { Console.WriteLine(""); Console.WriteLine("Waiting for message: " + message); var output = String.Empty; var wasMessageReceived = false; Timeout.Start(); while (!wasMessageReceived) { output += ReadLineFromDevice(); var expectedText = "Received message: " + message; if (output.Contains(expectedText)) { wasMessageReceived = true; Console.WriteLine(" Message was received"); ConsoleWriteSerialOutput(output); } else { Timeout.Check(TimeoutWaitingForResponse, "Timed out waiting for text '" + expectedText + "'."); } } }