QSerialPort from version 5.13.1 of the Qt library does not physically output data under Windows 7 and 10.
In order t
Searching Qt bug tracker there seem to be multiple bugs about QSerialPort not working on Qt 5.13.1 on Windows. All of them are duplicated with QTBUG-78086 which also contains a link to Gerrit review of the fix.
From the bug description:
The signal readyRead is never emitted, even if data is sent to the serial port from a connected device. The member bytesAvailable returns 0 even if data has been sent to the serial port from a connected device.
Basically, they have tried to emit _q_notify in qwinoverlappedionotifier.cpp only if there's no notification pending. Unfortunatelly
That commit completely breaks the I/O on Windows.
For now you have the options to downgrade to 5.13.0, wait for Qt 5.13.2 or
Fix the Qt 5.13.1 qserialport yourself:
QTDIR\5.13.1\Src\qtserialport\qtserialport.pro with QtCreatorProjects -> Manage kits -> Desktop Qt 5.13.1 MSVC2017 64bitsrc/serialport/serialport-lib/sources/qwinoverlappedionotifier.cppQAtomicInt pendingNotifications;change
if (!waiting && pendingNotifications-- == 0)
emit q->_q_notify();
to
if (!waiting)
emit q->_q_notify();
change
int n = pendingNotifications.fetchAndStoreAcquire(0);
while (--n >= 0) {
if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0)
dispatchNextIoResult();
}
to
if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0)
dispatchNextIoResult();
In QtCreator go to build -> clean all, then run qmake, then rebuild all
Qt5SerialPort.dll and Qt5SerialPortd.dll from build\bin to QTDIR\5.13.1\msvc2017_64\binYour code should work now.