Table of Contents

Class ModbusClient

Namespace
FluentModbus
Assembly
FluentModbus.dll

A base class for Modbus client implementations.

public abstract class ModbusClient
Inheritance
ModbusClient
Derived

Methods

MaskWriteRegister()

This methdod is not implemented.

[Obsolete("This method is not implemented.")]
public void MaskWriteRegister()

MaskWriteRegisterAsync()

This methdod is not implemented.

[Obsolete("This method is not implemented.")]
public Task MaskWriteRegisterAsync()

Returns

Task

ReadCoils(int, int, int)

Reads the specified number of coils as byte array. Each bit of the returned array represents a single coil.

public Span<byte> ReadCoils(int unitIdentifier, int startingAddress, int quantity)

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress int

The coil start address for the read operation.

quantity int

The number of coils to read.

Returns

Span<byte>

ReadCoilsAsync(int, int, int, CancellationToken)

Reads the specified number of coils as byte array. Each bit of the returned array represents a single coil.

public Task<Memory<byte>> ReadCoilsAsync(int unitIdentifier, int startingAddress, int quantity, CancellationToken cancellationToken = default)

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress int

The coil start address for the read operation.

quantity int

The number of coils to read.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task<Memory<byte>>

ReadDiscreteInputs(int, int, int)

Reads the specified number of discrete inputs as byte array. Each bit of the returned array represents a single discrete input.

public Span<byte> ReadDiscreteInputs(int unitIdentifier, int startingAddress, int quantity)

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress int

The discrete input start address for the read operation.

quantity int

The number of discrete inputs to read.

Returns

Span<byte>

ReadDiscreteInputsAsync(int, int, int, CancellationToken)

Reads the specified number of discrete inputs as byte array. Each bit of the returned array represents a single discrete input.

public Task<Memory<byte>> ReadDiscreteInputsAsync(int unitIdentifier, int startingAddress, int quantity, CancellationToken cancellationToken = default)

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress int

The discrete input start address for the read operation.

quantity int

The number of discrete inputs to read.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task<Memory<byte>>

ReadFifoQueue()

This methdod is not implemented.

[Obsolete("This method is not implemented.")]
public void ReadFifoQueue()

ReadFifoQueueAsync()

This methdod is not implemented.

[Obsolete("This method is not implemented.")]
public Task ReadFifoQueueAsync()

Returns

Task

ReadFileRecord()

This methdod is not implemented.

[Obsolete("This method is not implemented.")]
public void ReadFileRecord()

ReadFileRecordAsync()

This methdod is not implemented.

[Obsolete("This method is not implemented.")]
public Task ReadFileRecordAsync()

Returns

Task

ReadHoldingRegisters(byte, ushort, ushort)

Low level API. Use the generic version of this method for easier access. Reads the specified number of values as byte array from the holding registers.

public Span<byte> ReadHoldingRegisters(byte unitIdentifier, ushort startingAddress, ushort quantity)

Parameters

unitIdentifier byte

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress ushort

The holding register start address for the read operation.

quantity ushort

The number of holding registers (16 bit per register) to read.

Returns

Span<byte>

ReadHoldingRegistersAsync(byte, ushort, ushort, CancellationToken)

Low level API. Use the generic version of this method for easier access. Reads the specified number of values as byte array from the holding registers.

public Task<Memory<byte>> ReadHoldingRegistersAsync(byte unitIdentifier, ushort startingAddress, ushort quantity, CancellationToken cancellationToken = default)

Parameters

unitIdentifier byte

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress ushort

The holding register start address for the read operation.

quantity ushort

The number of holding registers (16 bit per register) to read.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task<Memory<byte>>

ReadHoldingRegistersAsync<T>(int, int, int, CancellationToken)

Reads the specified number of values of type T from the holding registers.

public Task<Memory<T>> ReadHoldingRegistersAsync<T>(int unitIdentifier, int startingAddress, int count, CancellationToken cancellationToken = default) where T : unmanaged

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress int

The holding register start address for the read operation.

count int

The number of elements of type T to read.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task<Memory<T>>

Type Parameters

T

Determines the type of the returned data.

