/// <summary> /// /// </summary> /// <param name="port"></param> /// <param name="settings"></param> /// <param name="dataReceived"></param> public void Handshake(string port, ComSettings settings, DataReceived dataReceived = null) { if (_comPort == null) { _comPort = new SerialPort(port); if (settings != null) { _comPort.BaudRate = settings.BaudRate; //set baud rate _comPort.Parity = settings.ParityBit; //set parity bit _comPort.DataBits = settings.DataBits; //set data bits _comPort.StopBits = settings.StopBit; //set stop bit } if (dataReceived != null) { _dataReceived = dataReceived; _comPort.DataReceived += new SerialDataReceivedEventHandler(_comPort_DataReceived); } } }
public ComLibrary(ComSettings pSettings) { this.settings = ObjectMerge <ComSettings>(_defaults, pSettings); }