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

No emitted readyRead() if dataErrorPolicy != QSerialPort::IgnorePolicy and data present in system

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.1.0
    • Serial Port
    • None
    • Qt: 5.1.0 MinGW
      OS: Windows XP SP3

    Description

       
      Initialization:
      
      ...
      QSerialPort     sport;
      connect(&sport, SIGNAL(readyRead()), this, SLOT(portReadyRead()));
      connect(&sport, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(portError(QSerialPort::SerialPortError)));
      
      cfg_portname = "COM1";
      cfg_baudrete = QSerialPort::Baud9600;
      cfg_databits = QSerialPort::Data8;
      cfg_parity = QSerialPort::NoParity;
      cfg_stopbits = QSerialPort::OneStop;
      cfg_errorpolicy = QSerialPort::SkipPolicy; // <--
      cfg_flowcontrol = QSerialPort::NoFlowControl;
      
      sport.setPortName(cfg_portname);
      sport.open(QIODevice::ReadWrite);
      sport.setBaudRate(cfg_baudrete);
      sport.setDataBits(cfg_databits);
      sport.setParity(cfg_parity);
      sport.setStopBits(cfg_stopbits);
      sport.setDataErrorPolicy(cfg_errorpolicy);
      sport.setFlowControl(cfg_flowcontrol);
      ...
      
      SLOT:
      void MbSerialPort::portReadyRead()
      {
          //data_recv.append(sport.readAll());
          
          while (!sport.atEnd())
              data_recv.append(sport.read(100));
          emit devRecvPacket(data_recv);
          qDebug() << "INFO: MbSerialPort::portReadyRead() RECV: " << data_recv.toHex();    
          qDebug() << "INFO: error = " << sport.error() << " " << sport.errorString();
      
      }
      
      

      If set setDataErrorPolicy(QSerialPort::SkipPolicy) only one byte accesible to read and no reemmited readyRead().

      ( Next byte of first packet can be read when second packet receiving (or any activity on Rx-line )

      I belive this is related with:

      qserialport_win.cpp: /line 630/
      
      bool QSerialPortPrivate::startAsyncRead()
      {
          DWORD bytesToRead = policy == QSerialPort::IgnorePolicy ? ReadChunkSize : 1;
          ...
      }
      

      And no attemts to read next bytes before system event.
      No system events before activity on RxD.

      And bytesAvailable() returns 0 too.

      Attachments

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

        Activity

          People

            lpapp Laszlo Papp
            solorunight Stanislav Novikov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes