File Information
Library: IoT/Modbus/TCP
Package: TCP
Header: IoT/Modbus/TCP/TCPMasterPort.h
Description
Member Summary
Member Functions: address, changeConnectionState, decodeFrame, hasTransactionIDs, maxSimultaneousTransactions, poll, receiveFrame, reset, sendFrame
Constructors
TCPMasterPort
TCPMasterPort(
const Poco::Net::SocketAddress & serverAddress,
Poco::Timespan connectTimeout,
bool connectImmediately = true,
std::size_t maxSimultaneousTransactions = 16
);
Creates a TCPMasterPort using the given server address.
Try connect to underlying socket in constructor. If connect failed the TCPMasterPort class try reconnect at the begin of every sendFrame() and receiveFrame() function to reconnect. If this also fail an IOException is thrown.
Destructor
~TCPMasterPort
~TCPMasterPort();
Destroys the TCPMasterPort.
Try to close the underlying socket.
Member Functions
address
std::string address() const;
Returns the server address.
decodeFrame
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().
hasTransactionIDs
bool hasTransactionIDs() const;
Returns true if the port supports transaction IDs, otherwise false. Currently, only Modbus/TCP supports transaction IDs.
maxSimultaneousTransactions
std::size_t maxSimultaneousTransactions() const;
Returns the maximum number of simultaneous transactions allowed by the port.
poll
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.
reset
void reset();
Closes and re-opens the connection.
sendFrame
template < class Message > void sendFrame(
const Message & message
);
changeConnectionState
void changeConnectionState(
ConnectionState state
);
Variables
connectionStateChanged
Poco::BasicEvent < const ConnectionState > connectionStateChanged;