Interface IModbusMaster
Modbus master device.
Inherited Members
Namespace: NModbus
Assembly: NModbus.dll
Syntax
public interface IModbusMaster : IDisposable
Properties
| Improve this Doc View SourceTransport
Transport used by this master.
Declaration
IModbusTransport Transport { get; }
Property Value
Type | Description |
---|---|
IModbusTransport |
Methods
| Improve this Doc View SourceExecuteCustomMessage<TResponse>(IModbusMessage)
Executes the custom message.
Declaration
TResponse ExecuteCustomMessage<TResponse>(IModbusMessage request)where TResponse : IModbusMessage, new ()
Parameters
Type | Name | Description |
---|---|---|
IModbusMessage | request | The request. |
Returns
Type | Description |
---|---|
TResponse |
Type Parameters
Name | Description |
---|---|
TResponse | The type of the response. |
ReadCoils(Byte, UInt16, UInt16)
Reads from 1 to 2000 contiguous coils status.
Declaration
bool[] ReadCoils(byte slaveAddress, ushort startAddress, ushort numberOfPoints)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of device to read values from. |
System.UInt16 | startAddress | Address to begin reading. |
System.UInt16 | numberOfPoints | Number of coils to read. |
Returns
Type | Description |
---|---|
System.Boolean[] | Coils status. |
ReadCoilsAsync(Byte, UInt16, UInt16)
Asynchronously reads from 1 to 2000 contiguous coils status.
Declaration
Task<bool[]> ReadCoilsAsync(byte slaveAddress, ushort startAddress, ushort numberOfPoints)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of device to read values from. |
System.UInt16 | startAddress | Address to begin reading. |
System.UInt16 | numberOfPoints | Number of coils to read. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean[]> | A task that represents the asynchronous read operation. |
ReadHoldingRegisters(Byte, UInt16, UInt16)
Reads contiguous block of holding registers.
Declaration
ushort[] ReadHoldingRegisters(byte slaveAddress, ushort startAddress, ushort numberOfPoints)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of device to read values from. |
System.UInt16 | startAddress | Address to begin reading. |
System.UInt16 | numberOfPoints | Number of holding registers to read. |
Returns
Type | Description |
---|---|
System.UInt16[] | Holding registers status. |
ReadHoldingRegistersAsync(Byte, UInt16, UInt16)
Asynchronously reads contiguous block of holding registers.
Declaration
Task<ushort[]> ReadHoldingRegistersAsync(byte slaveAddress, ushort startAddress, ushort numberOfPoints)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of device to read values from. |
System.UInt16 | startAddress | Address to begin reading. |
System.UInt16 | numberOfPoints | Number of holding registers to read. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.UInt16[]> | A task that represents the asynchronous read operation. |
ReadInputRegisters(Byte, UInt16, UInt16)
Reads contiguous block of input registers.
Declaration
ushort[] ReadInputRegisters(byte slaveAddress, ushort startAddress, ushort numberOfPoints)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of device to read values from. |
System.UInt16 | startAddress | Address to begin reading. |
System.UInt16 | numberOfPoints | Number of holding registers to read. |
Returns
Type | Description |
---|---|
System.UInt16[] | Input registers status. |
ReadInputRegistersAsync(Byte, UInt16, UInt16)
Asynchronously reads contiguous block of input registers.
Declaration
Task<ushort[]> ReadInputRegistersAsync(byte slaveAddress, ushort startAddress, ushort numberOfPoints)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of device to read values from. |
System.UInt16 | startAddress | Address to begin reading. |
System.UInt16 | numberOfPoints | Number of holding registers to read. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.UInt16[]> | A task that represents the asynchronous read operation. |
ReadInputs(Byte, UInt16, UInt16)
Reads from 1 to 2000 contiguous discrete input status.
Declaration
bool[] ReadInputs(byte slaveAddress, ushort startAddress, ushort numberOfPoints)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of device to read values from. |
System.UInt16 | startAddress | Address to begin reading. |
System.UInt16 | numberOfPoints | Number of discrete inputs to read. |
Returns
Type | Description |
---|---|
System.Boolean[] | Discrete inputs status. |
ReadInputsAsync(Byte, UInt16, UInt16)
Asynchronously reads from 1 to 2000 contiguous discrete input status.
Declaration
Task<bool[]> ReadInputsAsync(byte slaveAddress, ushort startAddress, ushort numberOfPoints)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of device to read values from. |
System.UInt16 | startAddress | Address to begin reading. |
System.UInt16 | numberOfPoints | Number of discrete inputs to read. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean[]> | A task that represents the asynchronous read operation. |
ReadWriteMultipleRegisters(Byte, UInt16, UInt16, UInt16, UInt16[])
Performs a combination of one read operation and one write operation in a single Modbus transaction. The write operation is performed before the read.
Declaration
ushort[] ReadWriteMultipleRegisters(byte slaveAddress, ushort startReadAddress, ushort numberOfPointsToRead, ushort startWriteAddress, ushort[] writeData)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of device to read values from. |
System.UInt16 | startReadAddress | Address to begin reading (Holding registers are addressed starting at 0). |
System.UInt16 | numberOfPointsToRead | Number of registers to read. |
System.UInt16 | startWriteAddress | Address to begin writing (Holding registers are addressed starting at 0). |
System.UInt16[] | writeData | Register values to write. |
Returns
Type | Description |
---|---|
System.UInt16[] |
ReadWriteMultipleRegistersAsync(Byte, UInt16, UInt16, UInt16, UInt16[])
Asynchronously performs a combination of one read operation and one write operation in a single Modbus transaction. The write operation is performed before the read.
Declaration
Task<ushort[]> ReadWriteMultipleRegistersAsync(byte slaveAddress, ushort startReadAddress, ushort numberOfPointsToRead, ushort startWriteAddress, ushort[] writeData)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of device to read values from. |
System.UInt16 | startReadAddress | Address to begin reading (Holding registers are addressed starting at 0). |
System.UInt16 | numberOfPointsToRead | Number of registers to read. |
System.UInt16 | startWriteAddress | Address to begin writing (Holding registers are addressed starting at 0). |
System.UInt16[] | writeData | Register values to write. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.UInt16[]> | A task that represents the asynchronous operation |
WriteMultipleCoils(Byte, UInt16, Boolean[])
Writes a sequence of coils.
Declaration
void WriteMultipleCoils(byte slaveAddress, ushort startAddress, bool[] data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of the device to write to. |
System.UInt16 | startAddress | Address to begin writing values. |
System.Boolean[] | data | Values to write. |
WriteMultipleCoilsAsync(Byte, UInt16, Boolean[])
Asynchronously writes a sequence of coils.
Declaration
Task WriteMultipleCoilsAsync(byte slaveAddress, ushort startAddress, bool[] data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of the device to write to. |
System.UInt16 | startAddress | Address to begin writing values. |
System.Boolean[] | data | Values to write. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task that represents the asynchronous write operation. |
WriteMultipleRegisters(Byte, UInt16, UInt16[])
Writes a block of 1 to 123 contiguous registers.
Declaration
void WriteMultipleRegisters(byte slaveAddress, ushort startAddress, ushort[] data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of the device to write to. |
System.UInt16 | startAddress | Address to begin writing values. |
System.UInt16[] | data | Values to write. |
WriteMultipleRegistersAsync(Byte, UInt16, UInt16[])
Asynchronously writes a block of 1 to 123 contiguous registers.
Declaration
Task WriteMultipleRegistersAsync(byte slaveAddress, ushort startAddress, ushort[] data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of the device to write to. |
System.UInt16 | startAddress | Address to begin writing values. |
System.UInt16[] | data | Values to write. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task that represents the asynchronous write operation. |
WriteSingleCoil(Byte, UInt16, Boolean)
Writes a single coil value.
Declaration
void WriteSingleCoil(byte slaveAddress, ushort coilAddress, bool value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of the device to write to. |
System.UInt16 | coilAddress | Address to write value to. |
System.Boolean | value | Value to write. |
WriteSingleCoilAsync(Byte, UInt16, Boolean)
Asynchronously writes a single coil value.
Declaration
Task WriteSingleCoilAsync(byte slaveAddress, ushort coilAddress, bool value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of the device to write to. |
System.UInt16 | coilAddress | Address to write value to. |
System.Boolean | value | Value to write. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task that represents the asynchronous write operation. |
WriteSingleRegister(Byte, UInt16, UInt16)
Writes a single holding register.
Declaration
void WriteSingleRegister(byte slaveAddress, ushort registerAddress, ushort value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of the device to write to. |
System.UInt16 | registerAddress | Address to write. |
System.UInt16 | value | Value to write. |
WriteSingleRegisterAsync(Byte, UInt16, UInt16)
Asynchronously writes a single holding register.
Declaration
Task WriteSingleRegisterAsync(byte slaveAddress, ushort registerAddress, ushort value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slaveAddress | Address of the device to write to. |
System.UInt16 | registerAddress | Address to write. |
System.UInt16 | value | Value to write. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task that represents the asynchronous write operation. |