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
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
unitIdentifierintThe 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.
startingAddressintThe coil start address for the read operation.
quantityintThe number of coils to read.
Returns
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
unitIdentifierintThe 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.
startingAddressintThe coil start address for the read operation.
quantityintThe number of coils to read.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
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
unitIdentifierintThe 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.
startingAddressintThe discrete input start address for the read operation.
quantityintThe number of discrete inputs to read.
Returns
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
unitIdentifierintThe 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.
startingAddressintThe discrete input start address for the read operation.
quantityintThe number of discrete inputs to read.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
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
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
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
unitIdentifierbyteThe 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.
startingAddressushortThe holding register start address for the read operation.
quantityushortThe number of holding registers (16 bit per register) to read.
Returns
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
unitIdentifierbyteThe 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.
startingAddressushortThe holding register start address for the read operation.
quantityushortThe number of holding registers (16 bit per register) to read.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
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
unitIdentifierintThe 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.
startingAddressintThe holding register start address for the read operation.
countintThe number of elements of type
Tto read.cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
Type Parameters
TDetermines 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
unitIdentifierintThe 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.
startingAddressintThe holding register start address for the read operation.
countintThe number of elements of type
Tto read.
Returns
- Span<T>
Type Parameters
TDetermines 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
unitIdentifierbyteThe 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.
startingAddressushortThe input register start address for the read operation.
quantityushortThe number of input registers (16 bit per register) to read.
Returns
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
unitIdentifierbyteThe 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.
startingAddressushortThe input register start address for the read operation.
quantityushortThe number of input registers (16 bit per register) to read.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
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
unitIdentifierintThe 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.
startingAddressintThe input register start address for the read operation.
countintThe number of elements of type
Tto read.cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
Type Parameters
TDetermines 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
unitIdentifierintThe 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.
startingAddressintThe input register start address for the read operation.
countintThe number of elements of type
Tto read.
Returns
- Span<T>
Type Parameters
TDetermines 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
unitIdentifierbyteThe 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.
readStartingAddressushortThe holding register start address for the read operation.
readQuantityushortThe number of holding registers (16 bit per register) to read.
writeStartingAddressushortThe holding register start address for the write operation.
datasetbyte[]The byte array to write to the server. A minimum of two bytes is required.
Returns
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
unitIdentifierbyteThe 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.
readStartingAddressushortThe holding register start address for the read operation.
readQuantityushortThe number of holding registers (16 bit per register) to read.
writeStartingAddressushortThe holding register start address for the write operation.
datasetbyte[]The byte array to write to the server. A minimum of two bytes is required.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
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
unitIdentifierintThe 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.
readStartingAddressintThe holding register start address for the read operation.
readCountintThe number of elements of type
TReadto read.writeStartingAddressintThe holding register start address for the write operation.
datasetTWrite[]The data of type
TWriteto write to the server.cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
Type Parameters
TReadDetermines the type of the returned data.
TWriteDetermines 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
unitIdentifierintThe 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.
readStartingAddressintThe holding register start address for the read operation.
readCountintThe number of elements of type
TReadto read.writeStartingAddressintThe holding register start address for the write operation.
datasetTWrite[]The data of type
TWriteto write to the server.
Returns
- Span<TRead>
Type Parameters
TReadDetermines the type of the returned data.
TWriteDetermines 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
unitIdentifierbyteThe unit identifier.
functionCodeModbusFunctionCodeThe function code.
extendFrameAction<ExtendedBinaryWriter>An action to be called to extend the prepared Modbus frame with function code specific data.
Returns
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
unitIdentifierbyteThe unit identifier.
functionCodeModbusFunctionCodeThe function code.
extendFrameAction<ExtendedBinaryWriter>An action to be called to extend the prepared Modbus frame with function code specific data.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
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
WriteMultipleCoils(int, int, bool[])
Writes the provided values to the coil registers.
public void WriteMultipleCoils(int unitIdentifier, int startingAddress, bool[] values)
Parameters
unitIdentifierintThe 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.
startingAddressintThe coil register start address for the write operation.
valuesbool[]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
unitIdentifierintThe 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.
startingAddressintThe coil register start address for the write operation.
valuesbool[]The values to write to the server.
cancellationTokenCancellationTokenThe 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
unitIdentifierbyteThe 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.
startingAddressushortThe holding register start address for the write operation.
datasetbyte[]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
unitIdentifierbyteThe 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.
startingAddressushortThe holding register start address for the write operation.
datasetbyte[]The byte array to write to the server. A minimum of two bytes is required.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
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
unitIdentifierintThe 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.
startingAddressintThe holding register start address for the write operation.
datasetT[]The data of type
Tto write to the server.cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
Type Parameters
TDetermines 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
unitIdentifierintThe 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.
startingAddressintThe holding register start address for the write operation.
datasetT[]The data of type
Tto write to the server.
Type Parameters
TDetermines 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
unitIdentifierintThe 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.
registerAddressintThe coil address for the write operation.
valueboolThe 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
unitIdentifierintThe 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.
registerAddressintThe coil address for the write operation.
valueboolThe value to write to the server.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
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
unitIdentifierbyteThe 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.
registerAddressushortThe holding register address for the write operation.
valuebyte[]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
unitIdentifierintThe 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.
registerAddressintThe holding register address for the write operation.
valueshortThe 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
unitIdentifierintThe 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.
registerAddressintThe holding register address for the write operation.
valueushortThe 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
unitIdentifierbyteThe 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.
registerAddressushortThe holding register address for the write operation.
valuebyte[]The value to write to the server, which is passed as a 2-byte array.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
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
unitIdentifierintThe 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.
registerAddressintThe holding register address for the write operation.
valueshortThe value to write to the server.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
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
unitIdentifierintThe 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.
registerAddressintThe holding register address for the write operation.
valueushortThe value to write to the server.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.