IoT::Modbus::TCP

class TCPDevicePort

File Information

Library: IoT/Modbus/TCP
Package: TCP
Header: IoT/Modbus/TCP/TCPDevicePort.h

Description

This class implements the Modbus TCP protocol over a socket.

Member Summary

Member Functions: address, decodeFrame, frameSlaveOrUnitAddress, isConnected, poll, receiveFrame, sendFrame

Constructors

TCPDevicePort

TCPDevicePort(
    const Poco::Net::StreamSocket & socket
);

Creates a TCPDevicePort using the given socket.

Destructor

~TCPDevicePort

~TCPDevicePort();

Destroys the TCPDevicePort.

Try to close the underlying socket.

Member Functions

address inline

std::string address() const;

Returns the client address.

decodeFrame inline

template < class Message > void decodeFrame(
    Message & message
);

Decodes the currently buffered Modbus TCP frame.

The raw frame must have been read from the wire with receiveFrame().

frameSlaveOrUnitAddress inline

Poco::UInt8 frameSlaveOrUnitAddress() const;

Returns the slave or unit address of the most recent frame received by receiveFrame().

isConnected inline

bool isConnected() const;

Returns true if the socket is connected, otherwise false.

poll inline

bool poll(
    const Poco::Timespan & timeout
);

Waits for data to arrive at the port.

Returns true immediately if data is already in the internal buffer, or if data arrives during the specified timeout interval, otherwise false.

receiveFrame

Poco::UInt8 receiveFrame();

Receives the next frame from the wire. Returns the frame's function code.

Throws an IOException if the port is not connected.

sendFrame inline

template < class Message > void sendFrame(
    const Message & message
);

Sends a Modbus TCP frame over the wire.

Throws an IOException if the port is not connected.

Securely control IoT edge devices from anywhere   Connect a Device