QModbusRequest never finishes
-
Hello everyone,
I'm trying to read some holding registers from a mass flow controller over a serial (RTU) modbus connection. It works well usingpymodbusbut as i'm writing the GUI withPySide6i figured it would be nice to do the comms using Qt as well. However, when using theQModbusRtuSerialClientto send a read request theQModbusRequestjust doesn't finish, i.e.isFinished()never returns true. I'm doing this in the IPython 8.26.0 console in Spyder 5.5.5 running python 3.12.5 (i have tried in the vanilla python console as well with the same results).So the MWE looks like
from pymodbus.client import ModbusSerialClient as ModbusClient from pymodbus import FramerType mc = ModbusClient(framer = FramerType.RTU, port = '/dev/ttyUSB0', stopbits = 2, baudrate = 9600) mc.connect() rr = mc.read_holding_registers(0x002, 2, slave = 1) # rr.registers now holds the correct values mc.close()And here's what i have as a QtSerial*-version:
from PySide6.QtSerialPort import QSerialPort from PySide6.QtSerialBus import (QModbusDevice, QModbusRtuSerialClient, QModbusDataUnit) mc = QModbusRtuSerialClient() mc.setConnectionParameter(QModbusDevice.SerialPortNameParameter, '/dev/ttyUSB0') mc.setConnectionParameter(QModbusDevice.SerialParityParameter, QSerialPort.NoParity) mc.setConnectionParameter(QModbusDevice.SerialBaudRateParameter, QSerialPort.Baud9600) mc.setConnectionParameter(QModbusDevice.SerialDataBitsParameter, QSerialPort.Data8) mc.setConnectionParameter(QModbusDevice.SerialStopBitsParameter, QSerialPort.TwoStop) mbdu = QModbusDataUnit(QModbusDataUnit.HoldingRegisters, 0x0002, 2) mc.connectDevice() # mc.state() returns <State.ConnectedState: 2> mbr = mc.sendReadRequest(mbdu, 1) # mbr.isFinished() just never returns true # both mbr.error() and mc.error() returns <Error.NoError: 0>The complete lack of errors or any other indication that something is going wrong makes me think I'm messing up something basic, which seems quite likely as I have never worked with QtSerial*-stuff before. Any help or suggestions as to what I'm doing wrong would be greatly appreciated!
This is running Qt 6.7.2 on (arch linux based) cachyos with kernel version 6.10.6.