Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-62299

QModbusRtuSerialMaster throws Resource Error when resizing window

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Invalid
    • Affects Version/s: 5.9.1, 5.9.2, 5.11.1
    • Fix Version/s: 5.9.2, 6.x
    • Component/s: SerialBus: MOD Bus
    • Labels:
      None
    • Environment:
      Windows 7 x64
    • Story Points:
      13
    • Sprint:
      Qt6_Foundation_Sprint 30

      Description

      If my modbus thread is running and the QModbusRtuSerialMaster-Class is connected everything works fine until I start with resizing my MainWindow or if something changes at the USB-Port (e.g. connecting a USB-Stick). If I use my Program with QModbusTcpClient-Class everything works fine during resizing and connecting USB-Stick. The following debug-Messages are thrown with QModbusRtuSerialMaster. See Modbus-Logging below.

      In errorString of QModbusRtuSerialMaster there is the String "Resource Error"

      Sometimes the following error messages appear.

      I initialize my serial modbus interface with the following code in a class which inherits from QThread:

      void BModbus::connectSerialDevice(QString portname, qint32 baud, qint16 parity, qint16 databits, quint16 stopbits, quint8 address, float interval)
      {
          client = new QModbusRtuSerialMaster(this);
          client->setTimeout(100);
          client->setNumberOfRetries(3);
          client->setConnectionParameter(QModbusDevice::SerialPortNameParameter, portname);
          client->setConnectionParameter(QModbusDevice::SerialBaudRateParameter, baud);
          client->setConnectionParameter(QModbusDevice::SerialParityParameter, parity);
          client->setConnectionParameter(QModbusDevice::SerialDataBitsParameter, databits);
          client->setConnectionParameter(QModbusDevice::SerialStopBitsParameter, stopbits);
          modbusAddress = address;
          this->interval = interval;
          connect(client,&QModbusClient::errorOccurred,this,&BModbus::errorOccured);
          connect(client,&QModbusClient::stateChanged,this,&BModbus::stateChanged);
          connect(this,&BModbus::readRequestSignal,this,&BModbus::readRequestSlot);
          client->connectDevice();
      }
      

      the initialization of the network modbus Interface which works looks like this:

      void BModbus::connectNetworkDevice(QString ip, quint16 port, float interval)
      {
          client = new QModbusTcpClient(this);
          client->setTimeout(100);
          client->setNumberOfRetries(3);
          client->setConnectionParameter(QModbusDevice::NetworkAddressParameter, ip);
          client->setConnectionParameter(QModbusDevice::NetworkPortParameter, port);
          modbusAddress = 255;
          this->interval = interval;
          connect(client,&QModbusClient::errorOccurred,this,&BModbus::errorOccured);
          connect(client,&QModbusClient::stateChanged,this,&BModbus::stateChanged);
          connect(this,&BModbus::readRequestSignal,this,&BModbus::readRequestSlot);
          client->connectDevice();
      }
      

      The above described error also happens in release mode.

       The modbus logging prints the following

      QModbusDevice::State(ConnectingState)
      
      QStatusBar::removeWidget(): Widget not found.
      
      QModbusDevice::State(ConnectedState)
      
      Modbus-Thread running
      
      qt.modbus: (RTU client) Sent Serial PDU: 0x0300060002
      
      qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x010300060002240a
      
      qt.modbus: (RTU client) Send successful: 0x0300060002
      
      qt.modbus.lowlevel: (RTU client) Response buffer: "01030441dcab19910f"
      
      qt.modbus: (RTU client) Received ADU: "01030441dcab19910f"
      
      qt.modbus: (RTU client) Sent Serial PDU: 0x0300080002
      
      qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x01030008000245c9
      
      qt.modbus: (RTU client) Send successful: 0x0300080002
      
      qt.modbus.lowlevel: (RTU client) Response buffer: "01030441dfd1fe0225"
      
      qt.modbus: (RTU client) Received ADU: "01030441dfd1fe0225"
      
      qt.modbus: (RTU client) Sent Serial PDU: 0x03000a0002
      
      qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x0103000a0002e409
      
      qt.modbus: (RTU client) Send successful: 0x03000a0002
      
      qt.modbus.lowlevel: (RTU client) Response buffer: "01030441df4733ac10"
      
      qt.modbus: (RTU client) Received ADU: "01030441df4733ac10"
      
      qt.modbus: (RTU client) Sent Serial PDU: 0x03000c0002
      
      qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x0103000c00020408
      
      qt.modbus: (RTU client) Send successful: 0x03000c0002
      
      qt.modbus.lowlevel: (RTU client) Response buffer: "01030441dfcdb88b17"
      
      qt.modbus: (RTU client) Received ADU: "01030441dfcdb88b17"
      
      qt.modbus: (RTU client) Sent Serial PDU: 0x0300060002
      
      qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x010300060002240a
      
      qt.modbus: (RTU client) Send failed: 0x0300060002
      
      qt.modbus: (RTU server) QSerialPort error: QSerialPort::SerialPortError(ResourceError) "Der E/A-Vorgang wurde wegen eines Threadendes oder einer Anwendungsanforderung abgebrochen."
      
      QModbusDevice::State(ClosingState)
      
      QModbusDevice::State(UnconnectedState)
      
      QIODevice::write (QSerialPort): device not open
      
      qt.modbus: (RTU client) Sent Serial PDU: 0x0300060002
      
      qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x010300060002240a
      
      qt.modbus: (RTU client) Send failed: 0x0300060002
      
      qt.modbus: (RTU server) QSerialPort error: QSerialPort::SerialPortError(NotOpenError) "Device is not open"
      
      bool __cdecl QSerialPort::clear(class QFlags<enum QSerialPort::Direction>): device not open
      
      QIODevice::write (QSerialPort): device not open
      
      qt.modbus: (RTU client) Sent Serial PDU: 0x0300060002
      
      qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x010300060002240a
      
      qt.modbus: (RTU client) Send failed: 0x0300060002
      
      qt.modbus: (RTU server) QSerialPort error: QSerialPort::SerialPortError(NotOpenError) "Device is not open"
      
      bool __cdecl QSerialPort::clear(class QFlags<enum QSerialPort::Direction>): device not open
      
      QIODevice::write (QSerialPort): device not open
      
      qt.modbus: (RTU client) Sent Serial PDU: 0x0300060002
      
      qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x010300060002240a
      
      qt.modbus: (RTU client) Send failed: 0x0300060002
      
      Modbus-Error QModbusDevice::Error(TimeoutError) "Cannot open serial device."
      
      qt.modbus: (RTU server) QSerialPort error: QSerialPort::SerialPortError(NotOpenError) "Device is not open"
      
      bool __cdecl QSerialPort::clear(class QFlags<enum QSerialPort::Direction>): device not open
      
      Modbus-Thread finished
      
      Modbus-Error QModbusDevice::Error(ConnectionError) "Cannot open serial device."

       

        Attachments

        1. BugReport.zip
          9 kB
        2. BugReport64.zip
          9 kB
        3. image-2017-08-03-14-00-12-973.png
          image-2017-08-03-14-00-12-973.png
          30 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            heimrich Karsten Heimrich
            Reporter:
            mr.pfiff mr.pfiff
            PM Owner:
            Maurice Kalinowski Maurice Kalinowski
            RnD Owner:
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes