Class ModbusRtuServer
- Namespace
- FluentModbus
- Assembly
- FluentModbus.dll
A Modbus RTU server.
public class ModbusRtuServer : ModbusServer, IDisposable
- Inheritance
-
ModbusRtuServer
- Implements
- Inherited Members
Constructors
ModbusRtuServer(byte)
Creates a Modbus RTU server with support for holding registers (read and write, 16 bit), input registers (read-only, 16 bit), coils (read and write, 1 bit) and discete inputs (read-only, 1 bit).
public ModbusRtuServer(byte unitIdentifier)
Parameters
unitIdentifier
byteThe unique Modbus RTU unit identifier (1..247).
ModbusRtuServer(byte, bool)
Creates a Modbus RTU server with support for holding registers (read and write, 16 bit), input registers (read-only, 16 bit), coils (read and write, 1 bit) and discete inputs (read-only, 1 bit).
public ModbusRtuServer(byte unitIdentifier, bool isAsynchronous)
Parameters
unitIdentifier
byteThe unique Modbus RTU unit identifier (1..247).
isAsynchronous
boolEnables or disables the asynchronous operation, where each client request is processed immediately using a locking mechanism. Use synchronuous operation to avoid locks in the hosting application. See the documentation for more details.
ModbusRtuServer(IEnumerable<byte>)
Creates a multi-unit Modbus RTU server with support for holding registers (read and write, 16 bit), input registers (read-only, 16 bit), coils (read and write, 1 bit) and discete inputs (read-only, 1 bit).
public ModbusRtuServer(IEnumerable<byte> unitIdentifiers)
Parameters
unitIdentifiers
IEnumerable<byte>The unique Modbus RTU unit identifiers (1..247).
ModbusRtuServer(IEnumerable<byte>, bool)
Creates a multi-unit Modbus RTU server with support for holding registers (read and write, 16 bit), input registers (read-only, 16 bit), coils (read and write, 1 bit) and discete inputs (read-only, 1 bit).
public ModbusRtuServer(IEnumerable<byte> unitIdentifiers, bool isAsynchronous)
Parameters
unitIdentifiers
IEnumerable<byte>The unique Modbus RTU unit identifiers (1..247).
isAsynchronous
boolEnables or disables the asynchronous operation, where each client request is processed immediately using a locking mechanism. Use synchronuous operation to avoid locks in the hosting application. See the documentation for more details.
Properties
BaudRate
Gets or sets the serial baud rate. Default is 9600.
public int BaudRate { get; set; }
Property Value
Handshake
Gets or sets the handshaking protocol for serial port transmission of data. Default is Handshake.None.
public Handshake Handshake { get; set; }
Property Value
IsConnected
Gets the connection status of the underlying serial port.
public bool IsConnected { get; }
Property Value
Parity
Gets or sets the parity-checking protocol. Default is Parity.Even.
public Parity Parity { get; set; }
Property Value
ReadTimeout
Gets or sets the read timeout in milliseconds. Default is 1000 ms.
public int ReadTimeout { get; set; }
Property Value
StopBits
Gets or sets the standard number of stopbits per byte. Default is StopBits.One.
public StopBits StopBits { get; set; }
Property Value
WriteTimeout
Gets or sets the write timeout in milliseconds. Default is 1000 ms.
public int WriteTimeout { get; set; }
Property Value
Methods
AddUnit(byte)
Dynamically adds a new unit to the server.
public void AddUnit(byte unitIdentifier)
Parameters
unitIdentifier
byteThe identifier of the unit to add.
ProcessRequests()
Process incoming requests.
protected override void ProcessRequests()
Start(IModbusRtuSerialPort)
Starts the server. It will communicate using the provided serialPort
.
public void Start(IModbusRtuSerialPort serialPort)
Parameters
serialPort
IModbusRtuSerialPortThe serial port to be used.
Start(string)
Starts the server. It will listen on the provided port
.
public void Start(string port)
Parameters
port
stringThe COM port to be used, e.g. COM1.
Stop()
Stops the server and closes the underlying serial port.
public override void Stop()