Interface IModbusMaster
- Namespace
- Loehnert.Lisrt.Communication.Modbus
- Assembly
- Loehnert.Lisrt.Communication.Modbus.dll
Interface for a Modbus master. Modbus documentation: https://modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf.
public interface IModbusMaster : IInitializable, INotifyPropertyChangedEx, INotifyPropertyChanged
- Inherited Members
-
INotifyPropertyChangedEx.Refresh()INotifyPropertyChangedEx.IsNotifying
Methods
ExecuteCustomMessage<TResponse>(ICustomMessage)
Writes and reads a custom message (FC FunctionCode).
TResponse ExecuteCustomMessage<TResponse>(ICustomMessage request) where TResponse : ICustomMessage, new()
Parameters
request
ICustomMessageA custom message request.
Returns
- TResponse
The response.
Type Parameters
TResponse
The type of the response.
ReadCoils(byte, ushort, ushort)
Reads coils status (FC 01).
IEnumerable<bool> ReadCoils(byte slaveAddress, ushort startAddress, ushort quantity)
Parameters
slaveAddress
byteAddress of device to read values from.
startAddress
ushortAddress to begin reading.
quantity
ushortNumber of coils to read.
Returns
- IEnumerable<bool>
Coils status.
ReadDiscreteInputs(byte, ushort, ushort)
Reads discrete inputs (FC 02).
IEnumerable<bool> ReadDiscreteInputs(byte slaveAddress, ushort startAddress, ushort quantity)
Parameters
slaveAddress
byteAddress of device to read values from.
startAddress
ushortAddress to begin reading.
quantity
ushortNumber of inputs to read.
Returns
- IEnumerable<bool>
Inputs status.
ReadHoldingRegisters(byte, ushort, ushort)
Reads the contents of a contiguous block of holding registers (FC 03).
IEnumerable<ushort> ReadHoldingRegisters(byte slaveAddress, ushort startAddress, ushort quantity)
Parameters
slaveAddress
byteAddress of device to read values from.
startAddress
ushortAddress to begin reading.
quantity
ushortNumber of inputs to read.
Returns
- IEnumerable<ushort>
Holding register status.
ReadInputRegisters(byte, ushort, ushort)
Reads contiguous input registers (FC 04).
IEnumerable<ushort> ReadInputRegisters(byte slaveAddress, ushort startAddress, ushort quantity)
Parameters
slaveAddress
byteAddress of device to read values from.
startAddress
ushortAddress to begin reading.
quantity
ushortNumber of inputs to read.
Returns
- IEnumerable<ushort>
Input register status.
ReadWriteHoldingRegisters(byte, ushort, ushort, ushort, IEnumerable<ushort>)
Performs a combination of one read operation and one write operation in a single Modbus transaction. The write operation is performed before the read.
IEnumerable<ushort> ReadWriteHoldingRegisters(byte slaveAddress, ushort readStartingAddress, ushort readQuantity, ushort writeStartingAddress, IEnumerable<ushort> writeValues)
Parameters
slaveAddress
byteAddress of device to read values from.
readStartingAddress
ushortAddress to begin reading.
readQuantity
ushortNumber of inputs to read.
writeStartingAddress
ushortAddress to begin writing.
writeValues
IEnumerable<ushort>Values to write.
Returns
- IEnumerable<ushort>
Read holding register status.
WriteCoil(byte, ushort, bool)
Writes single coil status (FC 05).
void WriteCoil(byte slaveAddress, ushort address, bool value)
Parameters
slaveAddress
byteAddress of the device to write to.
address
ushortAddress to write.
value
boolValue to write.
WriteHoldingRegister(byte, ushort, ushort)
Writes a single holding register (FC 06).
void WriteHoldingRegister(byte slaveAddress, ushort address, ushort value)
Parameters
slaveAddress
byteAddress of the device to write to.
address
ushortAddress to write.
value
ushortValue to write.
WriteMultipleCoils(byte, ushort, IEnumerable<bool>)
Writes multiple coils status (FC 15).
void WriteMultipleCoils(byte slaveAddress, ushort startAddress, IEnumerable<bool> values)
Parameters
slaveAddress
byteAddress of the device to write to.
startAddress
ushortAddress to begin writing.
values
IEnumerable<bool>Values to write.
WriteMultipleHoldingRegisters(byte, ushort, IEnumerable<ushort>)
Writes a block of contiguous registers (FC 16).
void WriteMultipleHoldingRegisters(byte slaveAddress, ushort startAddress, IEnumerable<ushort> values)
Parameters
slaveAddress
byteAddress of the device to write to.
startAddress
ushortAddress to begin writing.
values
IEnumerable<ushort>Values to write.