summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Add the minimal set of the base auto testsv5.3.0-alpha1Denis Shienkov2014-02-223-1/+231
| | | | | | | | | | | | | | | | Added two types of tests: the constructing tests and the opening tests. The construction tests are checking of the getters to return of default values. Also are checking a correctness work of the constructor of class with different types of a port name. The opening tests are checking the open() method with the valid/invalid open modes and with the valid/invalid port names. The results are compared with the expected behavior (with the error codes and the return values). Change-Id: I503adf629cf613844bf9b96d8704ff017ea5fcdb Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* use private linkage where appropriateOswald Buddenhagen2014-02-201-4/+4
| | | | | | | Task-number: QTBUG-35781 Change-Id: I24b5ec010525da2c1f1be63996193ac31dcd3808 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-02-175-24/+164
|\ | | | | | | Change-Id: Ifff35473fe07ee5d94f9fb4f0125ee125c109c76
| * Set error if the file buffer flushing fails on Windowsold/5.2Laszlo Papp2014-02-171-1/+14
| | | | | | | | | | | | Change-Id: I58cf61540bc53e314988753a252cbc71003ce581 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * Use Q_GLOBAL_STATIC for the udev symbol loading QLibrary instanceLaszlo Papp2014-02-162-15/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Even though this has been introduced in 5.1, officially, we can rely on it in the previous versions even if private API that it was. * Global variables are better avoided. * Q_GLOBAL_STATIC is thread-safe in Qt 5. * QLibrary depends on QCoreApplication and we need to make sure that is initialized afterwards, respectively. The instantiation is now moved into the corresponding source file so that if it is included at more than one place, it will not be instantiated each time it is used in a new source file including this header. Task-number: QTBUG-36870 Change-Id: I96de1257e5836b69d0c48b717d7c2e708d6b0fee Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
| * Use the qt_safe_* methods for open/read/write/closeLaszlo Papp2014-02-162-7/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes the operation thread-safe. It also helps with preventing the leaks for child processes. Also, there is now some protection against EINTR when the system call has to be restarted. Thanks go to Thiago Macieira for providing the original patches. Task-number: QTBUG-36824 Change-Id: I90cac87c5e1c55a57e5ba6c20313446c43c6d242 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
| * Remove the continuous warning about the unknown flow controlLaszlo Papp2014-02-141-1/+0
| | | | | | | | | | | | | | | | Task-number: QTBUG-36865 Change-Id: I332901ad0118f1176b0d3b8e45c8000f0dfb59ee Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-02-142-33/+46
|\ \ | |/ | | | | Change-Id: I111ca7fd67979152329f290d45bd5b47551a404a
| * Do not emit bytesWritten() while data aren't transferredDenis Shienkov2014-02-122-24/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The serial port very slow device therefore the system call write() doesn't guarantee that data were transferred completely to the device. It guarantee only that data were sent to the driver from the user space. Thus it is wrong to emit the bytesWritten() signal at once after successful writing. The correct solution is to store the number of transferred data in some variable (e.g. pendingBytesWritten in this case) and to wait for the next notification from the WriteNotifier that the write FIFO of device is empty (i.e. when all data were really transferred) and ready to transmission of the next portion of data. Also good decision is to divide a data transfer operation into two methods: startAsyncWrite() and completeAsyncWrite(), similar with the Windows implementation. Where the startAsyncWrite() invokes the write() system call, and the completeAsyncWrite() is invoked by a writeNotifier to complete writing operation or start a new startAsyncWrite() operation. Tested on Arch Linux 64 bit with the on-board and the USB (PL2303) serial ports with use Qt4 and then Qt5. Change-Id: I1c274b2052a9bd54811586c6f1cfdf080b400263 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * Revert the private qtcore_unix related changes because they break the Qt 4 buildLaszlo Papp2014-02-121-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Revert "Open file descriptors thread-safely on Unix and don't leak them" This reverts commit 691212d9e492b12590d5b7f4e2b24921911d4b17. Revert "Protect against EINTR in Unix non-atomic I/O calls" This reverts commit a8597cbae47076e33b638c2e593f852c8c0a02d5. Change-Id: I6d931ae6d3b4bee9be019fdf4a08ecc5a41a2b0f Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-02-1213-286/+350
|\ \ | |/ | | | | Change-Id: I10b71332b0ec3afc50d11bcc95adb94c6343f6b1
| * Use QString for device propertiesDenis Shienkov2014-02-121-43/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The device registry property of the SPDRP_HARDWAREID is not used any more. This property was used earlier for parsing of the VID/PID and had the type of the REG_MULTI_SZ which was interpreted as QStringList, see commit: d8dc10efb1714dcfafa6a08e107fd31fc1e3ce0e The current code is using only string based concept, hence changing the interface to QString. Tested on Windows 8 with on-board and virtual com0com serial ports using the cenumerator example. Change-Id: I31e4f85f1b145021c1b34b81ba890553604a0531 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
| * Protect against EINTR in Unix non-atomic I/O callsThiago Macieira2014-02-121-6/+6
| | | | | | | | | | | | | | | | read(), write() and close() may return EINTR, indicating the system call should be restarted. The qt_safe_xxx versions of those functions do it. Change-Id: Ifef3b98131a7e24a5defea3e3af9345a505ad733 Reviewed-by: Laszlo Papp <lpapp@kde.org>
| * Open file descriptors thread-safely on Unix and don't leak themThiago Macieira2014-02-121-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | ::open directly is not thread-safe. You need to pass O_CLOEXEC if the OS supports it. That's the only thread-safe way to open files. qt_safe_open does that for you. This patch also implicitly makes all serial devices be opened with CLOEXEC on all systems, which prevents the file descriptors from leaking to child processes. Change-Id: I83a2657fa8d9ccca1b42182bcd83416091066045 Reviewed-by: Laszlo Papp <lpapp@kde.org>
| * Don't use cfmakeraw on SunOSSebastian Wiedenroth2014-02-111-0/+8
| | | | | | | | | | | | | | | | | | The cfmakeraw() function is an extension to POSIX and thus not fully portable. It doesn't exist on Solaris and Illumos. Source: http://www.perkin.org.uk/posts/solaris-portability-cfmakeraw.html Change-Id: Icf514fe32c01e85baff2a0d49321e45a320703b7 Reviewed-by: Laszlo Papp <lpapp@kde.org>
| * Merge remote-tracking branch 'origin/release' into stableFrederik Gladhorn2014-02-114-23/+34
| |\ | | | | | | | | | | | | | | | | | | Conflicts: src/serialport/qserialport_win.cpp Change-Id: Ib00a645c6660a3c81dbc9e159110f7bfc392ea36
| | * Obsolete the TxD/RxD signalsv5.2.1Laszlo Papp2014-01-272-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | They are not much of use due to the low-level OS limitations as of now, hence the obsolete proposal. It can be brought back to life at any point when we have a more clear idea what to do with this API. "faking" this signal as RealTterm probably does it, is not a nice impression for the end users. That would be more like a software "signal" (which we already have in place) rather than a real pinout hardware signal. It is interesting why Windows, Linux, etc do not provide an option for this. There must be some strong reason for it. Change-Id: Ia065e2ee9226d16e724f5e2690b25b954329d78e Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
| | * Refactor the reference in the documentation for property setters/gettersLaszlo Papp2014-01-241-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation contains broken links due to this, and it is also inconsistent with the rest. Properties should be referred to as properties, not individual methods like setter, getter, notified signal, etc. The change is tested with "make docs" and the broken links are history. Change-Id: Id94cba1f88503754318c865793229e3d3947bec6 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com> Reviewed-by: Martin Smith <martin.smith@digia.com>
| | * Fix the creaderasync example name in the qdoc fileLaszlo Papp2014-01-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change eliminates the following warnings when using "make docs": /home/lpapp/Projects/qt/qt5/qtserialport/examples/serialport/doc/creaderasync.qdoc:28: warning: Cannot find file 'creader/creader.pro' or 'creader/creader.qmlproject' /home/lpapp/Projects/qt/qt5/qtserialport/examples/serialport/doc/creaderasync.qdoc:28: warning: EXAMPLE PATH DOES NOT EXIST: creader It is also visible that the example is unreachable on the following documentation page: http://qt-project.org/doc/qt-5/examples.html Change-Id: I09f1532fcff6b1f7bfc5c4857bd14252aceb2eb3 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
| | * Fix the broken handle() documentationLaszlo Papp2014-01-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is likely to be happening due to the mismatching function signature include the return type between the header and source file. Two things are being fixed: 1) Dropped scope for the Handle just like with the winId case in QWidget. 2) "const" qualifier is now added for the method. Here you can see the documentation that it is empty: http://qt-project.org/doc/qt-5/qserialport.html#handle Change-Id: I5e9e0732cfd746a863de523fe90e58eafa42c081 Reviewed-by: Alex Henrie <alexhenrie24@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Martin Smith <martin.smith@digia.com>
| | * Fix the waitForReadyRead() behavior on WindowsDenis Shienkov2014-01-171-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is necessary to compare size of the readBuffer before and after completion of each read operation. If size of readBuffer are equal it means that are no more data available for reading. In this case the method should returns true if an initial size of readBuffer is not equal to the current size of readBuffer. Otherwise in all other cases should be continue waiting until timeout has been expired. Also must not to do check for the NoError code and to hope for valid value of this code inside waitForReadyRead(). Because a last error code do not clears automatically. It lead to false returns of this method in case the error number is not equal to NoError (for example it error remained after failed of any previous method). This check should be implemented in a different way in case of need. But at present this check is unnecessary because result of the waitAnyEvent() cover it. Task-number: QTBUG-33987 Change-Id: Ic8d8e3806fd4863c2720ffb83d5c19eae54d57f0 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Laszlo Papp <lpapp@kde.org>
| * | Keep the DTR line state at changing of DCB propertiesDenis Shienkov2014-02-112-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Updating of the DCB structure (in case of setup of some properties through setXX() methods) leads to reset of a status of the DTR line to an initial state. For example, after opening of port the DTR state was "high", further the call of method setDataTerminalReady(false) will drop the DTR to "low" state. But if now to change any properties of the device (e.g. to setup a new baud rate), the DTR will again be set to "high". The reason of this behavior is the fDtrControl flag of DCB structure: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363214%28v=vs.85%29.aspx To control of DTR is used the EscapeCommFunction() function which has no relation to the DCB structure. Therefore any re-initialization of the DCB discard the results of the EscapeCommFunction() function in case a state of the fDtrControl flag not equal to the real DTR state. Solution is change of a fDtrControl flag after successfully call of the EscapeCommFunction() function. Then further change of any property will be with a correct DCB. Besides, it is necessary to drop the flag DTR_CONTROL_HANDSHAKE at opening of device. Because in this mode the manual control of the DTR line is forbidden. Thanks to Dr. Alexander W. Lenhardt Task-number: QTBUG-36490 Change-Id: I14b040761f7e28108db87e667eb76f559be436cb Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * | Initialize the DCB structure before using itDenis Shienkov2014-02-102-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Please refer to the MSDN documentation for details: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363214%28v=vs.85%29.aspx and http://msdn.microsoft.com/en-us/library/windows/desktop/aa363201%28v=vs.85%29.aspx Change-Id: Id60f6d1b4a9237c2ae74063ac52221f42761b004 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
| * | Rename the writeSequenceStarted variable to writeStartedLaszlo Papp2014-02-102-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/serialport/qserialport_win.cpp Change-Id: I786879a485e78e3637d8cb474f86e3bd406bd237 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
| * | Rename the "descriptor" to handle on WindowsLaszlo Papp2014-02-104-62/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Windows uses the term handle instead of descriptor. * It is also consistent with the rest how Qt manages it. Conflicts: src/serialport/qserialport_win.cpp Change-Id: I68a672ea2d8e88e26ad5d822b157ccab79a3d2d9 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * | Remove the unused SystemIn/OutputQueue size methodsLaszlo Papp2014-02-096-74/+0
| | | | | | | | | | | | | | | | | | Change-Id: Iafab6ccc376da7a856b409017bbc42c36c016253 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
| * | Add error handling to some missing functionsLaszlo Papp2014-02-083-29/+112
| | | | | | | | | | | | | | | | | | Change-Id: If8dee1819d493fa4b27eba99de611c61bfdfe7a3 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
| * | Add enumeration through the SERIALCOMM registry entryDenis Shienkov2014-02-071-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using some software that provide an virtual serial ports functionality is impossible to use the Win32 SetupAPI feature to enumerate these serial ports. For example, such software is "Virtual Serial Ports Emulator" from Eterlogic: http://www.eterlogic.com/Products.VSPE.html The only possible simple way to detect these serial ports it to read the registry key HARDWARE\\DEVICEMAP\\SERIALCOMM: http://msdn.microsoft.com/en-us/library/windows/hardware/ff546502%28v=vs.85%29.aspx In this case it is possible to get only a name of the serial port without any additional information. This method is simply addition to the main SetupAPI functionality. Task-number: QTBUG-36526 Change-Id: Ib505aee66b74b6a8ebe16cf88c3060c8267397a0 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * | Use the ternary operator meant for this purpose rather than two returnsLaszlo Papp2014-02-071-3/+1
| | | | | | | | | | | | | | | | | | Change-Id: Ie6b17d95b83ad751130305a6d44cdead3cd46da6 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * | Add listing of virtual ports from the "AGG Software"Denis Shienkov2014-02-071-14/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current algorithm takes a name of the serial port from the PortName property which is in the Registry. This value is filled out by the Ports class installer automatically: http://msdn.microsoft.com/en-us/library/windows/hardware/ff546514%28v=vs.85%29.aspx But at using the "AGG Software" software this property is absent. Therefore the algorithm ignores these serial ports. The simplest workaround is use of the PortNumber property which identifies a port number for this software. In this case a port name defines indirectly, by adding a port number to the "COM" suffix. This does not influence other serial ports which are defined through PortName property. Tested on Windows XP and Windows 8 with the cenumerator example. Task-number: QTBUG-32774 Change-Id: I8cda3ed992ff80742511a2952d3fb7e8ac6edc81 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * | Rewrite the short description of the handle() methodLaszlo Papp2014-02-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * handle() is duplicated since the description explains that method. * It is pointless to put the "object" into the sentence. * It is consistent to start the sentence with the "if". Here goes a typical example that is worth following with consistency: "If successful, returns true; otherwise returns false." Change-Id: I1c7648237c75381b8452b8c47a59445fff58ad34 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * | Optimize of writing sequence algorithmDenis Shienkov2014-02-021-25/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * The writeSequenceStarted shall be set to true after a successful call of WriteFile() and to be dropped to false in case of write completion. * The method startAsyncWrite() shall not call WriteFile() if the writeBuffer is empty or writing sequence is already started. Also now there is no sense to check a validity of pointers on data in writeBuffer before call of WriteFile() because writeBuffer can not be empty. * It is also expedient to free the writeBuffer in _q_completeAsyncWrite() method only if numberOfBytesTransferred is not zero. Tested on Windows 8 with the on-board and the USB (PL2303) serial ports. Change-Id: Ib70276705fcc3f2396bf7dd6cf6977b62382a64b Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * | Handle the ERROR_INVALID_NAME error codeDenis Shienkov2014-01-311-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the user tries to open the serial port with empty port name, Windows returns this error code. The error will be exposed as QSerialPort::DeviceNotFoundError from now. Tested only on Windows 8 (32 bit) with on-board serial port as well as an usb dongle (PL2303) using Qt4 and Qt5. Change-Id: I9a56a7e51dbdab684b6d2a9fdf6398d8d5018e1c Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
| * | Fix some typos in documentation.Jeff Tranter2014-01-303-29/+29
| | | | | | | | | | | | | | | | | | | | | Fix some spelling and grammatical errors in comments that show up in Qt documentation. No changes to code. Change-Id: I185458e162d115eac25326d239b851b5e14ed5cf Reviewed-by: Laszlo Papp <lpapp@kde.org>
* | | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-01-271-56/+56
|\ \ \ | |/ / | | | | | | Change-Id: Id640f4d6e6d6c6eb794cdc59d7c2008e60634274
| * | Remove an unnecessary boolean interim variableLaszlo Papp2014-01-221-56/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is needless because it is only used once, right after the creation. Moreover, we would probably need to separate the two calls later into distinct introspection conditions to give a bit more correct warning whether the sysfs is present, or it is just not readable for some reason. It is also consistent with some other places. It also eliminates the needless indentation level for that relatively long block. Change-Id: Ib66e3033c2439315a8034101129cadd2dcdc29d0 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | | Disable build for WinRTMaurice Kalinowski2014-01-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to MSDN Windows Store apps will not have any serial port replacement. http://msdn.microsoft.com/en-us/library/windows/apps/hh464945.aspx Change-Id: I2aa54462c411341e3b3cdbbbf65a7b3397df93b6 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* | | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-01-179-131/+107
|\ \ \ | |/ / | | | | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: Id8be0cbb66eabf59c47011e4605e71cf29c1f532
| * | Bump MODULE_VERSION to 5.2.2Sergio Ahumada2014-01-161-1/+1
| | | | | | | | | | | | | | | Change-Id: Ic1184214f9ce933fc3df47629e0a707e0b8d63f5 Reviewed-by: Laszlo Papp <lpapp@kde.org>
| * | Optimize access to the write bufferDenis Shienkov2014-01-158-36/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Earlier for writing in writeBuffer was used the QSerialPortPrivate::writeToBuffer() method which contained a similar code for each platform. Therefore it is reasonable to delete this method, and to move its common functionality to the QSerialPort::writeData(). Also all platform-dependent code of start of data transfer move to the QSerialPortPrivate::startWriting() method. Change-Id: I1423723fd69c05df974f8ba597e3dd71d5a797dd Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * | Unify of the internal API of asynchronous handlingDenis Shienkov2014-01-153-95/+94
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It makes sense to unify internal methods of asynchronous I/O where to each method of start of operation corresponds the method of completion of operation: * startAsyncCommunication() - it is a new method which has a code relating to the handling of the WaitCommEvent() function. It implementations is taken directly by copy/paste with minimal modifications relating with adding of returns a boolean values. * _q_completeAsyncCommunication() - it is an existing method which is renamed from the _q_canCompleteCommunication(). * startAsyncRead() - it is an existing method without modifications. * _q_completeAsyncRead() - it is an existing method which is renamed from the _q_canCompleteRead(). Earlier this method contained a subfunction of the completeAsyncRead(DWORD) which is deleted now, and its code (related with the policy processing) is moved into body of the _q_completeAsyncRead() with the minimum modifications which do not change it behavior. * startAsyncWrite() - it is an existing method without modifications. * _q_completeAsyncWrite() - it is an existing method which is renamed from the _q_canCompleteWrite(). Earlier this method contained a subfunction of the completeAsyncWrite(DWORD) which is deleted now, and its code is moved into body of the _q_completeAsyncWrite() without modifications. Also in addition is added the new method emitReadyRead() and the code of policy emulation is moved into new method emulateErrorPolicy(). Change-Id: I58345e3270d676879a16efc4b7f35f74869894d8 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-01-101-1/+1
|\ \ | |/ | | | | Change-Id: I9b4871e9d69e73a1267a700aa953efaa0267c0e1
| * creadersync: do not return successful read for empty dataDenis Shienkov2014-01-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | In case of handling of the TimeoutError it is necessary to check on existence of the read data (for this concrete implementation of the example). Otherwise the application always return the TimeoutError even if a data was successfully read. Change-Id: I2437461f2ed2806bb7d7e16deb6925df035f62a1 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-01-067-40/+23
|\ \ | |/ | | | | Change-Id: I535078aafe7a322f3b09e2893a89e30c0028661a
| * Improve data receiving in creaderasync exampleDenis Shienkov2014-01-031-1/+1
| | | | | | | | | | | | | | | | | | | | Received data should be accumulated at each triggering of readyRead() during wait timeout. Otherwise application may print out only last portion of received data. Change-Id: Ib4d72f70e333298bae31c0eb95d7639b5c4d177d Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * Reimplement low level data sendingDenis Shienkov2013-12-306-21/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * Remove unused variablesDenis Shienkov2013-12-302-18/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * actualWriteBufferSize variable - it is a wrong old heritage related with the implementation of a code with the analogy from the the QWindowsPipeReader (where actualReadBufferSize is present). * acyncWritePosition variable - it is a old heritage when the write notifier could operate with a multiple writing operations at the same time. For this purpose it is necessary to know the following write position in the ring buffer. But currently all write operations happen sequentially, i.e. forbidden to carry out startAsyncWrite() several times without completeAsyncWrite() completion. Change-Id: I25b665b638649e6002fb194babfaa73f5ec8a6fa Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-01-0227-586/+3976
|\ \ | |/ | | | | | | | | | | | | Conflicts: .qmake.conf src/serialport/qserialportinfo_unix.cpp Change-Id: I9582d161018939defd3ba81d601fff176e86eb3c
| * Use the signals/slots for internal events handling on WindowsDenis Shienkov2013-12-183-251/+174
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The principal idea of this patch - to simplify a code and to minimize risks of UB in operation with the notifiers. Details are below: 1) Use a separate instances for the each notifier. It allows to get rid from an lookupXX() methods because now we always know which of notifiers was triggered. 2) Now each notifier is created once and used during serial port life. Moreover now in the open() and the close() methods are carried out a simply enabling and disabling of the notifiers. It allows to simplify code and to reduce overhead costs of check of a validity of the notifier pointers. 3) Use the signals/slots mechanism for the internal events handling. Use a slots excludes any UB in the notifier handlers because now isn't present a deep callbacks and so on. Even if some notifier will be deleted, we never got a crash at processing of triggered handle, we can just got an some error code and handle it. 4) There is no more need for existence of separate classes of notifiers which were inherited from the QWinEventNotifier. Now, the objects of QWinEventNotifier are use directly, only for delivery a triggered events to the appropriate slots. All logic of a events handling are in the _q_xx() slots. 5) The overlappedPointer() methods aren't necessary to us anymore. Now we know each OVERLAPPAD structure instance. It gives us to pass a pointers of these structures directly to the ReadFile/WriteFile/WaitCommEvent functions and have direct access to the hEvent field for the waitForXXX() methods. 6) The errors handling inside of the _q_xx() handlers are simplified. Now is not used a dptr-pointer to the QSerialPortPrivate class. So, earlier entered additional method QSerialPortPrivate::setError() is removed. This patch with using of slots is a strategic step because in the future in case of fix of a bug QTBUG-34946 instead of the QWinEventNotifier it is necessary to use the QWinOverlappedIoNotifier which provides only the signal/slot API. Note: Also this patch implicitly fix a bug QTBUG-33938. Task-number: QTBUG-33938 Change-Id: Iba9137e13e0bd6001c665434698b8cd965bc36e5 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * Merge remote-tracking branch 'origin/release' into stableFrederik Gladhorn2013-12-1610-40/+86
| |\ | | | | | | | | | | | | | | | | | | | | | Conflicts: src/serialport/qserialport.cpp src/serialport/qserialportinfo_unix.cpp Change-Id: I12658a9f92c91ab83f404c93a311ef947d1f2503