File Information
Library: IoT/Modbus/RTU
Package: RTU
Header: IoT/Modbus/RTU/RTUMasterPort.h
Description
Member Summary
Member Functions: address, checkFrame, decodeFrame, hasTransactionIDs, maxSimultaneousTransactions, poll, receiveFrame, reset, sendFrame
Enumerations
ByteOrder
RTU_BIG_ENDIAN = 1
Constructors
RTUMasterPort
RTUMasterPort(
Poco::SharedPtr < Poco::Serial::SerialPort > pSerialPort,
Poco::Timespan frameTimeout = 10000,
ByteOrder byteOrder = RTU_BIG_ENDIAN
);
Creates a RTUMasterPort using the given SerialPort.
The recommended value for frameTimeout is 10ms.
The SerialPort must be open and properly configured for RS-485 communication with the Modbus slaves.
Destructor
~RTUMasterPort
~RTUMasterPort();
Destroys the RTUMasterPort.
Member Functions
address
std::string address() const;
Returns the device name.
decodeFrame
template < class Message > void decodeFrame(
Message & message
);
Decodes the currently buffered Modbus RTU 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 time interval, otherwise false.
receiveFrame
Poco::UInt8 receiveFrame();
Receives the next frame from the wire. Returns the frame's function code.
reset
void reset();
Resets the connection to the bus.
sendFrame
template < class Message > void sendFrame(
const Message & message
);
checkFrame
bool checkFrame(
std::size_t size
);
Variables
connectionStateChanged
Poco::BasicEvent < const ConnectionState > connectionStateChanged;
Required by MasterPort interface, but not used for RTU.