ReadHoldingRegisters<T>(int, int, int)

Reads the specified number of values of type T from the holding registers.

public Span<T> ReadHoldingRegisters<T>(int unitIdentifier, int startingAddress, int count) where T : unmanaged

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress int

The holding register start address for the read operation.

count int

The number of elements of type T to read.

Returns

Span<T>

Type Parameters

T

Determines the type of the returned data.

ReadInputRegisters(byte, ushort, ushort)

Low level API. Use the generic version of this method for easier access. Reads the specified number of values as byte array from the input registers.

public Span<byte> ReadInputRegisters(byte unitIdentifier, ushort startingAddress, ushort quantity)

Parameters

unitIdentifier byte

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress ushort

The input register start address for the read operation.

quantity ushort

The number of input registers (16 bit per register) to read.

Returns

Span<byte>

ReadInputRegistersAsync(byte, ushort, ushort, CancellationToken)

Low level API. Use the generic version of this method for easier access. Reads the specified number of values as byte array from the input registers.

public Task<Memory<byte>> ReadInputRegistersAsync(byte unitIdentifier, ushort startingAddress, ushort quantity, CancellationToken cancellationToken = default)

Parameters

unitIdentifier byte

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress ushort

The input register start address for the read operation.

quantity ushort

The number of input registers (16 bit per register) to read.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task<Memory<byte>>

ReadInputRegistersAsync<T>(int, int, int, CancellationToken)

Reads the specified number of values of type T from the input registers.

public Task<Memory<T>> ReadInputRegistersAsync<T>(int unitIdentifier, int startingAddress, int count, CancellationToken cancellationToken = default) where T : unmanaged

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress int

The input register start address for the read operation.

count int

The number of elements of type T to read.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task<Memory<T>>

Type Parameters

T

Determines the type of the returned data.

ReadInputRegisters<T>(int, int, int)

Reads the specified number of values of type T from the input registers.

public Span<T> ReadInputRegisters<T>(int unitIdentifier, int startingAddress, int count) where T : unmanaged

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress int

The input register start address for the read operation.

count int

The number of elements of type T to read.

Returns

Span<T>

Type Parameters

T

Determines the type of the returned data.

ReadWriteMultipleRegisters(byte, ushort, ushort, ushort, byte[])

Low level API. Use the generic version of this method for easier access. Reads the specified number of values as byte array from and writes the provided byte array to the holding registers. The write operation is performed before the read.

public Span<byte> ReadWriteMultipleRegisters(byte unitIdentifier, ushort readStartingAddress, ushort readQuantity, ushort writeStartingAddress, byte[] dataset)

Parameters

unitIdentifier byte

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

readStartingAddress ushort

The holding register start address for the read operation.

readQuantity ushort

The number of holding registers (16 bit per register) to read.

writeStartingAddress ushort

The holding register start address for the write operation.

dataset byte[]

The byte array to write to the server. A minimum of two bytes is required.

Returns

Span<byte>

ReadWriteMultipleRegistersAsync(byte, ushort, ushort, ushort, byte[], CancellationToken)

Low level API. Use the generic version of this method for easier access. Reads the specified number of values as byte array from and writes the provided byte array to the holding registers. The write operation is performed before the read.

public Task<Memory<byte>> ReadWriteMultipleRegistersAsync(byte unitIdentifier, ushort readStartingAddress, ushort readQuantity, ushort writeStartingAddress, byte[] dataset, CancellationToken cancellationToken = default)

Parameters

unitIdentifier byte

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

readStartingAddress ushort

The holding register start address for the read operation.

readQuantity ushort

The number of holding registers (16 bit per register) to read.

writeStartingAddress ushort

The holding register start address for the write operation.

dataset byte[]

The byte array to write to the server. A minimum of two bytes is required.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task<Memory<byte>>

ReadWriteMultipleRegistersAsync<TRead, TWrite>(int, int, int, int, TWrite[], CancellationToken)

Reads the specified number of values of type TRead from and writes the provided array of type TWrite to the holding registers. The write operation is performed before the read.

