File Information
Library: IoT/Modbus/RTU
Package: RTU
Header: IoT/Modbus/RTU/RTUDevicePort.h
Description
Member Summary
Member Functions: address, checkFrame, decodeFrame, frameSlaveOrUnitAddress, isConnected, poll, receiveFrame, sendFrame
Constructors
RTUDevicePort
RTUDevicePort(
Poco::SharedPtr < Poco::Serial::SerialPort > pSerialPort,
Poco::Timespan frameTimeout = 10000
);
Creates a RTUDevicePort 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
~RTUDevicePort
~RTUDevicePort();
Destroys the RTUDevicePort.
Member Functions
address
std::string address() const;
Returns the client 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().
frameSlaveOrUnitAddress
Poco::UInt8 frameSlaveOrUnitAddress() const;
Returns the slave or unit address of the most recent frame received by receiveFrame().
isConnected
bool isConnected() const;
Always returns true.
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.
sendFrame
template < class Message > void sendFrame(
const Message & message
);
checkFrame
bool checkFrame(
std::size_t size
);