QModbusDevice Class

The QModbusDevice class is the base class for Modbus classes, QModbusServer and QModbusClient. More...

Header: #include <QModbusDevice>
qmake: QT += serialbus
Since: Qt 5.8
Inherits: QObject
Inherited By:

QModbusClient and QModbusServer

This class was introduced in Qt 5.8.

Public Types

enum ConnectionParameter { SerialPortNameParameter, SerialParityParameter, SerialBaudRateParameter, SerialDataBitsParameter, SerialStopBitsParameter, …, UserParameter }
enum Error { NoError, ReadError, WriteError, ConnectionError, ConfigurationError, …, UnknownError }
enum State { UnconnectedState, ConnectingState, ConnectedState, ClosingState }

Detailed Description

Member Type Documentation

enum QModbusDevice::ConnectionParameter

This enum describes the possible values that can be set for a Modbus device connection.

The general purpose value (and the associated types) are:

ConstantValueDescription
QModbusDevice::SerialPortNameParameter0This parameter holds the serial port used for device communication, e.g. COM1. QString
QModbusDevice::SerialParityParameter1This parameter holds the parity checking mode. QSerialPort::Parity
QModbusDevice::SerialBaudRateParameter2This parameter holds the data baud rate for the communication. QSerialPort::BaudRate
QModbusDevice::SerialDataBitsParameter3This parameter holds the data bits in a frame. QSerialPort::DataBits
QModbusDevice::SerialStopBitsParameter4This parameter holds the number of stop bits in a frame. QSerialPort::StopBits
QModbusDevice::NetworkPortParameter5This parameter holds the network port. int
QModbusDevice::NetworkAddressParameter6This parameter holds the host address for network communication. QString

User options:

ConstantValueDescription
QModbusDevice::UserParameter0x100This enum value has been deprecated. There will be no replacement.

enum QModbusDevice::Error

This enum describes all the possible error conditions.

ConstantValueDescription
QModbusDevice::NoError0No errors have occurred.
QModbusDevice::ReadError1An error occurred during a read operation.
QModbusDevice::WriteError2An error occurred during a write operation.
QModbusDevice::ConnectionError3An error occurred when attempting to open the backend.
QModbusDevice::ConfigurationError4An error occurred when attempting to set a configuration parameter.
QModbusDevice::TimeoutError5A timeout occurred during I/O. An I/O operation did not finish within a given time frame.
QModbusDevice::ProtocolError6A Modbus specific protocol error occurred.
QModbusDevice::ReplyAbortedError7The reply was aborted due to a disconnection of the device.
QModbusDevice::UnknownError8An unknown error occurred.

Note: An UnknownError can also indicate that the received FunctionCode is not supported in the current implementation. In this case custom Modbus client implementations need to override the processResponse() and processPrivateResponse() methods to provide support for needed functions.

enum QModbusDevice::State

This enum describes all possible device states.

ConstantValueDescription
QModbusDevice::UnconnectedState0The device is disconnected.
QModbusDevice::ConnectingState1The device is being connected.
QModbusDevice::ConnectedState2The device is connected to the Modbus network.
QModbusDevice::ClosingState3The device is being closed.