UART issue on iMX6 with WEC2013?

Hi,

We are using a SerialPort (COM3) for communication and everything works fine

but :wink:

after a couple of ms the port reports a wirte error. The wirte-operation returns w/o error
and the reported amount of bytes written is correct. Some milliseconds later the error signal arrives
and reports the write error. Somtimes it is 4ms, sometimes 150ms.

Sample Code is basically the QSerialPort asynch example.
Com-Port settings are: 115200, 8, n, 1

Any help is greatly appreciated.

You say that you get a write error, but the function returns no error and number of bytes written is correct. How do you detect the error? Does this happen only on UART3? This UART has no flow control signals enabled by default, are you enabling any kind of flow control on the port?

Hi Valter.Tx,
To detect the error I have the QSerialPort::error() signal connected.
This error is not specific to UART3, happens also on UART2. FlowControl is
disabled.

Maybe it’s a problem of the qt5.6 QSerialPort implementation.
The WINCE implementation of QSerialPortPrivate::notifyWrite()
(qserialport_wince.cpp:498) does NOT checked, if the writebuffer is empty, while the
the win32 implementation dose so (qserialport_win.cpp:429). My guess is, that the
following ::WriteFile function of windows would return that error on an empty writebuffer.
Right now, my debug capabilities in that area are quite limited to verify this hypothesis.
… but I can be wrong.

In qt5.7 the WINCE implementation is dropped completely and only the win-implementation is available.

Are you doing 0-length writes when the issue is reported?
Or I misunderstood your explanation?

no. My assumption is, that qt is checking, if there are still something to write, if run in asynch-mode.

I don’t know the Qt implementation in detail, can you point me to some src repo where I should check this?
CE does not support async I/O up to CE7, in CE7 it’s supported, but drivers must support it and our serial driver (based on MS reference implementation) don’t do that.
Did you experience the same issue also on other modules? (just to understand if it may be BSP-related)?
Sorry if I reply with more questions than answers, but I need to understand the issue a bit better.

Hi Valter,

sorry, took me while to compile and install qt onto the device but it is ineed a problem of qt 5.6 for WINCE. If the writeBuffer of the serialport is empty, it still
tries to transfer 0-length data. The windows WriteFile function does return false
in this case and causes a write error. The fix below is not well tested (e.g. large amount of data is not tested) but it works for me.

File:
Qt\5.6.2\qtserialport\src\serialport\qserialport_wince.cpp
diff -u qserialport_wince.cpp_bad qserialport_wince.cpp
— qserialport_wince.cpp_bad 2016-12-22 10:18:51.781714500 +0100
+++ 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();

Hi Valter,

I suggested the fix to QT and it was accepted for the qt5.6.3 release.
see: [QTBUG-57783] QSerialPort WINCE causes WriteError on WindowsCompact 2013 - Qt Bug Tracker

Great news, thank you for sharing.