QModbusRequest Class
QModbusRequest is a container class containing the function code and payload that is stored inside a Modbus ADU. More...
| Header: | #include <QModbusRequest> |
| qmake: | QT += serialbus |
| Since: | Qt 5.8 |
| Inherits: | QModbusPdu |
This class was introduced in Qt 5.8.
Public Types
| (alias) | CalcFuncPtr |
Detailed Description
A Modbus request usually consists of a single byte describing the FunctionCode and N bytes of payload
A typical Modbus request can looks like this:
QModbusRequest request(QModbusRequest::WriteMultipleCoils, QByteArray::fromHex("0013000a02cd01"));
Note: When using the constructor taking the QByteArray, please make sure to convert the containing data to big-endian byte order before creating the request.
The same request can be created like this, if the values are known at compile time:
quint16 startAddress = 19, numberOfCoils = 10; quint8 payloadInBytes = 2, outputHigh = 0xcd, outputLow = 0x01; QModbusRequest request(QModbusRequest::WriteMultipleCoils, startAddress, numberOfCoils, payloadInBytes, outputHigh, outputLow);