private void Open(string port, int baud, ComPortLib.Parity parity, int dataBits, ComPortLib.StopBits stopBits)//, int timeout) { _port = new SerialPort(port, baud, ConvertParity(parity), dataBits, ConvertStopBits(stopBits)); _port.Open(); if (PortOpenedEvent != null) { PortOpenedEvent.Invoke(); } }
private Parity ConvertParity(ComPortLib.Parity parity) { switch (parity) { case ComPortLib.Parity.None: return(Parity.None); case ComPortLib.Parity.Odd: return(Parity.Odd); case ComPortLib.Parity.Even: return(Parity.Even); default: throw new Exception("Parity converter exception"); } }
public SerialComm(string port, int baud, ComPortLib.Parity parity, int dataBits, ComPortLib.StopBits stopBits) { Open(port, baud, parity, dataBits, stopBits); }