summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Refactor and add missed changes up 5.2.0 to 5.3.25.3Denis Shienkov2014-11-276-111/+285
| | | | | | Change-Id: I8a3c40202a89cd1fd264e324e6379d1f6220c340 Reviewed-by: Martin Smith <martin.smith@digia.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Improve the QSP::clear() on WindowsDenis Shienkov2014-11-271-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 9c88ad89801596e1d94acc4f32ff55c34118a66f solves a problem partially. Still when used QSP::clear() with some devices (e.g. virtual ports from the "AGG Software") the reading can be stalled. It is reasonable to make following: 1. Prevent to reset the both readStarted and writeStarted variables inside of QSP::clear() method. These variables shall be reset inside of _q_completeXX() methods which will be called automatically from the notifiers, since the PurgeComm should terminate pending read or write operations. 2. Instead of startAsyncRead() should be called the startAsyncCommunication(), that allow to correctly startup of the read sequence. This scenario can be reproduced with running of the tst_QSerialPort::readAfterInputClear() autotest. Tested on Windows 8 with the virtual com0com ports and with the virtual ports from the "AGG Software" using Qt5. Change-Id: Ic1a53334abd97667a9dd3291c3b975eb04062efd Reviewed-by: Robert Kurjata <rkurjata@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Prevent multiple calls of WaitCommEventDenis Shienkov2014-11-271-2/+3
| | | | | | | | | | | | | | | | Commit ac0422e8c9e74f2275129e3c7c69ef64299f07a9 introduced a regression that QSP::startAsyncCommunication() was called twice when a limited read buffer is used. In the second call the WaitCommEvent function returned the ERROR_INVALID_PARAMETER error that lead to a stall of the read sequence. QSP::startAsyncCommunication() should be called only when the read buffer has enough space. Tested on Windows 8 with the virtual com0com ports using Qt5. Change-Id: Icd6cada7c3acfd4e689ac76ec304416b00f52b50 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Fix critical typo with _q_startAsyncWrite()Denis Shienkov2014-11-271-1/+1
| | | | | | | | | | | Commit 62dfdeb3642250bdb642dbf607a8c7b95e57835e introduce a critical typo that revert a bug which are fixed in the b4d5bd813f591dc618e0fff2d55d93eeccb1a26e commit. Change-Id: I9ed29f5b443cbd7102878287d531d18a9351a2e5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QSP::bytesToWrite() on WindowsDenis Shienkov2014-10-067-36/+68
| | | | | | | | | | | | | | | | | | | | | | | After calling the WriteFile() function, QSP::bytesToWrite() should return zero, but did return the size of writeBuffer. On Windows, we must not to cut a size of the writeBuffer until the asynchronous write operation has completed. So we need to make use of an additional actualBytesToWrite variable, the value of which is increased when new data is added to the writeBuffer, and decreased after calling the WriteFile() function. This change also entails the modification of the QSP::writeData() method and deleting the QSP::startWriting() method. Now all platform-dependent code (related to startWriting(), and to copying of memory to writeBuffer) resides in the new QSP::writeData() method. But this modification does not change the behavior on platforms other than Windows. Tested on Windows with the virtual com0com serial ports using Qt5. Change-Id: I35c1428ad374c0709d6c352a93c552898e947bde Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Allow for deviceInstanceIdentifier() to return an upper case stringDenis Shienkov2014-10-061-3/+3
| | | | | | Change-Id: I91977b1aa4a8e5bd8321efc5cfda375c9d7deff7 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Restart of async reading when a QSP::clear() is calledDenis Shienkov2014-10-032-0/+48
| | | | | | | | | | | | | | | | | | | The method QSP::clear() can stall reading in case of following situations: - at the moment when PurgeComm abort of previously started asynchronous reading operation - when a serial port is in hardware flow control mode - when a serial port has a limited read buffer size Therefore is necessary restart of asynchronous reading to enable of the read sequence. Change-Id: I7a722a1ee20ecba0dd631da96ca81d2937d7ca6b Reviewed-by: Robert Kurjata <rkurjata@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Fix reading on Windows at limited read buffer sizeDenis Shienkov2014-10-028-4/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case the read buffer has a limited size then are impossible to read remainder which is still can be in driver's queue, since no readyRead signal emmitted and reading are stalled. Problem is that Windows does not fire the EV_RXCHAR event in case a driver's queue has ready to read remainder; this event will be triggered only when a new data are received. The solution is to start of asynchronous read operation for reading of possible remainder from the queue after doing QSP::read() from the user. Besides is necessary to meet conditions: - do not start reading in case a reading already is started - do not start reading in case is not in limited buffer size - do not start reading in case is a previous reading returns a less data than read buffer size or are not in the hardware flow control mode Tested on Windows 8 with virtual com0com serial ports using Qt5 and then Qt4. Task-number: QTBUG-41295 Change-Id: I01797e6f8d6006751244144fead3616b1de1b811 Reviewed-by: Robert Kurjata <rkurjata@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Remove custom baud rate filteringManuele Conti2014-10-011-3/+7
| | | | | | | | | Some serial device have baud base that it is not multiple of baud rate selected, so we need to allow baud rate compliant with device. Change-Id: I7d3ce94f10d4382a29ff34bb18daebb650186c1c Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Fix segfault related to dynamic udev loadingSergey Belyashov2014-10-012-7/+2
| | | | | | | | | Problem was caused by conflict of libudev symbols and function pointers declared in qtudev_p.h. Task-number: QTBUG-40113 Change-Id: I599575e8a1b9ffe32295331d46d991422975f773 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Handle onboard serial ports when parsing sysfsRainer Keller2014-09-291-0/+3
| | | | | | | | | | | The device detection stopped if one of the sources reported at least one device. This made onboard serial ports not listed if a USB device was plugged in. Onboard serial ports are now detected and added to the list of devices. Change-Id: I8798e7f14073e19d9e206eb4d7cdd0b28bd8a0bb Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Fix typo in twoStageSynchronousLoopback testDenis Shienkov2014-09-281-2/+2
| | | | | | | | | Commit f1761c1236edce428278f7a9e8aa1091097eaa57 introduce a typo for receiverPort and senderPort variables, that lead to failure of test. Change-Id: I18ecad78bb11d7bb218a674c3c3bf9c863a2b33c Reviewed-by: Samuel Gaist <samuel.gaist@edeltech.ch> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Fix order of passed parameters into QCOMPAREDenis Shienkov2014-09-281-7/+7
| | | | | | | | According to documentation the QCOMPARE should accept to the first parameter an actual value, and to the second parameter an expected value. Change-Id: I64e762e779fa6a61401f358c4dd6097dacf7a33a Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Fix access after delete in OS X QSPIDyami Caliri2014-09-251-2/+1
| | | | | | | | | | Valgrind analysis shows that searchStringProperty was accessing memory after deletion. This was caused by constructing QCFString local var with CFStringRef, which does not retain object. Change-Id: I1e9571a5051aa6f0c3fbc732ac01e821069f8b02 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Query a serial number of USB device from SysfsDenis Shienkov2014-09-251-0/+4
| | | | | | | | Tested on Linux with the USB (FTDI and TI) serial ports using Qt4 Change-Id: I8c088bf8b6fe440565cc37538ca7ef029651fb61 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Make tst_qtserialport build with Qt 4Samuel Gaist2014-09-121-4/+5
| | | | | | | | | The newly moved twoStageSynchronousLoopback fails to compile since there's no qCompare available for int and long long with Qt 4. This patch allows to build it again with Qt 4 Change-Id: Ib3764b125f371ae70864bd578c7ccda39d08ae22 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Added missing deprecation guards and documentation updateSamuel Gaist2014-09-121-2/+7
| | | | | | | | This patch adds the missing guards around the deprecated functions implementations. Change-Id: I829e90e289da7af736fc6f5d6c319509138f1aef Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Fix Qt 4 buildSamuel Gaist2014-09-121-2/+0
| | | | | | | | | | Following the discussion on the development mailing list with Thiago Macieira, remove the guard around the signals since it's not supported to build with Qt 4. Task-number: QTBUG-41190 Change-Id: I8df1b7fa8cc69a2aacdcb4fedea0cc6fe092eece Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Bump versionFrederik Gladhorn2014-08-291-1/+1
| | | | Change-Id: Ida6ecfd792ea1906c70bf17bb5b8077ad4c5e631
* Fix a race condition at writing on Windowsv5.3.25.3.2Denis Shienkov2014-08-284-10/+167
| | | | | | | | | | | | | | | | | | | | | | | 1. The writeStarted flag shall be reset to false after bytesWritten() signal is emitted, but not before it. 2. In case of start of writing from the startAsyncWriteTimer it is necessary to call the startAsyncWrite() method but not the completeAsyncWrite() method. It give guarantees to exclude of race condition to multiple call of the WriteFile twice until the write operation is not completed. For example, a race condition is watched in case of writing data from the slots which are connected to the bytesWritten() signal from a device; or to the timeout() signal from a timer with zero interval. To checking of these scenarios are added additional autotests. Tested on Windows 8 with the on-board and USB serial ports, using Qt5. Task-number: QTBUG-40769 Change-Id: Iedabbf38847debeee795a10fd7a4c54c65d2a338 Reviewed-by: Patrick Noffke <patrick.noffke@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Add missing private headers warningsSamuel Gaist2014-08-187-0/+77
| | | | | Change-Id: Ia60bf0d020d98a6fda8f689d631bb8681950d15f Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Fix handling of writing at using of waitForReadyRead()Denis Shienkov2014-08-151-0/+3
| | | | | | | | | | | | | The method waitForReadyRead() shall call of the write sequence since the signals from the startAsyncWriteTimer will not be handled inside of waitForReadyRead() without event-loop. Tested on Windows 8 with the on-board and USB serial ports, using Qt5. Task-number: QTBUG-40793 Change-Id: I7806f16a4df30c4ec1643d8f696ad5761decd30a Reviewed-by: Patrick Noffke <patrick.noffke@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Fix compilation of apps with QT_DISABLE_DEPRECATED_BEFORE=0x050300Marcel Krems2014-08-111-0/+2
| | | | | | | | | | The enum is already marked as deprecated leading to this error: qserialport.h:267:46: error: no type named 'DataErrorPolicy' in 'QSerialPort' void dataErrorPolicyChanged(QSerialPort::DataErrorPolicy policy); ~~~~~~~~~~~~~^ Change-Id: I8d178f0d0921b8f5308183e1f09a4c8388448e26 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Move the synchronous loopback test from benchmarks to auto testsDenis Shienkov2014-08-035-158/+29
| | | | | | | | | | | | | | | Previous commit 76f293bfb0fd7bab391f96ac822eacc40e4c5176 with adding of this test to the benchmarks were hasty. After all it makes sense to place it to auto tests to have opportunity to run with others together. Besides, this test is renamed since it is not a loopback, it is an I/O test with the synchronous approach. Change-Id: I043a6e0075561167bb29a59a384554ef98dbbd4a Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Make the QSerialPort::flush() non-blockingDenis Shienkov2014-08-022-20/+2
| | | | | | | | | | | | | According to documentation, the flush() method shall be non-blocking. Tested on Linux 64-bit with auto-tests with the on-board and the USB serial ports for Qt4 and then Qt5. Note: On Windows the flush() method still does not work. Change-Id: Iaee80361e59e0c281206ca24c817a446cdbf6ed1 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Pass a length of string to QString::fromWCharArrayDenis Shienkov2014-08-011-6/+17
| | | | | | | | | | | | | | | | | | | | Using of the QString::fromWCharArray() we didn't pass length of a string, hoping that all WCHAR strings are terminated by the null-character. But it can lead to the wrong results if the initial WCHAR string has no null character. Therefore it is reasonable to pass length of a string to exclude an error. Besides, to do not break of the algorithm of string comparison it is necessary to return not null-terminated strings. Also now there is no need to initialize of some allocated arrays by zero values. Tested on Windows 7/8 with the on-board, the virtual com0com, the USB FTDI and the PL2303 serial ports, using Qt4 and then Qt5. Change-Id: I382cf8eacf4ab4d21c54de17fcdd6b9fcfa3d02c Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Fix leak of a descriptor after unsuccessful openingDenis Shienkov2014-07-316-115/+152
| | | | | | | | | In case of unsuccessful initialization of a device at the opening, a valid descriptor has to be closed before return from the open() method. Task-number: QTBUG-40414 Change-Id: I45568f176e003d9be1fe8c3017da29f39908efb0 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Fix events handling in waitForBytesWritten() method on WindowsDenis Shienkov2014-07-302-5/+52
| | | | | | | | | | | | | | | | | | | | | In case of communication event is triggered in the waitForBytesWritten() method then necessary to process it with the _q_completeAsyncCommunication() method, but not with the _q_completeAsyncRead() method. Otherwise it leads to false filling of the readBuffer with the data that were read earlier (or with garbage) which remained in readChunkBuffer. The synchronous loopback autotest reproduces a bug without of this patch. Tested on Windows 7/8 with the on-board and USB serial ports, using Qt5. Task-number: QTBUG-40344 Change-Id: I679109b60f4058c4c6f7e5f02c1f70ba6039d8d8 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Add the synchronous loopback data verification testDenis Shienkov2014-07-264-1/+158
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Good reason to check of data correctness at transferring and receiving. In this test are used two serial ports, connected in a null-modem mode: http://en.wikipedia.org/wiki/Null_modem . The sender port transfers data to the receiver port. After data are received is carried out check of equivalence of the transferred and received data. Before run of testing it is necessary to set two variable environments QTEST_SERIALPORT_SENDER and QTEST_SERIALPORT_RECEIVER to specify names of used serial ports. This test can reveal errors related with the internal data processing and also errors of synchronous I/O inside of QSerialPort. This test is placed in separate "benchmarks" category not to mix-up with "manual" and "auto" categories, because this test is closer to "benchmarks" by own functionality. Tested on Windows 7/8 with the virtual com0com serial ports, using Qt4 and then Qt5. Change-Id: Ie6f87b50784bce211cf68c16cf75f79d12a8564f Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Doc: Edited example documentation.Jerome Pasion2014-07-1410-48/+76
| | | | | | | | | | | | | -added information about how to run the example by including a file from qtbase/doc/global -edited summary sections -added \brief. -removed image captions. Our Qt 5 CSS files don't handle them. Task-number: QTBUG-33597 Change-Id: If3293aa9d98b662f20af2af7030b0ab0fb1e8401 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
* Return from the loop if a port name is foundDenis Shienkov2014-07-101-0/+3
| | | | | | | | | | | | | The function devicePortName() search in the Registry the names of ports by names of registry keys. At first looks for value of a key of "PortName", and then of "PortNumber" key. Thus, the first found value shall stop search and do not try to continue. Tested on Windows 7/8 using Qt4 and then Qt5. Change-Id: I98b00ff043a3b08476fec0a57b0d36ce65fc8d63 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Wrap of getting the port properties on WindowsDenis Shienkov2014-07-091-50/+74
| | | | | | | | | | | | | It is reasonable to wrap implementation of getting properties of port from availablePorts() to the separate functions. It is simplifies a code and improves its understanding. Tested on Windows 7/8 with the on-board, virtual com0com, USB FTDI serial ports using Qt4 and then Qt5. Change-Id: I2345fa49b3633960412715b299e068daa8fdcfd0 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Do not continue waitForReadyRead() if an error occurredDenis Shienkov2014-07-091-10/+3
| | | | | | | | | | This patch improves workaround implemented in the previous commit d34fce4a5d12789ded107631e22cb6ef54d35eee Change-Id: I013b19b47ee343ab00f242d7ee1021b92c07d18f Reviewed-by: Peter Kümmel <syntheticpp@gmx.net> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Refactor of the QSerialPortInfo for OS XDenis Shienkov2014-07-092-193/+267
| | | | | | | | | | | | | | | | | | | The current implementation of the qserialportinfo_mac.cpp module is a little confused and complicated. It is reasonable to re-write it using some ready wrappers of CFTypeRef, CFStringRef and others objects from the private qcore_mac_p.h file. Thus, it will allow to bypass of manual releasing of the allocated resources (using the RAII idiom where it is possible), and also to simplify a code. Tested on OS X 10.8.4 with the on-board, USB PL2303, USB FTDI, USB Android serial ports and with the USB ZTE Modem using Qt4. Change-Id: Ibbac03a17fdd41bbaf530f863e7c690a15708bd2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Make independent implementation of QSerialPortInfo for OS XDenis Shienkov2014-07-094-13/+62
| | | | | | | | | | | | | | | | | | | | | | | | Building in OS X uses some shared code from the serialportinfo_unix.cpp module with the OS X specific code from the serialportinfo_mac.cpp module. Thus, all code of the serialportinfo_unix.cpp module, which not related with the OS X, is shielded by a macro. It adds an excessive garbage for readability in this module and also some confusion in the *.pri file. It makes sense to make implementation of the serialportinfo_mac.cpp module completely independent, that will simplify maintaining of source code. Besides are added tests which can reveal declared but not implemented methods in building, and also to check a correctness of default values at running. Tested build on OS X 10.8.4 with Qt4, an then on Android with Qt5. Change-Id: I67935b64e2b623fb8d4c14d59e1b87f1eac71c3e Reviewed-by: Bernard Pratz <guyzmo+qt@m0g.net> Reviewed-by: Peter Kümmel <syntheticpp@gmx.net> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Improve error handling for the waitForXX() methods on WindowsDenis Shienkov2014-07-083-27/+29
| | | | | | | | | | | | | | | | | | | | | | | The slots _q_completeXX() returns empty values, therefore the waitForXX() methods continue to work even if occurs an error from the I/O completion. Is reasonable allow to return of boolean values for the I/O completion slots. Besides, it allows avoiding indirect detection of an error, comparing of the sizes of I/O buffers before and after the operation completion. Though, for the waitForReadyRead(), for this purpose it is necessary to add additional modifications in a following patches. Tested on Windows 7/8 with the virtual com0com ports using Qt4 and then Qt5. Testing was made using of autotests and examples. Change-Id: I95a76461af4595f6658f0cad766a4fff14eb7afc Reviewed-by: Peter Kümmel <syntheticpp@gmx.net> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Unify handling of errors of the overlapped I/O resultDenis Shienkov2014-07-082-46/+37
| | | | | | | | | | | | | | | | | | | | | | | Each q_completeXXX() slot does call of GetOverlappedResult() and differently interprets an error depending on the type of I/O operation (read, write or communication). It is more reasonable to make it in the separate method handleOverlappedResult() which returns the number of the transferred bytes or -1 in case of error. Besides, this method accepts the additional integer parameter which expresses type of overlapped operation using the existing QSerialPort::Direction enumeration. The type of the communication operation has not separate value, so is used zero value for it. Tested build on Windows 7/8 using Qt4 and then Qt5. Change-Id: I8482392d06279bc430656e50b1e4392c513885c6 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Peter Kümmel <syntheticpp@gmx.net> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Abort waitForReadyRead() when there is an errorPeter Kümmel2014-06-301-0/+4
| | | | | | | | | | When in readNotification() or completeAsyncWrite() an error is emitted and the loop is not exited, this error signal will flood the eventloop. Change-Id: I77b8a4c337041258862b19a07917bef059c11cc1 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Improve the serial number handling on WindowsDenis Shienkov2014-06-301-13/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The standard USB CDC driver (usbser.sys) does not add information of serial number to the device instance identifier of the child devices (serial ports), so our algorithm returns an empty string. But information about a serial number is stored in the device identifier of the parental node. Thus, it is necessary to get this parent identifier, using these recommendations from MSDN: http://msdn.microsoft.com/en-us/library/windows/hardware/ff549417%28v=vs.85%29.aspx For this purpose is used the set of new functions from the "Configuration Manager Functions" family. Therefore it was necessary: * Rewrite the deviceInstanceIdentifier() function. Now this function accepts one DEVINST parameter and returns the corresponding device instance identifier string. * Add the new parentDeviceInstanceNumber() function. This function accepts a DEVINST of the child device and returns a DEVINST of the parent device. Thus, the new algorithm tries to extract a serial number from the current (child) device and in case it is empty, try to extract from the parent. Tested on Windows 7/8 with the Segger JLink device (provides the CDC serial port) using Qt4 (MSVC2010) and then Qt5 (MSVC2012, MinGW). Also are checked other devices for possible regressions: * on-board serial port * com0com virtual serial port * USB FTDI serial port no regressions found. Change-Id: Ic6afc258f45aa374ec77dc0b586d479b5286359f Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Improve the ResourceError handling on WindowsDenis Shienkov2014-06-291-21/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To the ResourceError handling we generally relied on triggering of the _q_completeAsyncCommunication(), in case of ejection of an USB device from a host. But it worked with not all USB devices (for example it did not work with the ZTE modems). Even when this worked (for example with the PL2303 devices), then we got the non informative "Unknown error" of the ResourceError string representation. It is more reasonable not to do any custom checks of an event mask when triggered of the _q_completeAsyncCommunication() method. We need allow to detect an errors with means of the ReadFile/GetOverlappedResult/WaitCommEvent syscalls on an invalid device handle. An important note is that returns the different error codes for a different types of devices. For example: * For the USB ZTE and the Samsung Android USB modem returns the ERROR_ACCESS_DENIED error code. * For the FTDI and the Samsung Android Diagnostic Serial Port returns the ERROR_OPERATION_ABORTED error code. * For the USB PL2303 device returns the ERROR_BAD_COMMAND error code. Thus, there is no universal solution of this issue. Each vendor of the driver implements it own way. Therefore for each new type of the device it is necessary to add processing its error code, if we have no it yet. Tested on Windows 7/8 with the USB ZTE and the Android modems, with the USB PL2303 and the FTDI devices and with the Android diagnostic serial port using Qt4 and then Qt5, no regressions found. Task-number: QTBUG-32020 Change-Id: I61c02078ee98221ecef18a27cde3d9bae3674d70 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Improve the I/O completion errors handling on WindowsDenis Shienkov2014-06-291-8/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * It is necessary to ignore the NoError error code. * In case of error from GetOverlappedResult() it is necessary to stop the I/O operation by a immediate return from the function, because I/O processing does not make sense. This is consistent behavior similar to starting I/O operations. * All errors from the read completion should be interpreted as ReadError. Exception is only the critical ResourceError error which it is necessary to leave without changes. This is also consistent behavior similar to starting I/O operations. * The write completion error handling should be similar to the read completion handling. * For the communication completion we have no specific error codes. Therefore error handling shall be without modification of their error code. Also were made small cosmetic fixes to the related start I/O methods. Tested on Windows 7/8 with the on-board, the PL2303 and the virtual com0com serial ports using Qt4 and then Qt5. Testing are made by means of examples of library and also by means of auto tests, no regressions found. Change-Id: I0d08b53627431c42ab5147d4330f1aaf819b4d63 Reviewed-by: Peter Kümmel <syntheticpp@gmx.net> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Bump versionOswald Buddenhagen2014-06-181-1/+1
| | | | Change-Id: I50ea328c903f3ba0c78f9570b6b6b892bb38f976
* Fix mixed up vendor and product identifiersv5.3.15.3.1Oleg Shparber2014-06-141-2/+2
| | | | | | | | Caused by I1a66164c. Change-Id: I78973a509ff91a1302f435b1a23ecce432e56dd4 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Remove the exception notifier handling for *nixDenis Shienkov2014-06-122-59/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The exception notifier does not do any useful operation while processing I/O but only complicates error handling. It has been thoughtlessly introduced at beginning in hope that in the future it can it is useful, but the practice showed that it not so. Problem is that in case of ejection of an open USB device from a host there is the infinite triggering of the exception notifier that leads to program hangup. We could stop an exception notifier in this case, but it not rationally because after the exception notifier is triggered the read notifier which also enters the infinite loop. Thus the read notifier anyway duplicates the exception notifier, as for functionality and as for an error code. Therefore more rationally to completely remove the exception notifier. So in case of the ResourceError we need just to stop of the read notifier, because it is a critical error. Then an user will be notified on the ResourceError appearance and must to close the device himself. Though work was checked only on Linux, but we can do not worry, and to refuse from this notifier in MacOSX also. Because anyway in MacOSX this type of notifier is not supported, at least from the Qt 5.1 and above: https://qt.gitorious.org/qt/qtbase/source/982fdd4ef556f63ba77384a0dbe97928e610091b:src/platformsupport/cfsocketnotifier/qcfsocketnotifier.cpp#L210 Besides in documentation on QSocketNotifier is recommended do not use the Exception mode: http://qt-project.org/doc/qt-5/qsocketnotifier.html#Type-enum Tested on ArchLinux 64 bit with the USB PL2303 device, ZTE modem, Android serial port using Qt4 and then Qt5. Task-number: QTBUG-36727 Task-number: QTBUG-35829 Change-Id: I4ea6db2a1c7f10c096d57817c00edefc4f0595ff Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com> Reviewed-by: Peter Kümmel <syntheticpp@gmx.net> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Merge remote-tracking branch 'origin/5.3.0' into 5.3Oswald Buddenhagen2014-06-120-0/+0
|\ | | | | | | | | | | | | | | Manually adjusted: src/serialport/qserialport_unix.cpp to remove isCustomBaudRateSupported Change-Id: I22480b57d8c1b91ea7ea4a1da4ba3060e1a5f93f
| * Fix setting custom baud rates under Linuxv5.3.0release5.3.0Sergey Belyashov2014-05-131-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | This regression was caused by 7c737e0edcb93585856c65890ef34e5c5a28ee6b. The initialization of the (current) serial port info was removed in that commit. Tested on Linux x86_64 with Qt 5.1.1 and 4.8.6. Task-number: QTBUG-38961 Change-Id: Idd3c5dc7eb37093848f33387563ff14567ac54fe Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
* | Merge remote-tracking branch 'origin/stable' into 5.3Sergio Ahumada2014-06-112-76/+96
|\ \ | | | | | | | | | Change-Id: I65f7cd2fdeced526c8bd7dc5bc4081e7687e7310
| * | Refactor the availablePortsByUdev() in favor to readabilitystableDenis Shienkov2014-06-071-48/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implementation of the availablePortsByUdev() function is a little complicated by excess "if/else" conditions and also too long lines, that worsens readability. It is reasonable to make the following: * To get rid of the big "if {...}" blocks in favor to immediate return from function in case of an error. It will allow to reduce a quantity of lines and will shift code alignment to the left. * To split declaration of some long variables and functions into separate lines, with length at least up to 80~100 characters. * To drop of the 'struct' keywords and the '::' global namespace operator for variables. Tested on ArchLinux 64 bit with the on-board and PL2303 serial ports using Qt4 and then Qt5. Tested build on Android x86 using Qt5. Change-Id: Iddc2a9511230e56e4a9d01a4c22af7b2eaeae60c Reviewed-by: Peter Kümmel <syntheticpp@gmx.net> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * | Use QScopedPointer (RAII) to do not care of the udev resourcesDenis Shienkov2014-06-071-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is a good idea to get rid from the manually releasing of the allocated udev resources. Tested on ArchLinux 64 bit with on-board and PL2303 serial ports using Qt4 and then Qt5. Change-Id: Ib25e100bea37ad3cc0bee015b7de6d4de762f2cc Reviewed-by: Peter Kümmel <syntheticpp@gmx.net> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
| * | Simplify of the availablePortsByUdev()Denis Shienkov2014-06-072-33/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no sense to use udev_device_get_subsystem() for comparing with the predetermined names of subsystems (like "pnp", "usb" and so on). This idea was preliminary and required further revising after accumulation of some statistic. The main ideas in favor of refactoring are given below: * It seems that reasonable to use the "ID_MODEL", "ID_VENDOR" and others identifiers to query of properties for all types of serial ports. We lose nothing, because in the worst case the getUdevPropertyValue() function will simply return an empty string, as before. * Earlier we excluded from the list all ports which have a subsystem with the "platform" name. Practice showed that for these devices is used the serial8250 driver. Therefore it is reasonable to exclude this type of devices by the name of drivers instead of by the name of subsystems. Also are made related changes: * Is added the resolving of chars for the new udev_device_get_driver() function * The functions of getting properties are wrapped for reduction of length up to 100 characters. Tested on ArchLinux 64-bit with the on-board, PL2303 serial devices using Qt4 and then Qt5. Tested build on Android x86 using Qt5. Change-Id: I1a66164ca1893180e1ed97524cff98b4a933a63b Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>