public Task<Memory<TRead>> ReadWriteMultipleRegistersAsync<TRead, TWrite>(int unitIdentifier, int readStartingAddress, int readCount, int writeStartingAddress, TWrite[] dataset, CancellationToken cancellationToken = default) where TRead : unmanaged where TWrite : unmanaged

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

readStartingAddress int

The holding register start address for the read operation.

readCount int

The number of elements of type TRead to read.

writeStartingAddress int

The holding register start address for the write operation.

dataset TWrite[]

The data of type TWrite to write to the server.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task<Memory<TRead>>

Type Parameters

TRead

Determines the type of the returned data.

TWrite

Determines the type of the provided data.

ReadWriteMultipleRegisters<TRead, TWrite>(int, int, int, int, TWrite[])

Reads the specified number of values of type TRead from and writes the provided array of type TWrite to the holding registers. The write operation is performed before the read.

public Span<TRead> ReadWriteMultipleRegisters<TRead, TWrite>(int unitIdentifier, int readStartingAddress, int readCount, int writeStartingAddress, TWrite[] dataset) where TRead : unmanaged where TWrite : unmanaged

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

readStartingAddress int

The holding register start address for the read operation.

readCount int

The number of elements of type TRead to read.

writeStartingAddress int

The holding register start address for the write operation.

dataset TWrite[]

The data of type TWrite to write to the server.

Returns

Span<TRead>

Type Parameters

TRead

Determines the type of the returned data.

TWrite

Determines the type of the provided data.

TransceiveFrame(byte, ModbusFunctionCode, Action<ExtendedBinaryWriter>)

Sends the requested modbus message and waits for the response.

protected abstract Span<byte> TransceiveFrame(byte unitIdentifier, ModbusFunctionCode functionCode, Action<ExtendedBinaryWriter> extendFrame)

Parameters

unitIdentifier byte

The unit identifier.

functionCode ModbusFunctionCode

The function code.

extendFrame Action<ExtendedBinaryWriter>

An action to be called to extend the prepared Modbus frame with function code specific data.

Returns

Span<byte>

TransceiveFrameAsync(byte, ModbusFunctionCode, Action<ExtendedBinaryWriter>, CancellationToken)

Sends the requested modbus message and waits for the response.

protected abstract Task<Memory<byte>> TransceiveFrameAsync(byte unitIdentifier, ModbusFunctionCode functionCode, Action<ExtendedBinaryWriter> extendFrame, CancellationToken cancellationToken = default)

Parameters

unitIdentifier byte

The unit identifier.

functionCode ModbusFunctionCode

The function code.

extendFrame Action<ExtendedBinaryWriter>

An action to be called to extend the prepared Modbus frame with function code specific data.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task<Memory<byte>>

WriteFileRecord()

This methdod is not implemented.

[Obsolete("This method is not implemented.")]
public void WriteFileRecord()

WriteFileRecordAsync()

This methdod is not implemented.

[Obsolete("This method is not implemented.")]
public Task WriteFileRecordAsync()

Returns

Task

WriteMultipleCoils(int, int, bool[])

Writes the provided values to the coil registers.

public void WriteMultipleCoils(int unitIdentifier, int startingAddress, bool[] values)

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress int

The coil register start address for the write operation.

values bool[]

The values to write to the server.

WriteMultipleCoilsAsync(int, int, bool[], CancellationToken)

Writes the provided values to the coil registers.

public void WriteMultipleCoilsAsync(int unitIdentifier, int startingAddress, bool[] values, CancellationToken cancellationToken = default)

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress int

The coil register start address for the write operation.

values bool[]

The values to write to the server.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

WriteMultipleRegisters(byte, ushort, byte[])

Low level API. Use the generic version of this method for easier access. Writes the provided byte array to the holding registers.

public void WriteMultipleRegisters(byte unitIdentifier, ushort startingAddress, byte[] dataset)

Parameters

unitIdentifier byte

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress ushort

The holding register start address for the write operation.

dataset byte[]

The byte array to write to the server. A minimum of two bytes is required.

WriteMultipleRegistersAsync(byte, ushort, byte[], CancellationToken)

Low level API. Use the generic version of this method for easier access. Writes the provided byte array to the holding registers.

