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

ResourceError does not fire on unplug for QtSerialPort 6.8.2

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.8.2
    • Serial Port
    • Arch Linux Latest.
    • Linux/Wayland
    • Foundation PM Staging

    Description

      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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes