/// <summary> /// setter port name /// </summary> /// <param name="port">Port Name String</param> public void SetPort(string port) { initPort = new InitialPort(); initPort.Comport = port; initPort.BaudRate = 9600; initPort.DataBits = 8; initPort.DtrEnable = true; _serialPort = Initial(initPort); }
/// <summary> /// Initial serial port /// </summary> /// <param name="init">port config class</param> /// <returns></returns> protected SerialPort Initial(InitialPort init) { SerialPort _serialport = new SerialPort(); _serialport.PortName = init.Comport; _serialport.BaudRate = init.BaudRate; _serialport.DataBits = init.DataBits; _serialport.StopBits = StopBits.One; _serialport.DtrEnable = init.DtrEnable; _serialport.Parity = Parity.Even; //_serialport.RtsEnable = true; return(_serialport); }