public Task WriteMultipleRegistersAsync(byte unitIdentifier, ushort startingAddress, byte[] dataset, CancellationToken cancellationToken = default)

Parameters

unitIdentifier byte

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress ushort

The holding register start address for the write operation.

dataset byte[]

The byte array to write to the server. A minimum of two bytes is required.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task

WriteMultipleRegistersAsync<T>(int, int, T[], CancellationToken)

Writes the provided array of type T to the holding registers.

public Task WriteMultipleRegistersAsync<T>(int unitIdentifier, int startingAddress, T[] dataset, CancellationToken cancellationToken = default) where T : unmanaged

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress int

The holding register start address for the write operation.

dataset T[]

The data of type T to write to the server.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task

Type Parameters

T

Determines the type of the provided data.

WriteMultipleRegisters<T>(int, int, T[])

Writes the provided array of type T to the holding registers.

public void WriteMultipleRegisters<T>(int unitIdentifier, int startingAddress, T[] dataset) where T : unmanaged

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

startingAddress int

The holding register start address for the write operation.

dataset T[]

The data of type T to write to the server.

Type Parameters

T

Determines the type of the provided data.

WriteSingleCoil(int, int, bool)

Writes the provided value to the coil registers.

public void WriteSingleCoil(int unitIdentifier, int registerAddress, bool value)

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

registerAddress int

The coil address for the write operation.

value bool

The value to write to the server.

WriteSingleCoilAsync(int, int, bool, CancellationToken)

Writes the provided value to the coil registers.

public Task WriteSingleCoilAsync(int unitIdentifier, int registerAddress, bool value, CancellationToken cancellationToken = default)

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

registerAddress int

The coil address for the write operation.

value bool

The value to write to the server.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task

WriteSingleRegister(byte, ushort, byte[])

Low level API. Use the overloads of this method for easier access. Writes the provided byte array to the holding register.

public void WriteSingleRegister(byte unitIdentifier, ushort registerAddress, byte[] value)

Parameters

unitIdentifier byte

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

registerAddress ushort

The holding register address for the write operation.

value byte[]

The value to write to the server, which is passed as a 2-byte array.

WriteSingleRegister(int, int, short)

Writes the provided value to the holding registers.

public void WriteSingleRegister(int unitIdentifier, int registerAddress, short value)

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

registerAddress int

The holding register address for the write operation.

value short

The value to write to the server.

WriteSingleRegister(int, int, ushort)

Writes the provided value to the holding registers.

public void WriteSingleRegister(int unitIdentifier, int registerAddress, ushort value)

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

registerAddress int

The holding register address for the write operation.

value ushort

The value to write to the server.

WriteSingleRegisterAsync(byte, ushort, byte[], CancellationToken)

Low level API. Use the overloads of this method for easier access. Writes the provided byte array to the holding register.

public Task WriteSingleRegisterAsync(byte unitIdentifier, ushort registerAddress, byte[] value, CancellationToken cancellationToken = default)

Parameters

unitIdentifier byte

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

registerAddress ushort

The holding register address for the write operation.

value byte[]

The value to write to the server, which is passed as a 2-byte array.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task

WriteSingleRegisterAsync(int, int, short, CancellationToken)

Writes the provided value to the holding registers.

public Task WriteSingleRegisterAsync(int unitIdentifier, int registerAddress, short value, CancellationToken cancellationToken = default)

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

registerAddress int

The holding register address for the write operation.

value short

The value to write to the server.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task

WriteSingleRegisterAsync(int, int, ushort, CancellationToken)

Writes the provided value to the holding registers.

public Task WriteSingleRegisterAsync(int unitIdentifier, int registerAddress, ushort value, CancellationToken cancellationToken = default)

Parameters

unitIdentifier int

The unit identifier is used to communicate via devices such as bridges, routers and gateways that use a single IP address to support multiple independent Modbus end units. Thus, the unit identifier is the address of a remote slave connected on a serial line or on other buses. Use the default values 0x00 or 0xFF when communicating to a Modbus server that is directly connected to a TCP/IP network.

registerAddress int

The holding register address for the write operation.

value ushort

The value to write to the server.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task