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

QSerialPort WINCE causes WriteError on WindowsCompact 2013

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.6.3
    • 5.6.2
    • Serial Port
    • None
    • Toradex Colibri IMX6
      Windows Embedded Compact 2013 (BSP: Toradex V1.1b4)
      VisualStudio 2015

      Symptom: Using QSerialPort in asynch mode (Asynch-Example from QT) on an embedded device running Windows Compact 2013 OS.
      After successfully sending a msg using QSerialPort:::write(QByteArray) function, a QSerialPort::error() signal is received with error QSerialPort::WriteError a couple of milliseconds later. Same happens on QSerialPort::flush() function.

      Problem: Apparently the windows WriteFile function returns false for 0-length data on Windows Compact 2013 systems

      Solution: bool QSerialPortPrivate::notifyWrite() (qtserialport_wince.cpp) does not check for empty writebuffer (the win implementation does so, see qtserialport_win.cpp).

      Patch:

      +++ qserialport_wince.cpp	2016-12-21 17:20:33.285213800 +0100
      @@ -499,6 +499,9 @@
       {
           Q_Q(QSerialPort);
       
      +	if (writeBuffer.isEmpty()) {
      +		return true; 
      +	}
           int nextSize = writeBuffer.nextDataBlockSize();
       
           const char *ptr = writeBuffer.readPointer();
      

      Drawback: The patch fixes the issue. But since debugging is not possible on the device, the source of the issue can be somewhere else. And the fix is not well tested (e.g not tested for large data, not tested for other OS)

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

            kuzulis Denis Shienkov
            thomas_a Thomas Achmann
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes