private void btnOpenTestPort_Click(object sender, EventArgs e) { //Load settings from text boxes testPort.PortName = ctbTestPort.Text; testPort.BaudRate = ctbTestBaud.Text; testPort.DataBits = ctbTestDataBits.Text; testPort.Parity = ctbTestParity.Text; testPort.StopBits = ctbTestStopBits.Text; //subscribe to event handlers testPort.SerialDataReadyEvent += testPort_SerialDataReadyEvent; //check if port is open if (testPort.OpenSerialPort()) { tbTestDebugOut.AppendText(testPort.PortName + " at " + testPort.BaudRate + " baud is open\n"); } else { tbTestDebugOut.AppendText("Error: " + testPort.ReadSerialData() + "\n"); } }