public CommTest() { InitializeComponent(); port = new SyncSerialPort(portName, baudRate, parity, dataBits, stopBits); if (port.Open()) { writeToLog(string.Format("Port: {0} open\n", portName)); } else { writeToLog(string.Format("Port failed to open with ex: {0}" + System.Environment.NewLine)); return; } }
public CommTest(string newPort) { InitializeComponent(); portName = newPort; port = new SyncSerialPort(portName, baudRate, parity, dataBits, stopBits); try { if (port.Open()) { writeToLog(string.Format("Port: {0} open\n", portName)); } else { writeToLog(string.Format("Failed to open port {0} ", portName)); } } catch (Exception ex) { writeToLog(string.Format("Port failed to open with ex: {0}" + System.Environment.NewLine, ex.Message)); } }
public bool open() { return(port.Open()); }