IoT::Modbus::Device

class ModbusDeviceHandler

File Information

Library: IoT/Modbus/Device
Package: Device
Header: IoT/Modbus/Device/ModbusDeviceHandler.h

Description

This class defines the interface for Modbus devices.

The interface is used for both RTU and TCP connections.

For every defined function code there is a corresponding handler method. In case of an unknown function code, a generic otherFunction() method is provided.

The response object is pre-initialized with the correct function code, device address and transaction ID, so the handler method only needs to fill in the message-specific information.

A handler method can return an exception message by throwing a ModbusException with an appropriate function and exception code.

Inheritance

Known Derived Classes: AbstractModbusDeviceHandler

Member Summary

Member Functions: idle, maskWriteRegister, otherFunction, readCoils, readDiscreteInputs, readExceptionStatus, readFIFOQueue, readHoldingRegisters, readInputRegisters, readWriteMultipleRegisters, writeMultipleCoils, writeMultipleRegisters, writeSingleCoil, writeSingleRegister

Constructors

ModbusDeviceHandler

ModbusDeviceHandler();

Creates a ModbusDeviceHandler.

Destructor

~ModbusDeviceHandler virtual

virtual ~ModbusDeviceHandler();

Destroys the ModbusDeviceHandler.

Member Functions

idle virtual

virtual bool idle(
    Poco::Timespan idleTime
) = 0;

Called repeatedly when no other request is there to handle.

If the method returns false, the Modbus connection will be closed.

maskWriteRegister virtual

virtual void maskWriteRegister(
    const MaskWriteRegisterRequest & request,
    MaskWriteRegisterResponse & response
) = 0;

Handles a Mask Write Register request.

otherFunction virtual

virtual void otherFunction(
    const GenericMessage & request,
    GenericMessage & response
) = 0;

Handles any function code not covered by the other handler methods.

readCoils virtual

virtual void readCoils(
    const ReadCoilsRequest & request,
    ReadCoilsResponse & response
) = 0;

Handles a Read Coils request.

readDiscreteInputs virtual

virtual void readDiscreteInputs(
    const ReadDiscreteInputsRequest & request,
    ReadDiscreteInputsResponse & response
) = 0;

Handles a Read Discrete Inputs request.

readExceptionStatus virtual

virtual void readExceptionStatus(
    const ReadExceptionStatusRequest & request,
    ReadExceptionStatusResponse & response
) = 0;

Handles a Read Exception Status request.

readFIFOQueue virtual

virtual void readFIFOQueue(
    const ReadFIFOQueueRequest & request,
    ReadFIFOQueueResponse & response
) = 0;

Handles a Read FIFO Queue request.

readHoldingRegisters virtual

virtual void readHoldingRegisters(
    const ReadHoldingRegistersRequest & request,
    ReadHoldingRegistersResponse & response
) = 0;

Handles a Read Holding Registers request.

readInputRegisters virtual

virtual void readInputRegisters(
    const ReadInputRegistersRequest & request,
    ReadInputRegistersResponse & response
) = 0;

Handles a Read Input Registers request.

readWriteMultipleRegisters virtual

virtual void readWriteMultipleRegisters(
    const ReadWriteMultipleRegistersRequest & request,
    ReadWriteMultipleRegistersResponse & response
) = 0;

Handles a Read Write Multiple Registers request.

writeMultipleCoils virtual

virtual void writeMultipleCoils(
    const WriteMultipleCoilsRequest & request,
    WriteMultipleCoilsResponse & response
) = 0;

Handles a Write Multiple Coils request.

writeMultipleRegisters virtual

virtual void writeMultipleRegisters(
    const WriteMultipleRegistersRequest & request,
    WriteMultipleRegistersResponse & response
) = 0;

Handles a Write Multiple Registers request.

writeSingleCoil virtual

virtual void writeSingleCoil(
    const WriteSingleCoilRequest & request,
    WriteSingleCoilResponse & response
) = 0;

Handles a Write Single Coil request.

writeSingleRegister virtual

virtual void writeSingleRegister(
    const WriteSingleRegisterRequest & request,
    WriteSingleRegisterResponse & response
) = 0;

Handles a Write Single Register request.

Securely control IoT edge devices from anywhere   Connect a Device