Class ModbusServer
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
deviceModbusDeviceThe Modbus device.
portSerialPortThe serial port.
modeSerialModeThe 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
deviceModbusDeviceThe Modbus device.
portNamestringThe name of the serial port.
baudRateintThe baud rate.
parityParityThe parity.
dataBitsintThe number of data bits.
stopBitsStopBitsThe stop bits.
modeSerialModeThe 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
bytesToReadintThe number of bytes to read from the serial port.
StartListening()
Starts listening for Modbus requests on the server.
public void StartListening()