Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QModbusRequest never finishes
Forum Updated to NodeBB v4.3 + New Features

QModbusRequest never finishes

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 202 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ragnar_no
    wrote on last edited by
    #1

    Hello everyone,
    I'm trying to read some holding registers from a mass flow controller over a serial (RTU) modbus connection. It works well using pymodbus but as i'm writing the GUI with PySide6 i figured it would be nice to do the comms using Qt as well. However, when using the QModbusRtuSerialClient to send a read request the QModbusRequest just 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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved