summaryrefslogtreecommitdiffstats
path: root/src/serialport/qserialport_win.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Prevent a crash if port has not been openedTomi Korpipaa2024-02-281-0/+6
| | | | | | | | | | | Also fix incorrect usage in the blocking receiver example. Fixes: QTBUG-120412 Pick-to: 6.6 6.7 Change-Id: I4c35cfc2a6f341fffae4a0db92a9a12de313bbc8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-101-40/+4
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I18aa521d1732fa721c9ad064b5d2f4d1abccd9cb Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Revert "QSerialPort: Port to alertable I/O functions on Windows"Karsten Heimrich2021-10-191-246/+115
| | | | | | | | | | This reverts commit a0faf986fccdce1d36f3308dc520cdac001f5264. Part of chain revert to go back to QWinOverlappedIoNotifier. Fixes: QTBUG-93865 Change-Id: Id4b6516282f35ccb3e81f20893872b4d1bcd3e05 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Revert "Avoid possible symbol clashes on static builds on Windows"Karsten Heimrich2021-10-191-1/+1
| | | | | | | | | | This reverts commit aa00e8eb623d5cb4ba32860dd3671a87f3763f89. Part of chain revert to go back to QWinOverlappedIoNotifier. Task-number: QTBUG-93865 Change-Id: I5456e792a22c76daf207d8c052ed14cd7976976c Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Use QList instead of QVectorJarek Kobus2020-06-251-1/+1
| | | | | | Task-number: QTBUG-84469 Change-Id: Ibe37e34aec910948ac2f5cdbcc99335c09447d5a Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Avoid possible symbol clashes on static builds on Windowsv5.14.0-beta1Denis Shienkov2019-09-251-1/+1
| | | | | | | | | | | | | We have same 'resolveSymbols' functions names in the global namespace as in the qtserialport module and as in the qtserialbus module. This can lead to the arbitrary call of this function from a different module that can lead to the crash or other issue (e.g. to this issue QTBUG-78546). So, we can just to rename this function that solves this issue in the future. Change-Id: I25f9d2a33c6858c5194d8c76eefd518eecfb6f7b Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* QSerialPort: Port to alertable I/O functions on WindowsDenis Shienkov2019-06-081-116/+248
| | | | | | | | | | | | | | | | | | | | | | This commit removes the QWinOverlappedIoNotifier in favor of alertable I/O functions like {Read|Write}FileEx(). The reason is that the QWinOverlappedIoNotifier is very complex to maintain. To use the alertable functions in the serial port we need an alertable analog of WaitCommEvent function. This function does not exist in the Win32 API, but we implement it trough a set of the system NtXXX and RtlXXX functions, which are resolved dynamically. This patch was tested with auto-tests and the examples using the: * com0com virtual serial port driver. * eltima virtual serial port driver. * pl2303 USB/serial converters. Task-number: QTBUG-74961 Change-Id: Idc428173eee7a1066a4693de00aa38416c4ee86c Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Start overlapped I/O notifier before any asynchronous operationv5.11.0-beta4Denis Shienkov2018-04-091-3/+6
| | | | | | | | | | | | | | | | | | This commit d57b9e83857253a1479f89fca18ea5856db39fb7 introduced a regression, where the QSP may ignore all the read events when the data comes to the device within opening. In this case, even re-opening of a device does not help. Reason is that the QWinOverlappedIoNotifier is enabled after than the startAsyncCommunication() called, that probably, leads to ignoring for all EV_RXCHAR events. A workaround is to enable the notifier before than any of I/O operation called. Task-number: QTBUG-67224 Change-Id: I21538fddc4dfd850c600e1d74f3c393a59a00549 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* Port QWinOverlappedIoNotifier to QDeadlineTimerThiago Macieira2017-08-151-11/+7
| | | | | Change-Id: Ib57b52598e2f452985e9fffd1459eb18587c99e3 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-071-2/+2
|\ | | | | | | | | | | | | | | Conflicts: .qmake.conf src/serialport/qserialport_win.cpp Change-Id: Icc832e218a1135cb82e780ccaa63abd990289eaf
| * QSPP::startAsyncRead(): set a correct type for variableAlex Trotsenko2017-05-041-1/+1
| | | | | | | | | | | | | | | | 'bytesToRead' takes the result of signed 64-bit computation which could be negative. So, its type should be qint64. Change-Id: Ib51129143fcb70475ad383df417ae4282c858e41 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
| * Fix possible UB in ReadFile()v5.9.0-beta4Alex Trotsenko2017-04-251-1/+1
| | | | | | | | | | | | | | | | This patch replicates commit 225ef1baeb0e49f157f3ba1271915e623bd27dd9 for Windows. Change-Id: Ic4e3444183289e7ce1a487500633fb5ad95590b9 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Use local copy of QWinOverlappedIoNotifierDenis Shienkov2017-05-171-1/+1
| | | | | | | | | | | | | | | | ... as there are plans to remove it from the QtCore. Change-Id: I79a2250b7b392896fa1c7307488a74dd44d62736 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | Improve read performance when the buffer size is limitedAlex Trotsenko2017-04-261-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Read notifications should be enabled all the time while the device is opened unless the buffer size limit is reached. To enable the read notifier again, the user needs to read the data or enlarge the buffer with a setReadBufferSize() call. According to that scenario, it's very likely that the device will toggle the state of notifier twice (on->off->on) in one notification cycle. This patch prevents this unnecessary toggling by: - unconditionally setting the notifier's state in setReadBufferSize()/ readData(); - deferring the notification disabling in readNotification() on Unix and in completeAsyncRead() on Windows to the next notification cycle. Change-Id: I97fc041bb705c034a7e73d1437e64b9b34dc2c18 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Increase buffer chunk sizesDenis Shienkov2017-04-261-3/+5
| | | | | | | | | | | | | | | | | | | | | | This reduces the number of syscalls and thus the CPU load when dealing with fast ports. And 32KiB seems still small enough to be no concern on modern hardware even if it's excessive for a given port. Change-Id: I4749e4255627d3abf2393323216e01ac6436413b Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Simplify QSPP::standardBaudRates() methodDenis Shienkov2017-04-091-72/+8
| | | | | | | | | | | | | | | | | | We do not need to use the ifdef guards for the CBR_ constants, because constants are standard and always exists in native API. Change-Id: I75ae9ffc17b132786fe5e72791b3f7c82c72c76e Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Create notifier only in end of successful initializationDenis Shienkov2017-04-091-3/+3
| | | | | | | | | | | | | | | | | | ... otherwise, this notifier's instance will be active even if the serial port is not open. Change-Id: Ieebb894a048f3ed89ac5d1c259e21bc790f5d387 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Get rid of originalEventMask memberDenis Shienkov2017-04-091-8/+6
|/ | | | | | | | | The event mask variable is used only once in process of initialization, so we do not need to keep this variable as the class member. Change-Id: I1f97a312cc92345d435dee821fefb8c2de33665e Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Do not reset RTS after changing other properties on WindowsDenis Shienkov2016-09-231-2/+11
| | | | | | | | | | | | | | | | | Changing any of serial port properties drops RTS, which has been set earlier, since the fRtsControl field of DCB structure always has RTS_CONTROL_DISABLE value (except hardware flow control). Thus, using one EscapeCommFunction() function inside of QSP::setRequestToSend() method is not enough. We need set there also the fRtsControl field to RTS_CONTROL_ENABLE(DISABLE) value and keep it unchanged. Task-number: QTBUG-55907 Change-Id: I7e407b0de9f970f5d11f61c0e360d4735a0acb84 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-011-13/+9
|\ | | | | | | | | | | | | Conflicts: src/serialport/qserialport_win.cpp Change-Id: I8f3403d448ef2e51cf2870b331c61ab808393e34
| * Detach buffer's segment for asynchronous write operationDenis Shienkov2016-07-201-13/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QRingBuffer does not guarantee that the read pointer which is returned by QRingBuffer::readPointer() will stay valid after calling QRingBuffer::reserve() or QRingBuffer::append(). Thus, we need to detach the buffer's segment and pass it to the WriteFile() function to ensure it stays unmodified for the whole time of the asynchronous operation. Change-Id: I5a42086b4339a050a4df57c39348864502be2c74 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Anton Kudryavtsev <a.kudryavtsev@netris.ru> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Start the write timer only when it is inactiveDenis Shienkov2016-07-131-1/+2
| | | | | | | | | | | | | | Change-Id: Ie6dd49bec6add204b45f15ff344ba6c92adedb0a Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Use append() instead of memcpy() where possibleDenis Shienkov2016-07-071-5/+3
| | | | | | | | | | | | | | | | | | | | ... to add the data to the internal QIODevice's buffer, that simplified the code and is more reliable. Change-Id: I61e6c7be3259cd754e4bbe6a3142dcdd6d33f7b6 Reviewed-by: Anton Kudryavtsev <a.kudryavtsev@netris.ru> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Minimize number of system calls at openingDenis Shienkov2016-07-071-68/+104
| | | | | | | | | | | | | | | | | | | | | | Currently, the method QSP::open() several times calls the system functions to get/set of DCB/termios structures for each parameter. It is not rational and should be minimized as possible, in ideally to once executed. Change-Id: If1f308176a82f3c8896fc648bf656f089e099f3f Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Replace 'Q_NULLPTR' and 'NULL' with 'nullptr'Denis Shienkov2016-06-171-9/+9
| | | | | | | | | | | | | | | | | | We can use nullptr since Qt 5.7. Change-Id: Id5354280d6a94b2c1f4c5967c65a22db878eca3e Reviewed-by: Anton Kudryavtsev <a.kudryavtsev@netris.ru> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Add some missed 'const' and 'Q_NULLPTR' keywordsDenis Shienkov2016-06-031-3/+3
| | | | | | | | | | Change-Id: Iaf06a0b3a8304ad44519f8d2187665c9f0d02aba Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | Merge 5.7 into 5.7.0Oswald Buddenhagen2016-05-201-10/+19
|\ \ | | | | | | | | | Change-Id: I2e0737fab1c12657d8dc7de5d1882ecb73bbb5f2
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-05-191-10/+19
| |\| | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: I6a4c3e446633e6f142b87c268096b1bdc1598a62
| | * Remove superfluous check during removal of the pointerDenis Shienkov2016-05-041-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | ... as deleting of a null-pointer it is a valid operation. Change-Id: Ia4ffd8b69ab75b9e3b200ce2ce999ab2820b915e Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com> Reviewed-by: André Hartmann <aha_1980@gmx.de>
| | * Fix reading of data remainder with CDC USB device on WindowsDenis Shienkov2016-04-271-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some cases the WaitCommEvent function does not triggered, even if the input driver's queue has an unread bytes. Most likely this happens if a bytes has been arrived between calls of ReadFile and WaitCommEvent. Thus, it can be avoided by means of ClearCommError function which should be called in end of ReadFile to require amount of bytes that has been arrived but still are unread. If it returns more than zero, then we start reading again, without calling of WaitCommEvent. Task-number: QTBUG-48677 Change-Id: I054975971a7c1823f7de879669c3d97f31348ed8 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | | Replace 'forever' with 'for(;;)'Denis Shienkov2016-05-201-1/+1
|/ / | | | | | | | | | | | | | | ... due to 'forever' is planned to be deprecated in Qt, and as 'for' is standard keyword. Change-Id: I05bec96d637389a22a2633e4b2bd8384ba17de10 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* / Unify license header usageAntti Kokko2016-02-021-13/+19
|/ | | | | | | | Update old header.LGPL3 to header.LGPL Change-Id: I1b17b6f798ee521d2e3bd8c37024df7cd65ee0c4 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Jani Heikkinen <jani.heikkinen@theqtcompany.com>
* Get rid of QSPP::updateCommTimeouts() methodDenis Shienkov2016-01-111-10/+3
| | | | | | | | | | This method is used only once when initializing of a device. Thus its code can be moved to an initialization place, and this method can be removed then. Change-Id: Ie9a40da1d6a2980829327f66830893ad7179bd57 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Suppress error emission when closingDenis Shienkov2016-01-111-9/+4
| | | | | | | | | | | | When the error signal is connected to a slot which calls QSP::close() and an error occurs in this method, this would lead to infinite recursion. Other Qt I/O classes avoid this problem by not emitting errors while closing the device, so we should not, either. Task-number: QTBUG-50052 Change-Id: Icfbcb19c32b8bd7fc586ab5253dc754e78829f11 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Do not use settingFromBaudRate() on Windowsv5.6.0-beta1Denis Shienkov2015-12-131-9/+0
| | | | | | | | This function makes sense only on *nix platforms. Change-Id: Ia1d107e1b0d9095f4f20e1aa472798aa0af11f0f Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Use qt_subtract_from_timeout() to reduce a code duplicationDenis Shienkov2015-10-101-3/+5
| | | | | | | | | | Commit qtbase/ed0c0070f9b05c647019270dfc42073d071c830a introduces a new helper function qt_subtract_from_timeout() which can be used to reduce a code duplication. Change-Id: I5c4941360f524225c14eac8c308fb16a546c802f Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Remove unused QSPP::baudRateFromSetting() methodDenis Shienkov2015-10-061-9/+0
| | | | | | Change-Id: Ida5f8f8b3374d52b6e20e560aff97cbdc1fe8776 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Cleanup remainders of code relating to data error policy handlingDenis Shienkov2015-09-241-63/+5
| | | | | | | | | | | | | | | | | | | It is impossible to implement all these features on all platforms, and particular drivers may not support them, too. Consequently, the user should handle such errors themselves by applying platform-specific ioctls on the device descriptor and/or parsing the stream's byte-stuffing. This commit also deprecates ParityError, FramingError, and BreakConditionError. Tested on Windows and Linux with the virtual and the USB serial ports. Change-Id: I4ffc2f067787bc304a83326acb2a2421b428f986 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Get rid of stored DCB structureDenis Shienkov2015-09-071-49/+83
| | | | | | | | | It is better to read the current DCB structure each time before changing, than to have stored it locally. Change-Id: I487931469112d657c12d99a74aa577921c042f35 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Clear the communicationStarted flag on closeDenis Shienkov2015-09-061-0/+1
| | | | | | | | | | Commit bec0b027f802d20dee00a33e9bc83d1d07b2dd42 misses cleaning of the communicationStarted flag, that breaks the data reception after reopening. Change-Id: I4aa63479b3edc5c1e0a5e51f74b66fe4df15a111 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Use the new signal/slot syntax everywherev5.6.0-alpha1Denis Shienkov2015-09-021-3/+3
| | | | | Change-Id: Ia9868d010106abbfeb8f8d24e84adf37de879991 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Unify common error strings in QSerialPortErrorInfoDenis Shienkov2015-08-281-3/+3
| | | | | | Change-Id: I1275e80988274e2409455217d5ffb03014962604 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Avoid to start of communication notifier if it already is activeDenis Shienkov2015-08-271-0/+6
| | | | | | | | | | | | This happens in the QSP::clear() method, where the WaitCommEvent() function returns with an error "The parameter is incorrect", because it calls when the waiting already is active. Tested with the virtual com0com and on-board serial ports. Change-Id: I351a336f2d3c05852a654e7bccc3ff84d7aba025 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Handle ERROR_PATH_NOT_FOUND error code on WindowsDenis Shienkov2015-08-261-0/+3
| | | | | | | | | This error occurs at attempt to open an empty device name. In this case we need to interpret it as QSerialPort::DeviceNotFoundError. Change-Id: Icdf8cd5735bcc38e6ddc2ca9c326f0f993b5cd72 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Delete the startAsyncWriteTimer object on closeDenis Shienkov2015-08-061-0/+5
| | | | | | | | | | | There are no sense to keep the startAsyncWriteTimer object when the device is closed. Because in next time the device can be opened in read-only mode, and the startAsyncWriteTimer will never used. Change-Id: I315ddfa88517087dcf708b0057a0e7c27cb1a3f1 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Delete the notifiers immediatelly on closeDenis Shienkov2015-08-061-2/+4
| | | | | | | | | | | This avoid of the errors when the triggered notifier tries to handle an already closed device descriptor. Tested on Windows and Linux with the USB serial ports. Change-Id: Iceb2e8c202b2b8d28fc87fa3a1b817df4caf39b9 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Give custom descriptions to errors which had none beforeDenis Shienkov2015-07-091-8/+6
| | | | | | Change-Id: Ic083cbd58e4e775ede0cdf610f61407003834207 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Improve the processing of errorsDenis Shienkov2015-07-081-91/+63
| | | | | | | | | | | | | | | | | | | | | | | | Sometimes the error string would contain a wrong description which did not correspond to the system error code. The reason was qt_error_string() being called too late, when the system error might have already been overwritten. The error processing is now in QSPP::getSystemError(), which returns both the error code and the error description as soon as possible. * Now the QSPP::getSystemError() returns the new class QSerialPortErrorInfo which contains all necessary fields. * The new method QSPP::setError() which accepts the QSerialPortErrorInfo as input parameter is used. * The old private method QSP::setError() is removed, because it is not used anywhere. Change-Id: Ia7e4d617b863e2131175c52812cdf426ed963795 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Fix opening of Exar VCP on WindowsDenis Shienkov2015-07-081-0/+2
| | | | | | | | | | | | | | | | The method QSPP::initialize() calls the GetCommState() function, which returns with the DCB.BaudRate field being 0. The subsequent call of SetCommState() would fail because of that. So, we need set DCB.BaudRate to any non-zero value (for example the input baud rate, which defaults to 9600) before calling the SetCommState() function. Task-number: QTBUG-46993 Change-Id: I809246b13899733f9e0bd12b3667b23c0e43b00b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Fix reading when switching from asynchronous to synchronous approachDenis Shienkov2015-07-071-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | If one wants to use the asynchronous approach (using the signals and slots), and then - the synchronous (using the waitForXX functions) then synchronous reading stalls because the waitForReadyRead() method always returns the TimeoutError code. The reason is that the signal readyRead() is emitted before the startAsyncRead() (or the startAsyncCommunication()) called inside of completeAsyncRead(). Need to emit the readyRead() only after the next asynchronous reading (the startAsyncRead() or the startAsyncCommunication()) was cocked. Now the behavior is similar to behavior of QWindowsPipeReader. Besides, the auto-test which reveals this issue is added. Tested with the virtual com0com serial ports, using the auto-tests and set of the examples. Change-Id: I64bfb871d17c179f474d6672546e532566913a7f Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Andrzej Ostruszka <andrzej.ostruszka@gmail.com>