QModbusPdu#
QModbusPdu
is a abstract container class containing the function code and payload that is stored inside a Modbus ADU. More…
Inherited by: QModbusRequest
Synopsis#
Functions#
def
data
()def
dataSize
()def
exceptionCode
()def
functionCode
()def
isException
()def
isValid
()def
setData
(newData)def
size
()
Virtual functions#
def
setFunctionCode
(code)
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#
The class provides access to the raw Modbus protocol packets as defined by the Modbus Application Protocol Specification 1.1b.
- class PySide6.QtSerialBus.QModbusPdu#
PySide6.QtSerialBus.QModbusPdu(code, newData)
PySide6.QtSerialBus.QModbusPdu(arg__1)
- Parameters:
arg__1 –
PySide6.QtSerialBus.QModbusPdu
newData –
PySide6.QtCore.QByteArray
code –
FunctionCode
Constructs an invalid QModbusPdu
.
Constructs a QModbusPdu
with function code set to code
and payload set to data
. The data is expected to be stored in big-endian byte order already.
Constructs a QModbusPdu
that is a copy of other
.
- PySide6.QtSerialBus.QModbusPdu.ExceptionCode#
This enum describes all the possible error conditions as defined by Modbus Exception Codes. They are set by the server after checking the appropriate error conditions in the reply to a request and must be decoded by the client to operate on the exception code.
Constant
Description
QModbusPdu.IllegalFunction
Function code is not supported by device.
QModbusPdu.IllegalDataAddress
The received data address in the query is not an allowable address for the Modbus server.
QModbusPdu.IllegalDataValue
The contained value in the request data field is not an allowable value for the Modbus server.
QModbusPdu.ServerDeviceFailure
An irrecoverable error occurred while the server was attempting to perform the requested action.
QModbusPdu.Acknowledge
Specialized use in conjunction with programming commands.
QModbusPdu.ServerDeviceBusy
The server is engaged in processing a long duration program command.
QModbusPdu.NegativeAcknowledge
The server cannot perform the program function received in the query. This code is returned for an unsuccessful programming request. The client should request diagnostic or error information from the server.
QModbusPdu.MemoryParityError
Indicates that the extended file area failed to pass a consistency check. Used in conjunction with function codes 20 and 21. The exception code does not refer to any parity settings of the transmission line but only to the servers’ internal memory of file records.
QModbusPdu.GatewayPathUnavailable
Indicates that the gateway was unable to allocate an internal communication path from the input port to the output port for processing the request.
QModbusPdu.GatewayTargetDeviceFailedToRespond
Indicates that no response was obtained from the target device behind a gateway. Usually this means the target device is not online on the network.
QModbusPdu.ExtendedException
This is an extended exception as per Modbus specification. Generally this code is used to describe an exception that is otherwise further described.
- PySide6.QtSerialBus.QModbusPdu.FunctionCode#
Defines the function code and the implicit type of action required by the server. Not all Modbus devices can handle the same set of function codes.
Constant
Description
QModbusPdu.Invalid
Set by the default constructor, do not use.
QModbusPdu.ReadCoils
Requests the status of one or more coils from a device.
QModbusPdu.ReadDiscreteInputs
Requests the status of one or more input registers from a device.
QModbusPdu.ReadHoldingRegisters
Requests the status of one or more holding register values from a device.
QModbusPdu.ReadInputRegisters
Requests the status of one or more input register values from a device.
QModbusPdu.WriteSingleCoil
Requests to write a single coil on a device.
QModbusPdu.WriteSingleRegister
Requests to write a single holding register on a device.
QModbusPdu.ReadExceptionStatus
Requests the status of the eight Exception Status outputs on a device.
QModbusPdu.Diagnostics
Used to provide a series of tests for checking the client server communication system, or checking internal
QModbusPdu.GetCommEventCounter
Requests a status word and an event count from the device’s communication event counter.
QModbusPdu.GetCommEventLog
Requests a status word, event count, message count, and a field of event bytes from a device.
QModbusPdu.WriteMultipleCoils
Requests to write one or more coils on a device.
QModbusPdu.WriteMultipleRegisters
Requests to write one or more holding registers on a device.
QModbusPdu.ReportServerId
Requests the description of the type, the current status, and other information specific to a device.
QModbusPdu.ReadFileRecord
Requests a file record read.
QModbusPdu.WriteFileRecord
Requests a file record write.
QModbusPdu.MaskWriteRegister
Requests to modify the contents of a specified holding register using a combination of an AND or OR mask, and the register’s current contents.
QModbusPdu.ReadWriteMultipleRegisters
Requests the status of one or more holding register and at the same time to write one or more holding registers on a device.
QModbusPdu.ReadFifoQueue
Requests to read the contents of a First-In-First-Out (FIFO) queue of register in a remote device.
QModbusPdu.EncapsulatedInterfaceTransport
Please refer to Annex A of the Modbus specification.
QModbusPdu.UndefinedFunctionCode
Do not use.
- PySide6.QtSerialBus.QModbusPdu.data()#
- Return type:
Returns the PDU’s payload, excluding the function code. The payload is stored in big-endian byte order.
See also
- PySide6.QtSerialBus.QModbusPdu.dataSize()#
- Return type:
int
Returns the PDU’s data size, excluding the function code.
- PySide6.QtSerialBus.QModbusPdu.exceptionCode()#
- Return type:
Returns the response’s exception code.
- PySide6.QtSerialBus.QModbusPdu.functionCode()#
- Return type:
Returns the PDU’s function code.
See also
- PySide6.QtSerialBus.QModbusPdu.isException()#
- Return type:
bool
Returns true if the PDU contains an exception code; otherwise false.
- PySide6.QtSerialBus.QModbusPdu.isValid()#
- Return type:
bool
Returns true if the PDU is valid; otherwise false.
A PDU is considered valid if the message code is in the range of 1 to 255 decimal and the PDU’s compound size (function code + data) does not exceed 253 bytes. A default constructed PDU is invalid.
- PySide6.QtSerialBus.QModbusPdu.setData(newData)#
- Parameters:
newData –
PySide6.QtCore.QByteArray
Sets the PDU’s function payload to data
. The data is expected to be stored in big-endian byte order already.
See also
- PySide6.QtSerialBus.QModbusPdu.setFunctionCode(code)#
- Parameters:
code –
FunctionCode
Sets the PDU’s function code to code
.
See also
- PySide6.QtSerialBus.QModbusPdu.size()#
- Return type:
int
Returns the PDU’s full size, including function code and data size.