public SerialParser(byte portNumber, int baudRate, IValueParserAdd valueParserAdd) : this(new SerialPort(), valueParserAdd) { this.serialPort.BaudRate = baudRate; this.serialPort.PortName = "COM" + portNumber; this.serialPort.Open(); }
public SerialParser(SerialPort serial, IValueParserAdd valueParserAdd) { this.valueParserAdd = valueParserAdd; this.serialPort = serial; this.serialPort.DataReceived += Serial_DataReceived; this.serialPort.ErrorReceived += SerialPort_ErrorReceived; this.serialPort.Disposed += SerialPort_Disposed; valueBuilder = new StringBuilder(); }