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

QSerialPort doesn't fully read from a serial port in windows 10

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.6.1
    • 5.5.0
    • Serial Port
    • None
    • Windows 10

    Description

      After some extensive debugging with an inline USB protocol debugger and various windows serial port debugging tools, I've come to the conclusion that somewhere within the depths of Windows 10's serial stack (which was helpfully rewritten for windows 10), ReadFile and WaitCommEvent aren't working right.

      Whats happening is:

      • WaitCommEvent will eventually cause QSerialPortPrivate::startAsyncRead() to be called, which starts a ReadFile overlapped operation.
      • This ReadFile operation will claim to read all of the bytes that are available as reported by WaitCommEvent's overlapped operation completing. Even polling the driver's buffer via ClearCommError() says that all of the bytes were read.
      • WaitCommEvent is called again, which appears to kick around some windows internals and makes a few more bytes appear on the line, but no notification is sent about it. QSerialPortPrivate will sit around waiting for the QWinOverlappedIoNotifier to trigger, but windows never notifies it.
      • Checking the bytes available in the buffer after that second WaitCommEvent reports that another number of bytes are available. Another call to ReadFile is needed to fully read all the data.

      Unless I'm mistaken about how Windows is handling things, the attached patch is a workaround for this bug.

      Attachments

        Issue Links

          Activity

            People

              kuzulis Denis Shienkov
              tdfischer Torrie Fischer
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: