Table of Contents

Class ModbusServer

Namespace
Iot.Device.Modbus.Server
Assembly
Iot.Device.Modbus.dll

Modbus server implementation that listens for Modbus requests and handles them.

public class ModbusServer : Port
Inheritance
ModbusServer
Inherited Members

Constructors

ModbusServer(ModbusDevice, SerialPort, SerialMode)

Initializes a new instance of the ModbusServer class with the specified Modbus device and serial port.

public ModbusServer(ModbusDevice device, SerialPort port, SerialMode mode = SerialMode.RS485)

Parameters

device ModbusDevice

The Modbus device.

port SerialPort

The serial port.

mode SerialMode

The mode of serial port, default is RS485.

ModbusServer(ModbusDevice, string, int, Parity, int, StopBits, SerialMode)

Initializes a new instance of the ModbusServer class with the specified Modbus device and communication parameters.

public ModbusServer(ModbusDevice device, string portName, int baudRate = 9600, Parity parity = Parity.None, int dataBits = 8, StopBits stopBits = StopBits.One, SerialMode mode = SerialMode.RS485)

Parameters

device ModbusDevice

The Modbus device.

portName string

The name of the serial port.

baudRate int

The baud rate.

parity Parity

The parity.

dataBits int

The number of data bits.

stopBits StopBits

The stop bits.

mode SerialMode

The mode of serial port, default is RS485.

Methods

DataReceived(int)

Called when data is received on the serial port.

protected override void DataReceived(int bytesToRead)

Parameters

bytesToRead int

The number of bytes to read from the serial port.

StartListening()

Starts listening for Modbus requests on the server.

public void StartListening()