internal void Start(IModbusRtuSerialPort serialPort) { if (this.Parity == Parity.None && this.StopBits != StopBits.Two) { throw new InvalidOperationException(ErrorMessage.Modbus_NoParityRequiresTwoStopBits); } // "base..." is important! base.Stop(); base.Start(); this.RequestHandler = new ModbusRtuRequestHandler(serialPort, this); }
/// <summary> /// Starts the server. It will communicate using the provided <paramref name="serialPort"/>. /// </summary> /// <param name="serialPort">The serial port to be used.</param> public void Start(IModbusRtuSerialPort serialPort) { /* According to the spec (https://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf), * section 2.5.1 RTU Transmission Mode: "... the use of no parity requires 2 stop bits." * Remove this check to improve compatibility (#56). */ //if (this.Parity == Parity.None && this.StopBits != StopBits.Two) // throw new InvalidOperationException(ErrorMessage.Modbus_NoParityRequiresTwoStopBits); base.StopProcessing(); base.StartProcessing(); this.RequestHandler = new ModbusRtuRequestHandler(serialPort, this); }