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: |
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:
| Constant | Value | Description |
|---|---|---|
QModbusDevice::SerialPortNameParameter | 0 | This parameter holds the serial port used for device communication, e.g. COM1. QString |
QModbusDevice::SerialParityParameter | 1 | This parameter holds the parity checking mode. QSerialPort::Parity |
QModbusDevice::SerialBaudRateParameter | 2 | This parameter holds the data baud rate for the communication. QSerialPort::BaudRate |
QModbusDevice::SerialDataBitsParameter | 3 | This parameter holds the data bits in a frame. QSerialPort::DataBits |
QModbusDevice::SerialStopBitsParameter | 4 | This parameter holds the number of stop bits in a frame. QSerialPort::StopBits |
QModbusDevice::NetworkPortParameter | 5 | This parameter holds the network port. int |
QModbusDevice::NetworkAddressParameter | 6 | This parameter holds the host address for network communication. QString |
User options:
| Constant | Value | Description |
|---|---|---|
QModbusDevice::UserParameter | 0x100 | This enum value has been deprecated. There will be no replacement. |
enum QModbusDevice::Error
This enum describes all the possible error conditions.
| Constant | Value | Description |
|---|---|---|
QModbusDevice::NoError | 0 | No errors have occurred. |
QModbusDevice::ReadError | 1 | An error occurred during a read operation. |
QModbusDevice::WriteError | 2 | An error occurred during a write operation. |
QModbusDevice::ConnectionError | 3 | An error occurred when attempting to open the backend. |
QModbusDevice::ConfigurationError | 4 | An error occurred when attempting to set a configuration parameter. |
QModbusDevice::TimeoutError | 5 | A timeout occurred during I/O. An I/O operation did not finish within a given time frame. |
QModbusDevice::ProtocolError | 6 | A Modbus specific protocol error occurred. |
QModbusDevice::ReplyAbortedError | 7 | The reply was aborted due to a disconnection of the device. |
QModbusDevice::UnknownError | 8 | An 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.
| Constant | Value | Description |
|---|---|---|
QModbusDevice::UnconnectedState | 0 | The device is disconnected. |
QModbusDevice::ConnectingState | 1 | The device is being connected. |
QModbusDevice::ConnectedState | 2 | The device is connected to the Modbus network. |
QModbusDevice::ClosingState | 3 | The device is being closed. |