Interface class for slave devices in a Modbus network. More...
#include <SlaveDeviceIfc.h>
Public Member Functions | |
virtual | ~SlaveDeviceIfc ()=default |
template<ModbusData D> | |
ModbusError | writeHolding (uint16_t reg, const D &data) const |
Write data to a holding register. | |
template<ModbusData D> | |
SlaveReturn< D > | readHolding (uint16_t reg) const |
Read data from a holding register. | |
template<ModbusData D> | |
ModbusError | writeCoils (uint16_t reg, const D &data, uint16_t coilNum) |
Write data to a group of coils. | |
template<ModbusData D> | |
SlaveReturn< D > | readCoils (uint16_t reg, uint16_t coilNum) |
Read data from a group of coils. | |
template<ModbusData D> | |
SlaveReturn< D > | readInputs (uint16_t reg) |
Read data from input registers. | |
template<ModbusData D> | |
SlaveReturn< D > | readDiscreteInputs (uint16_t reg) |
Reads data from discrete inputs in a Modbus slave device. | |
Interface class for slave devices in a Modbus network.
This class provides an interface for slave devices in a Modbus network. It uses CRTP to allow the usage of generic templated virtual Methods.
This interface can be used when devices require a different Implementation for their communication from dynamic_modbus_master::slave::SlaveDevice which provides a generally good way to access a device.
T | The derived class that implements the interface |
|
virtualdefault |
|
inline |
Read data from a group of coils.
This method reads data from a group of coils starting at the specified coil address.
reg | The coil address to start reading data from |
coilNum | The number of coils to read data from |
D | The type as which the read Data will be returned, must fulfill the ModbusData concept. |
|
inline |
Reads data from discrete inputs in a Modbus slave device.
This function reads data from discrete inputs in a Modbus slave device at the specified register address. The function is templated to allow reading data of different types. The type of data to be read must fulfill the ModbusData concept. The function delegates the actual implementation to the derived class implementing the interface.
D | The type of data to be read, must fulfill the ModbusData concept |
reg | The register address to read the data from |
|
inline |
Read data from a holding register.
This method reads data from a holding register at the specified register address. The data read must be of a type that can be represented in Modbus registers, i.e., it must be at least 16-bits or the size of a single Modbus register.
reg | The register address to read the data from |
D | The type of data to be read |
|
inline |
Read data from input registers.
This method reads data from input registers at the specified register address. Input registers are read-only and contain data from the slave device.
reg | The register address to read the data from |
D | The type of data to be read from input registers, must fulfill the ModbusData concept |
|
inline |
Write data to a group of coils.
This method writes the provided data to a group of coils starting at the specified coil address.
reg | The coil address to start writing data to |
data | The data to be written to the coils |
coilNum | The number of coils to write data to |
D | The type of data to be written, must fulfill the ModbusData concept. |
|
inline |
Write data to a holding register.
This method writes the provided data to a holding register at the specified register address. The data must be of a type that can be represented in Modbus registers, i.e., it must be at least 16-bits or the size of a single Modbus register.
reg | The register address to write the data to |
data | The data to be written to the register |
D | The type of data to be written |