summaryrefslogtreecommitdiff
path: root/src/serialport/qserialport_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Do not use settingFromBaudRate() on Windowsv5.6.0-beta1Denis Shienkov2015-12-131-0/+2
| | | | | | | | 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-2/+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>
* Remove unused QSPP::baudRateFromSetting() methodDenis Shienkov2015-10-061-1/+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-8/+0
| | | | | | | | | | | | | | | | | | | 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 termios structureDenis Shienkov2015-09-081-2/+2
| | | | | | | | | | | It is better to read the current termios structure each time before changing, than to have stored it locally. Tested with the USB serial ports. Change-Id: I63e0c2c1c320ee4b98c8423963d78396f72eb3c2 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-2/+2
| | | | | | | | | 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>
* Refactor the speed configuration for *nixDenis Shienkov2015-09-071-6/+2
| | | | | | | | | | | | | | | | | | | | The internal implementation of this is a little tangled. It is reasonable to simplify it: 1. Remove the setBaudRate_helper() method, as it is equivalent to setStandardBaudRate() method. 2. Now the setStandardBaudRate() and the setCustomBaudRate() are self-sufficient methods (can setup a speed and an error codes internally) and return a boolean values. Also added the "loopback" test for check of different speeds. Tested with the on-board and the USB serial ports. Change-Id: I4320c2e29ad42a394e07753cbaea804d0faf6b78 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-6/+2
| | | | | | 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/+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>
* Improve the processing of errorsDenis Shienkov2015-07-081-4/+19
| | | | | | | | | | | | | | | | | | | | | | | | 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/+0
| | | | | | | | | 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-2/+0
| | | | | | | | | | | | | | 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>
* Do not use the queued connection to handle an I/O events on WindowsDenis Shienkov2015-06-231-1/+0
| | | | | | | | | | | | | | ... that simplifies the code of waitForXX() methods. In this case we do not need to call the completion methods, because it does the _q_notified() slot automatically even without an event loop. Tested with the virtual com0com serial ports, using auto tests and examples. Change-Id: I33d6c91d1842fd3eff1673d60e8413d471725f74 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.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>
* Remove space between "if/elif defined" macro and its bracketDenis Shienkov2015-03-121-8/+8
| | | | | | | | It is the recommended coding-style which is used in the Qt core. Change-Id: Id2efc3b2276b2d86d75fe0b7240077dbb61286f0 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Make QSP::timeoutValue() as staticDenis Shienkov2015-03-121-1/+1
| | | | | | Change-Id: I9f11be6f1de66af70e84a00943d8cc75909e4956 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Get rid of C-style's SERIALPORT_BUFFERSIZE macroDenis Shienkov2015-03-121-5/+2
| | | | | | | | It is reasonable make it as enum and part of QSP class. Change-Id: I13d4561568b2688f7d1a054073455c23a64c1b94 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Add the missed PORT_UNKNOWN macro for Android OSDenis Shienkov2015-02-271-0/+1
| | | | | | | | | This macro was missed in 5.5 branch, this causes a break of building. Change-Id: I0e79e6c6cb6c347356c449959b1cf14755a42eb1 Reviewed-by: Jani Heikkinen <jani.heikkinen@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Merge remote-tracking branch 'origin/5.4' into 5.5Frederik Gladhorn2015-02-251-4/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/serialport/qserialport_unix.cpp src/serialport/qserialport_unix_p.h src/serialport/qserialport_win.cpp src/serialport/qserialport_win_p.h src/serialport/qserialport_wince.cpp src/serialport/qserialport_wince_p.h Change-Id: Ibb917652b132e66fbb90f437bf762c1094911dc0
| * Do not use internal pre-cached RTS and DTR variablesDenis Shienkov2014-12-051-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some devices do not support these signals, and returns an errors when attempt to query it. But the QSP::open() always requests a status of these lines. In this case the QSP::open() will return true, but also will setup an error code (for example, QSP::UnsupportedOperationError for socat's devices in Linux). That is unexpected behavior for the user. It is reasonable do not query a state of these signals when opening. Also we do not need to use of appropriate internal variables, and we can remove it. Change-Id: I277110014c20c1f2c3fdaed20c4582d1356897b9 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* | Update copyright headersJani Heikkinen2015-02-131-6/+6
| | | | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I35f551de8408a2eb6a0f39df1f09d90c8084a7c0 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Improve usage of the break state for the Tx lineDenis Shienkov2015-01-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Now the sendBreak() method is deprecated since it is blocking and impossible to implement same behavior on different platforms using their API's. Besides, this method can be implemented via setBreakEnabled() and QTimer. 2. Introduced the new property named as "breakEnabled" which consist of setBreakEnabled() and isBreakEnabled() methods and the signal breakEnabledChanged(). Note: After opening, the port always is in non-break state. Task-number: QTBUG-36571 Change-Id: Ib808dab7eaed8cc5449c66d8186a29a7b7e45afc Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Use QWinOverlappedIoNotifier instead of QWinEventNotifierDenis Shienkov2014-11-271-14/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reasons of this change are following: 1) Implementation of QEventDispatcherWin32 has restrictions to maximum quantity of QWinEvenNotifier instances in one thread. Method QEventDispatcherWin32::registerEventNotifier() registers the [MAXIMUM_WAIT_OBJECTS - 2] numbers of notifiers only. Where the MAXIMUM_WAIT_OBJECTS that is equal to 64, since it is a part of "Multiple-object Wait Functions" API: http://msdn.microsoft.com/en-us/library/windows/desktop/ms687069%28v=vs.85%29.aspx 2) There is need to have three instances of QWinEventNotifier to watch I/O events of each serial port. It has limits to the maximum number of used serial ports and it is [(MAXIMUM_WAIT_OBJECTS - 2) / 3] = 20 for the one thread. 3) Attempting to move or to resize a window of GUI application lead to suspending of I/O events from serial port. A long suspension can lead to overflowing of FIFO of device, so the data can be lost. All these shortcomings are resolved with QWinOverlappedIoNotifier, which uses the "I/O Completion Ports" API: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365198%28v=vs.85%29.aspx Tested on Windows 8 with the virtual (com0com), on-board and the USB (PL2303) serial ports. Task-number: QTBUG-34946 Change-Id: I879d939f86c8dcde0fe21a8d6267e81152822aa4 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* | Use internal read buffer of QIODeviceDenis Shienkov2014-11-171-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is reasonable to use the internal read buffer of QIODevice instead of additional QRingBuffer which currently are used. It will allow to reduce an overhead when copying data as now there is not an excess chain with QRingBuffer. Besides, the majority of I/O classes from QtCore (except QProcess) also use the internal QIODevice buffer which are optimized for this purpoze. Tested on Windows 8 and Linux with the virtual com0com and on-board serial ports. Change-Id: I6c3d4b84593940ccfef8c15c9fbef16bddcd002f Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* | Use QIODevicePrivate for PIMPLDenis Shienkov2014-11-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | It is reasonable to get rid of excess D/Q pointers and to use their equivalents from QIODevicePrivate. Also in the future it will allow to use the internal read buffer of QIODevicePrivate. Tested on Windows 8 and Linux with the on-board and com0com serial ports. Change-Id: I9d0923c6f9adc5981dc49dacea163b286620ed5c Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* | Create notifiers inside of startAsyncXX() methods when requiredDenis Shienkov2014-11-151-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | It is reasonable to move creation of notifiers from the constructor to the specific separate methods. In this case notifiers are created in startAsyncXXX() methods if necessary for concrete I/O operation. Also it allows to return an error in case a notifier is failed. Tested on Windows 8 with virtual com0com serial ports. Change-Id: I351a4c54214c84455150d0fc157a99108280cc12 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Move all platform-specific declarations into one QSPPrivateDenis Shienkov2014-11-141-2/+219
|/ | | | | | | | | | This is near to the internal Qt PIMPL style. Also it will allow to use QIODevicePrivate is more smoothly in next patches. Tested on Windows 8, Linux, OSX 10.9 with on-board serial port. Change-Id: Ieef4b05d0bf11cf2da6420e58629bea1818108f9 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Update license headers and add new license filesAntti Kokko2014-09-091-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I08685205169cdd4b49a651ed98f36ba1e6c1bb29 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Add missing private headers warningsSamuel Gaist2014-08-181-0/+11
| | | | | Change-Id: Ia60bf0d020d98a6fda8f689d631bb8681950d15f Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Rename the flow to flowControl for consistencyLaszlo Papp2014-03-011-1/+1
| | | | | Change-Id: Ida3c4ff049f21bd96fd64b41c66787b3961ada5e Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Reimplement low level data sendingDenis Shienkov2013-12-301-2/+1
| | | | | | | | | | | | | | | | | | | | | | | A feature of writing of the buffer by chunks of 512 bytes (by default) was introduced earlier as the developers option in order that it was possible to regulate load of the CPU and quantity of emitted signals of bytesWritten() just change WriteChunkSize value in source code. As shows of the practice, the most optimal mode is writing of whole content of the buffer without division into chunks. It reduces load of CPU (because reduces a quantity of the events triggers) and also simplifies the source code. But potentially there can be negative consequences of writing of whole buffer directly in case of broken driver: * A kernel panic (or BSOD) in case of writing a data large than driver's internal queue. * Can be transferred not all data from the buffer, but only their part. Change-Id: I0fcac1ccf3c752579978b4745771accbf8274267 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Eliminate the ifdef in the code for imported headers (qt4support)Laszlo Papp2013-10-091-4/+0
| | | | | | | | | | | | | | | | | | | As I previously wrote on Gerrit, this idea of resembling the include hiearchy inside qt4support has two advantages: 1) The includes are well-separated for Qt 4 that are imported. 2) The code is less complex due to the non-existence of ifdefs for major Qt variants. The only disadvantage is that the build system got one additional line, but the benefits outweigh that. This has been (only build!) tested on Linux (Arch) with Qt 4 and then 5. Change-Id: Ic33632cd0e569693a65af094479dac0a02b1a7f7 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Remove the unnecessary Q_DECLARE_PUBLIC from the data classLaszlo Papp2013-07-271-1/+0
| | | | | | Change-Id: I8293dfc6d492bac59fa830d499902cabdc8d95dd Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Revert "Add property to set exclusivity"Laszlo Papp2013-07-081-1/+0
| | | | | | | | | | | | | | | | | | | This reverts commit 4c67500e5d14e561e37b4bdc056f059d3eefdfa4. "dev: unfrozen branch, containing alpha-quality code that is ready to go into beta testing at any time" ... from: http://qt-project.org/wiki/Branch-Guidelines Please respect the basic principles. In doubts, do not approve changes yourself, but ask for help. Besides the illegit nature of this change, it has fundamental documentation issues as well. It is summer, and this can wait until 5.2, so please do /not/ rush with approvals. Change-Id: Ic2763394035c776088cb28f9c04086920cedb3a2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add property to set exclusivityAlex Henrie2013-07-031-0/+1
| | | | | | | | | Disabling the serial port driver's exclusive mode is necessary for pseudo serial ports and some USB/serial adapters to work correctly. Change-Id: I74d45feed619817b61e265b00aec8b0ebfae7a33 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Modify the restore settings on close API to lean towards the Qt'ish styleLaszlo Papp2013-02-101-1/+1
| | | | | | Change-Id: Idb648c9e8d0607826e775f4b92f092b5c81c9790 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Establish internal variables for aiding the signal emission fixLaszlo Papp2013-02-091-0/+2
| | | | | | | | | It is better to optimize for successful open as there is no access then to the device or virtual port anymore for scam applications to alter. Change-Id: I4f2eddea11ab55bf2b4d8d78bbc2986b2f7ca754 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Remove the QtSerialPort namespace define and hence namespace usageLaszlo Papp2013-02-071-4/+0
| | | | | | | | | | * This is for following the convention in the Qt Project with the rest. * This fixes examples and tests to build now as all of them are broken due to the regression. Change-Id: I3f4d64d97466520aea621da582a64a0d97e32136 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Fix the potential build breaks introduced by a previous commit (regression)Laszlo Papp2013-02-071-0/+4
| | | | | | | | | | | | | This is due to the fact the Qt namespace is not considered which is normally not a problem as it is empty by default. However, using something like "-qtnamespace MyNamespace" when configuring Qt will break the QtSerialPort build completely. This is intended to be a fix for the library, and the examples/tests will be fixed in a separate commit if necessary. Change-Id: Iecd24dc5135c3a9645910754589dfd8bf4942337 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Rename the PortError to SerialPortError to be more consistent and talkativeLaszlo Papp2013-02-021-1/+1
| | | | | | | | | It is necessary not to get a potential Error enumeration overridden in QIODevice in order to be specific. It is also how other QIODevice subclasses handle the API more or less. Change-Id: I9f5b5601118be4b7a285b965ea5ea5e995848e8e Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Make all the file renames and relevant changesLaszlo Papp2013-01-271-0/+87
"git log --follow /path/to/the/file/in/question" can be used, for instance, for the renamed files to get the whole history. Change-Id: I20da087ca88e2c179a6c3232772fa21575e0aa6a Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>