/// <summary> /// Creates a new instance of the ModBusClient and sets the default parameters. /// The default values are: BaudRate = 19200, Parity = None, DataBits = 8, StopBits = One. /// It also sets the Mode of the client to RTU. /// </summary> /// <param name="SerialPortName">Serial port name.</param> public ModBusClient(string SerialPortName) { this.SerialPortName = SerialPortName; this.BaudRate = 19200; this.Parity = Parity.None; this.DataBits = 8; this.StopBits = StopBits.One; this.Mode = ModBusMode.RTU; }
public ModBus(ModBusMode mode, int port, int baudrate, SerialPortMode serialPortMode) { Mode = mode; Port = port; Baudrate = baudrate; SerialPortMode = serialPortMode; HardwareInterface = new HardwareInterface(port, baudrate, new Commands[] { Commands.SendOverSerialPort, Commands.InitSerialPort }); PendingReadRequestList = new SyncList <ModBusReadRequest>(); _maxSendCapacity = SettingManager.Instance.Settings.MaxSendListCapacity; HardwareInterface.OnReceiceNewPacket += HardwareInterface_OnReceiceNewPacket; }
/// <summary> /// Creates a new instance of the ModBusClient. /// If no Port is provided the default (502) is set. /// It also sets the Mode of the client to TCP. /// </summary> /// <param name="IPAddress">IP Address.</param> /// <param name="Port">Port.</param> public ModBusClient(string IPAddress, ushort Port = 502) { this.IPAddress = IPAddress; this.Port = Port; this.Mode = ModBusMode.TCP; }