summaryrefslogtreecommitdiff
path: root/src/serialport/qserialport.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-10-301-2/+2
|\ | | | | | | | | | | | | | | Conflicts: .qmake.conf examples/serialport/blockingmaster/masterthread.cpp Change-Id: I3716089bae99247f98ed02656d4418de5f866c1d
| * Update waitFor{ReadyRead|BytesWritten} documentation for timeoutsAndre Hartmann2017-09-291-2/+2
| | | | | | | | | | | | | | | | | | [ChangeLog][QSerialPort] Added a note to the documentation that waitForReadyRead() and waitForBytesWritten() never time out if the parameter msecs is -1. Change-Id: I5852da14faf1bba5a338db6a8764da582238aae7 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Use C++11 member class initializationDenis Shienkov2017-10-121-31/+1
| | | | | | | | | | | | Change-Id: I427b993a3a71f199029a8956cdf0dc2c98f0e444 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: André Hartmann <aha_1980@gmx.de>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-071-2/+9
|\ \ | |/ | | | | | | | | | | | | Conflicts: .qmake.conf src/serialport/qserialport_win.cpp Change-Id: Icc832e218a1135cb82e780ccaa63abd990289eaf
| * Fix bytesToWrite()Alex Trotsenko2017-04-221-2/+5
| | | | | | | | | | | | | | | | | | We should not add the size of the internal write buffer here because QIODevice::bytesToWrite() already checks it. Also, take into account the size of 'writeChunkBuffer' on Windows. Change-Id: I87dfcb4dd1cd9d2bbb6f82a084d79fb4db9323d8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Doc: Describe limitations to use of QSP::setRequestToSend()5.8Denis Shienkov2017-03-061-0/+4
| | | | | | | | | | | | | | | | The limitations were introduced by the commit 56c001b, but were not documented. Change-Id: I5e44ab78e2e5cce2477ebc1f83280fa8c22e0ef6 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* | Improve read performance when the buffer size is limitedAlex Trotsenko2017-04-261-18/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+3
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Get rid of originalEventMask memberDenis Shienkov2017-04-091-1/+0
|/ | | | | | | | | 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>
* Improve documentation a bitDenis Shienkov2017-01-041-41/+41
| | | | | | | | ... where has been added the '\c' tag where it is required. Change-Id: Ie346fc147deb535501eb365693a2ff5fe22a98f9 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* qserialport.cpp: Silence deprecation warningFriedemann Kleint2016-12-081-0/+5
| | | | | | | | | qserialport.cpp: In member function 'void QSerialPort::setSettingsRestoredOnClose(bool)': qserialport.cpp:627:9: warning: 'void QSerialPort::settingsRestoredOnCloseChanged(bool)' is deprecated [-Wdeprecated-declarations] Change-Id: I4ed17403cd1692c4f965a69be711f0c5b03a8376 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-09-191-1/+15
|\ | | | | | | Change-Id: I4f2c44fa70f4f0905daf22c619c597a4a1972c85
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-09-171-1/+15
| |\ | | | | | | | | | Change-Id: I3c5b0052f5645ead630e33bce46b360fa0135061
| | * Add mention of QSP::waitForX() functions in documentationDenis Shienkov2016-08-051-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | ... otherwise the snippet with the blocking reading does not make sense logically. Change-Id: I5a037e7c44f50e57a1c48ab37764f9e7367a6dec Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | | Replace QSP::error signal with QSP::errorOccurredDenis Shienkov2016-08-091-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make the name of the signal and the name of the getter unambiguous, which in turn allows the easy use of Qt 5-style connects. This commit message was taken from commit qtbase/4672e31. [ChangeLog][QtSerialPort][QSerialPort] Deprecated QSP::error() signal in favor of new QSP::errorOccurred() one. Change-Id: I3f04bb8b1ae686d5368d43741cd0e97748b31b8f Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-08-021-21/+4
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/serialport/qserialport.cpp Change-Id: I858fec6e426f5fd867b7eda7b1db69a2d447b357
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-011-8/+1
| |\ \ | | |/ | | | | | | | | | | | | | | | Conflicts: src/serialport/qserialport_win.cpp Change-Id: I8f3403d448ef2e51cf2870b331c61ab808393e34
| | * Detach buffer's segment for asynchronous write operationDenis Shienkov2016-07-201-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | Remove mention of Windows CE supportDenis Shienkov2016-07-151-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | As Windows CE support has been stopped since Qt 5.7. Change-Id: I850c5e1e41508502a9e82491f89488facca40f51 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-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Add missng default parameters to waitFor() methodsDenis Shienkov2016-07-281-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... and adjust their documentation a bit. [ChangeLog][QtSerialPort][QSerialPort] Added missing parameters for waitFor() methods Change-Id: I95d7076bfef47dd75d37960ca8a719ae779737d6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Reuse QIODevice's write bufferAlex Trotsenko2016-07-191-5/+2
|/ / | | | | | | | | | | Change-Id: Ieda6cd8452391a1fd3276a35c9854cf764dbb679 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.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>
* | Drop the Win CE supportDenis Shienkov2016-05-021-4/+1
| | | | | | | | | | | | | | | | | | | | | | Now we can drop the WinCE (5/6) support, because its compilers do not support the C++11 features, that lead to the further API limitations and so on. Change-Id: I2431d15b1361f1e093fc09ff7fbe824daeac3984 Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-03-071-0/+5
|\ \ | |/ | | | | Change-Id: I35f19a7d266f90e957bfe01534a40c4d98b40b34
| * Forbid the RTS changing when the HardwareFlowControl was setDenis Shienkov2016-02-251-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | It is an error when the RTS changes manually when the HardwareFlowControl is set. In this case the driver operates with the RTS automatically, so manual control is not allowed. But some drivers ignore this requirement and do not return errors in attempt of manual RTS control. Thus, we have to forbid change of RTS and to return the UnsupportedOperationError error. Change-Id: I80bc87d51d9c653ed15ec310fca654243821b1e7 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.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>
* | Merge remote-tracking branch 'origin/5.6' into devLiang Qi2016-01-261-2/+2
|\ \ | |/ | | | | Change-Id: Idc590cb4d891d7701cc443be80275c4d9ccfa5a6
| * Doc: corrected issue QSerialPort baud rateNico Vertriest2015-12-031-2/+2
| | | | | | | | | | | | Task-number: QTBUG-44994 Change-Id: Id14aaa87bc648e9b775594749eaa2d6a1defdf73 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | QSerialPort::atEnd(): remove code duplicationAlex Trotsenko2016-01-211-2/+1
|/ | | | | | | These conditions are checked in the base implementation. Change-Id: I4bb010d48c6a581a140ba697f9dc31390d2067d2 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Use qt_subtract_from_timeout() to reduce a code duplicationDenis Shienkov2015-10-101-8/+0
| | | | | | | | | | 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>
* Fix stalling of reading with the limited buffer size on *nixDenis Shienkov2015-10-011-1/+7
| | | | | | | | | | | When the read buffer with a limited size is used, the read notifier becomes disabled when the buffer completely is filled. The notifier should be enabled again when several bytes were read from the read buffer. Change-Id: I723253fb153a1144009579141fa0ce1aca93b648 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-17/+7
| | | | | | | | | | | | | | | | | | | 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>
* Allow to use the QSP::IgnorePolicy onlyDenis Shienkov2015-09-201-5/+5
| | | | | | | | | | | | | | | It is impossible to fix the dataErrorPolicy property that it worked at any platforms (this property does not work at all), besides, this property was deprecated. Therefore we can use always only the IgnorePolicy value for all cases, that will not be worse than it is. It gives a chance to get rid of internal code, related to dataErrorPolicy handling in favor to fixing of the Mark/Space parity handling, and the Parity/Frame/BreackCondition errors handling. Change-Id: Ib0c5d1396819aabe459002c5ca5cca5840052eff Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Unify common error strings in QSerialPortErrorInfoDenis Shienkov2015-08-281-10/+55
| | | | | | Change-Id: I1275e80988274e2409455217d5ffb03014962604 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Merge remote-tracking branch 'origin/5.5' into 5.6Liang Qi2015-08-281-2/+1
|\ | | | | | | Change-Id: I8b8dcf2103583b0a9113a0369a89aaa71c0b1b4b
| * Fix warning about unused variable on Non-Windows OS.Friedemann Kleint2015-08-191-2/+1
| | | | | | | | | | | | | | | | qserialport.cpp:1373:32: warning: unused variable 'd' [-Wunused-variable] Change-Id: I31adafe0089d13362b4a7c0efeddfbfb138f9415 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/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Doc: Fixed examples linkNico Vertriest2015-08-241-1/+1
|/ | | | | | Change-Id: Ic85e246c6bd5a6684f44940fb1c229835083c9dc Task-number: QTBUG-45391 Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* Merge remote-tracking branch 'origin/5.4' into 5.5Oswald Buddenhagen2015-07-171-2/+2
|\ | | | | | | Change-Id: Ibf52d73727ece041fea18c0711f018ddf9cc7960
| * Move QT_DEPRECATED_SINCE(5,2 and 5,3) macro before than qdoc comments5.4Denis Shienkov2015-07-161-2/+2
| | | | | | | | | | Change-Id: I72c455d2e5bbd660c53edd4bbb0b3fa5b08d806e Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Add QT_DEPRECATED_SINCE(5, 5) macro around qdoc commentsDenis Shienkov2015-07-161-0/+6
| | | | | | | | | | | | | | | | The macro was added for the signals in the header file, but not in the implementation file. Change-Id: Ie10b6bfffcbd8012f8e50b2009d95d826d983199 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Add missing QT_DEPRECATED_SINCE(5, 5) macroDenis Shienkov2015-07-161-0/+2
| | | | | | | | | | | | | | | | The macro was added in the header file, but not in the implementation file. Change-Id: Ia46563d19fba7dd1a1e1fbe40039f62667d32b11 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Give custom descriptions to errors which had none beforeDenis Shienkov2015-07-091-11/+11
| | | | | | | | | | | | 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-26/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Get rid of QSPP::bytesToWrite()Denis Shienkov2015-07-011-1/+7
| | | | | | | | | | | | | | | | | | It is not worth to spread the platform-specifics over multiple files, as the difference are actually tiny and much better expressed with an ifdef. Change-Id: I5279e05d52ce5243ad3d0655c6353e1fb18891a1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | Get rid of QSPP::readData()Denis Shienkov2015-06-301-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Because we now (in the Qt 5.5 branch) use QIODevicePrivate's internal read buffer directly, there is no need to call buffer.read() in QSP::readData(). There is also no point in keeping the platform-specific implementations of QSPP::readData(), so remove them. Tested on Windows using the virtual com0com serial ports, and on Linux usig the virtual tty0tty serial ports. Change-Id: I136c6d10708cc6fc99a77c351c3945470530845d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
* | Call the QIODevice::close() only after real closing of deviceDenis Shienkov2015-06-241-1/+1
| | | | | | | | | | | | Change-Id: I2b5b2ce8f193d09697f0a0b7e7cd1520cdf488bd Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* | Cleanup an error string when QSP::clearError() is calledDenis Shienkov2015-04-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | QSP::clearError() calls setError() with an empty error string. But setError() anyway calls the qt_error_string() that sets an error string from an system error which occurred before, that is garbage in this case. Thus, we need to call qt_error_string() only if the input QSP::SerialPortError is not NoError. Change-Id: I0260159d74579de47bcf1c7b2f4e747be6817269 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Remove unused readyReadEmitted variableDenis Shienkov2015-04-191-1/+0
| | | | | | | | | | | | Change-Id: I2313bd6160ffe18766b50257957b2cc66834290d Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>