/// <summary> /// setter serial port /// </summary> /// <param name="port">port name</param> public void SetPort(String port) { initPort = new InitialPort(); initPort.Comport = port; initPort.BaudRate = 9600; initPort.DataBits = 8; initPort.DtrEnable = false; _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); }