PySide6.QtSerialBus.QModbusResponse¶
- class QModbusResponse¶
QModbusResponse
is a container class containing the function code and payload that is stored inside a Modbus ADU. More…Inherited by:
QModbusExceptionResponse
Synopsis¶
Methods¶
def
__init__()
Static functions¶
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
A typical Modbus response can looks like this:
QModbusResponse response(QModbusResponse::ReadCoils, QByteArray::fromHex("02cd01"));
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 response can be created like this, if the values are known at compile time:
quint8 payloadInBytes = 2, outputHigh = 0xcd, outputLow = 0x01; QModbusResponse response(QModbusResponse::ReadCoils, payloadInBytes, outputHigh, outputLow);
- __init__()¶
Constructs an invalid
QModbusResponse
.- __init__(pdu)
- Parameters:
pdu –
QModbusPdu
Constructs a copy of
pdu
.- __init__(code[, newData=QByteArray()])
- Parameters:
code –
FunctionCode
newData –
QByteArray
Constructs a
QModbusResponse
with function code set tocode
and payload set todata
. The data is expected to be stored in big-endian byte order already.- static calculateDataSize(pdu)¶
- Parameters:
pdu –
QModbusResponse
- Return type:
int
Calculates the expected data size for
response
, based on the response’s function code and data. Returns the full size of the response’s data part;-1
if the size could not be properly calculated.See also
minimumDataSize
registerDataSizeCalculator
- static minimumDataSize(pdu)¶
- Parameters:
pdu –
QModbusResponse
- Return type:
int
Returns the expected minimum data size for
response
based on the response’s function code;-1
if the function code is not known.