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

ResourceError does not fire on unplug for QtSerialPort 6.8.2

XMLWordPrintable

    • Linux/Wayland, Linux/X11
    • 5
    • a9206ddef (dev), ea44c1500 (6.10), 8a73f0ed8 (6.9), b46e6c245 (tqtc/lts-6.8), c674ab2e8 (tqtc/lts-6.5)
    • Foundation Sprint 134, Foundation Sprint 135

      I have code that has 3 errorOccurred handlers attached.

       
      private slots:     // Slots for handling events     
      void handleUnitSerialError(QSerialPort::SerialPortError error);     
      void handleReferenceSerialError(QSerialPort::SerialPortError error);     
      void handleChilledMirrorSerialError(QSerialPort::SerialPortError error);
      
      
      
      QSerialPort *unitSerial;
      QSerialPort *referenceSerial;
      QSerialPort *chilledMirrorSerial;
      
      
      Serial::Serial(QObject *parent)
          : QObject(parent),
          unitSerial(new QSerialPort(this)),
          referenceSerial(new QSerialPort(this)),
          chilledMirrorSerial(new QSerialPort(this)),
          referenceCommandTimer(new QTimer(this)),
          chilledMirrorCommandTimer(new QTimer(this)), m_pauseLog(false)
      {
          // Connect readyRead signals
          connect(unitSerial, &QSerialPort::readyRead, this, &Serial::readUnitData);
          connect(referenceSerial, &QSerialPort::readyRead, this, &Serial::readReferenceData);
          // Connect individual errorOccurred signals to specific slots
          connect(unitSerial, &QSerialPort::errorOccurred, this, &Serial::handleUnitSerialError);
          connect(referenceSerial, &QSerialPort::errorOccurred, this, &Serial::handleReferenceSerialError);
          connect(chilledMirrorSerial, &QSerialPort::errorOccurred, this, &Serial::handleChilledMirrorSerialError);
      
      
      
      
      void Serial::handleUnitSerialError(QSerialPort::SerialPortError error)
      {
          qDebug() << "handleUnitSerialError triggered with error:" << error;
          if (error == QSerialPort::NoError)
              return;
          if (error == QSerialPort::ResourceError) {
              qDebug() << "Critical resource error. Closing unit serial port.";
              closeUnitSerialPort();
          }
      }
      void Serial::handleReferenceSerialError(QSerialPort::SerialPortError error)
      {
          qDebug() << "ReferenceSerialError triggered with error:" << error;
          if (error == QSerialPort::NoError)
              return;
          if (error == QSerialPort::ResourceError) {
              qDebug() << "Critical resource error. Closing reference serial port.";
              closeReferenceSerialPort();
          }
      }
      void Serial::handleChilledMirrorSerialError(QSerialPort::SerialPortError error)
      {
          if (error == QSerialPort::NoError)
              return;
          if (error == QSerialPort::ResourceError) {
              qDebug() << "Critical resource error. Closing chilled mirror serial port.";
              closeChilledMirrorSerialPort();
          }
          // Add additional handling specific to chilledMirrorSerial if necessary
      }
      
      
      
      

      For whatever reason, I am able to get ResourceError fired when I unplug both the chilledMirror and reference serial ports. But I cannot get unitSerial to fire ResourceError when I unplug the USB from the computer.

      This code started working when I upgraded to 6.8.2 from 6.8.1. I noticed that there are bug fixes for QtSerialPort in the release notes that helped implement this fix automatically when I upgraded.

      I am not sure how to debug this. The engine will not give me ResourceError for unit for whatever reason.

        1. qtbug133489.zip
          2.69 MB
          Irfan Omair
        For Gerrit Dashboard: QTBUG-133489
        # Subject Branch Project Status CR V

            ivan.solovev Ivan Solovev
            whitleystriber Whitley Striber
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There is 1 open Gerrit change