summaryrefslogtreecommitdiff
path: root/src/serialport/qserialportinfo_win.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QSerialPortInfo: Extract Method anyOfPortAnton Kudryavtsev2016-07-151-22/+11
| | | | | Change-Id: Ic0851ee8d491f29922d55f3c0530ccd21ed171a5 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Replace 'Q_NULLPTR' and 'NULL' with 'nullptr'Denis Shienkov2016-06-171-6/+6
| | | | | | | | | We can use nullptr since Qt 5.7. Change-Id: Id5354280d6a94b2c1f4c5967c65a22db878eca3e Reviewed-by: Anton Kudryavtsev <a.kudryavtsev@netris.ru> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Replace local 'static const' integers with 'enum'Denis Shienkov2016-06-101-4/+4
| | | | | | | | | | Not sure whether this improves anything, but it can't make it worse. Enumerators are always rvalues and never end up in the .rodata part of binaries; static variables (const or not) are lvalues and therefore can get their address taken. Change-Id: I24155e5a3224fd6a33885a7ca3194ac53879d2c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge 5.7 into 5.7.0Oswald Buddenhagen2016-05-201-3/+4
|\ | | | | | | Change-Id: I2e0737fab1c12657d8dc7de5d1882ecb73bbb5f2
| * Replace 'Q_FOREACH' with the range-based 'for'Denis Shienkov2016-05-131-3/+4
| | | | | | | | | | | | Change-Id: I057267982ac946ce1ec863a79120cd21cd563c4b Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Replace 'forever' with 'for(;;)'Denis Shienkov2016-05-201-4/+4
|/ | | | | | | | ... 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>
* Merge remote-tracking branch 'origin/5.6' into 5.7v5.7.0-beta1Liang Qi2016-04-081-0/+2
|\ | | | | | | Change-Id: I1b9b5ff33064eab6e35e4fd57b72b8fbf2a5a022
| * Merge remote-tracking branch 'origin/5.6.0' into 5.6Liang Qi2016-03-211-0/+2
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/serialport/qserialportinfo_osx.cpp src/serialport/qserialportinfo_unix.cpp src/serialport/qserialportinfo_win.cpp src/serialport/qserialportinfo_wince.cpp Change-Id: I9540cf8c714a99b7ace9aeaeb003cb4a00b8303e
| | * Deprecate QSPI::isBusy() methodv5.6.0-rc1v5.6.05.6.0Denis Shienkov2016-02-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is impossible to implement this method properly on all platforms. Its implementation is complicated and introduces a side-effects, related to the race-conditions, permissions and so on. The user can implement QSPI::isBusy() himself just trying to open a desired device, what is equivalent to the current implementation. Change-Id: I71ef69a1a8edb7c4df23c8b2816add40475e00b5 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-03-071-12/+13
|\ \ \ | |/ / | | | | | | Change-Id: I35f19a7d266f90e957bfe01534a40c4d98b40b34
| * | Get serial number of bluetooth USB dongle on WindowsDenis Shienkov2016-02-191-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now, the serial ports which are created by the bluetooth connection takes the serial numbers of the own USB bluetooth dongles. We enumerate all parent devices of a driver stack until their end has been reached, or the serial number has been found. Change-Id: I63820f34fd4c47992c3c5ef3c7ce63eca4ea0cf8 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
| * | Move QSPI::standardBaudRates() in one placeDenis Shienkov2016-02-161-5/+0
| |/ | | | | | | | | | | | | | | | | | | Currently we do not need in multiple implementations of this method, and can move it to the qserialportinfo.cpp file. Change-Id: I9d27c739ebd07f76a0e4e808766052bf90d4c19b 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>
* Use C-style tokens array for query of device name from registryDenis Shienkov2015-12-101-5/+8
| | | | | | | | ... because QStringList it is an overhead in there. Change-Id: Ic5da6243348ee1a934ae2c91707de71fa7e96825 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Use the C-style array of GUID tokensDenis Shienkov2015-12-101-14/+13
| | | | | | | | ... because use QPair and QList it is an overhead. Change-Id: I9ed90f9301ab1fed194890e925c9124e86d3c7dc Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Use pre-defined class/interface devices GUIDsDenis Shienkov2015-12-101-8/+12
| | | | | | | | | | Also is added the test for verification of presence of ntddmodm.h file, which contains GUID_DEVINTERFACE_MODEM definition. In case the compiler has not this file, we define GUID_DEVINTERFACE_MODEM himself. Change-Id: I471f76f8eabd2a200702a0970aa538c780208e18 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Refactor QSPI code on WindowsDenis Shienkov2015-10-061-40/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | Current approach with passing of the array's data pointer to a Win API functions when the array is empty has potential danger. Because the data pointer is invalid, and if a Win API function tries to get access to this pointer then this can cause a crash or an UB. Still this does not happens, but nobody guarantees that this will be same in future. It is better to pre-allocate the array with some size (e.g. with the MAX_PATH size). In this case we can pass the data pointer without any problem. Besides, the Win API functions will return result with the first pass if the array size is sufficient; otherwise it returns ERROR_MORE_DATA error code and we can re-allocate the array with required size and to return a result in the second pass. We re-allocate the array with size more than required on some bytes with filling of the array with zeros. This allows us to convert it using QString::fromWCharArray() without specifying a size, and to remove the toStringAndTrimNullCharacter() function. Change-Id: I5976485286db4097514ea7b3a8adfc9a6a7cea4f Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Merge remote-tracking branch 'origin/5.4' into 5.5Oswald Buddenhagen2015-07-171-0/+2
|\ | | | | | | Change-Id: Ibf52d73727ece041fea18c0711f018ddf9cc7960
| * Add missing QT_DEPRECATED_SINCE(5, 2) macroDenis Shienkov2015-07-161-0/+2
| | | | | | | | | | | | | | | | | | The macro was added in the header file, but not in the implementation file. Change-Id: I51bc62eedbaba627fb525c04dc126bf0125e7a39 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Fix getting duplicate serial ports with null charactersDenis Shienkov2015-07-091-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function toStringAndTrimNullCharacter() deletes only trailing zeroes from right to left direction up to the first non-zero character were meet. This can return the wrong string in case there are the zero characters to the left of the non-zero characters. We should look for the first zero-character from left to right direction, and discard all right part of a string, including the zero-character. Task-number: QTBUG-47127 Change-Id: I4d101b49bbb153bddbe535a920d616b5fef130e9 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Don't use QStringLiteral when QLatin1String is efficient.Debao Zhang2015-03-271-7/+7
| | | | | | | | | | | | | | | | | | For QLatin1String, startsWith/endsWith/append/operator==/... are overloaded, so use QLatin1String instead of QStringLiteral in such cases. Change-Id: Id040697480b7b7f195a2b83bb85ba7e0199d38e3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* | Merge remote-tracking branch 'origin/5.4' into 5.5Frederik Gladhorn2015-02-251-6/+6
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | 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
| * Use Q_NULLPTR where it is possibleDenis Shienkov2014-12-101-6/+6
| | | | | | | | | | Change-Id: I7261a92ea4405c8aeab7670f73e7225ed7e4d9d0 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>
* | Merge remote-tracking branch 'origin/5.4' into devFrederik Gladhorn2015-01-191-15/+28
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/serialport/qserialport.cpp src/serialport/qserialport.h 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_p.h src/serialport/qt4support/include/private/qcore_unix_p.h Change-Id: Ifaa5ce8c1c0eb1c70246c54782719b91f3c95771
| * Allow to use custom devices pathsDenis Shienkov2014-11-271-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QSP incorrectly transforms non-standard device names to their paths and vice-versa (for example, "/home/ttyS0", "//./COM1", and so on). Now this problem is solved: * The transformation code is moved to QSPP. * Added autotests auto/qserialportinfoprivate to testing of conversion algorithm. These tests are private and can be activated with building of QtSerialPort with: qmake "QT_CONFIG+=private_tests warnings_are_errors" \ DEFINES+=QT_BUILD_INTERNAL Tested on Windows 8, Linux, OSX with auto-tests, with on-board and virtual serial ports. Task-number: QTBUG-38639 Change-Id: I43757a7f1390f53ed2b1d70de59c6bfb71892a59 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
| * Fix QSPI::isNull()Denis Shienkov2014-11-211-11/+11
| | | | | | | | | | | | | | | | | | | | | | The method QSPI::isNull() should return false when QSPI is empty. Tested on Winsows 8 and Linux with on-board, virtual and USB serial ports using Qt5 and then Qt4. Task-number: QTBUG-41262 Change-Id: Ic9e0afc5549311283aef7ec2ed841f5e418b7edf Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* | Move all platform-specific declarations into one QSPPrivateDenis Shienkov2014-11-141-1/+1
|/ | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.3' into 5.4Frederik Gladhorn2014-10-141-3/+3
|\ | | | | | | Change-Id: Id7e66059233e8d07ba44cad19048d9cddc68e250
| * 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>
* | 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>
* 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>
* 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>
* 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>
* Move the WinCE implementation into separate moduleDenis Shienkov2014-05-201-6/+0
| | | | | | | | | | | | | | | | | WinCE implementation was mixed a common code with the Win32 implementation that caused some problems with maintenance. More correct decision is moving a common code which was used in *win.cpp into *wince.cpp module without modifications. Now the Win32 and the WinCE implementation are independent from each other. Tested build with Qt5 on "win32-msvc2012" and then with Qt4 on "wincewm50pocket-msvc2008" configurations. Change-Id: I63f687468beffa9a75b534a4fbe536b854b12210 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Add API for querying the serial numberLaszlo Papp2014-03-021-0/+24
| | | | | | | | | | | Thanks go to Massimo Callegari for the initial patch and the request to remind us again. Thanks also go to Denis and Sergey for working on the windows serial number parser. Task-number: QTBUG-31981 Change-Id: I60d882280f481eb99d275e0a9c81da50292b1c61 Reviewed-by: Massimo Callegari <massimocallegari@yahoo.it> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* 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>
* Rename the "descriptor" to handle on WindowsLaszlo Papp2014-02-101-6/+6
| | | | | | | | | | | | | * 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>
* 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>
* 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>
* Add the additional enumeration through Device Interface Class GUIDDenis Shienkov2013-11-301-15/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current "Setup Class GUID" approach ignores the devices which has been created by the drivers with a custom setup GUID's (e.g. Eltima Virtual Serial Port Driver and so on). In this case need to add each new custom GUID to the list. But it is not a good solution and shall be used as a last resort. The good solution is use of the "Device Interface Class GUID" instead of the "Setup Class GUID" because it is the recommended way: http://msdn.microsoft.com/en-us/library/windows/hardware/ff545036%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/windows/hardware/ff545046%28v=vs.85%29.aspx A new approach uses the standard GUID_DEVINTERFACE_COMPORT and GUID_DEVINTERFACE_MODEM GUID's which shall be used for the development of any serial port drivers. Besides requires adding of the additional DIGCF_DEVICEINTERFACE flag for the SetupDiGetClassDevs() function, see MSDN: http://msdn.microsoft.com/en-us/library/windows/hardware/ff551069%28v=vs.85%29.aspx It should be noted that this approach also can ignore some devices with drivers which don't use the recommendation. Earlier already there were attempts to implement this approach but unsuccessful, see more 3bfe998860e0bfd3ce48784188eaa0d58bf86da1 and bcdeb589dd9d3b0ff7270d380d043b1882eefdc0 commits. Thus, it seems effective to use both "Setup Class GUID" and "Device Interface Class GUID" approaches that will complement each other. In this case can be keep only the standard GUID's. 1. Now all GUID classes are in the QUuid form and stored in the constant list of pairs as QPair<uuid, flags>. It allows to avoid the old heritage related to the pure-C coding style. 2. The second "flags" parameter from the pair is the DWORD input parameter for the SetupDiGetClassDevs() function which specify the control options that filter the device information elements. It allows to pass the appropriate flags for the each used approach independently. Tested with the cenumerator example on Windows with Qt4 and then Qt5, no regressions found. Task-number: QTBUG-33313 Change-Id: I478905e8ae4b79b7d967e0727d2e1620ad667177 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Laszlo Papp <lpapp@kde.org>
* Remove the unnecessary and noisy comments for the serial port info filesLaszlo Papp2013-11-241-2/+0
| | | | | | | | | | | | | Comments are noisy, useless, and can get outdated. The only comments that might make sense to me the ones where we note future tasks, such as TODO (or FIXME). The code should document itself. The serial port files need a separate evaluation since a lot of stuff is inherited from QtCore in there where the comments should probably be kept for consistency. Change-Id: I6c759c7138f64546c2c4e27a039667c556a30db9 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Define QStringLiteral when undefined (e.g. Qt 4)Laszlo Papp2013-11-061-5/+5
| | | | | | | | | | | | This will allow us Qt 5 style coding. QLatin1String replaced everywhere where it works for Qt 4 and 5, namely: the direct literal passing. Note that the "standard" typo has also been fixed in this commit as the line had to change anyway, so it is not much of an additional noise. Change-Id: I8b7e4fe5f337441000bd3d8f58db528fdd0e175b Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Windows: acquire identifiers using the SetupDiGetDeviceInstanceId functionDenis Shienkov2013-08-181-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | This decision uses one identification string of the device instead of the list of hardware identifiers. See more detail in MSDN: * http://msdn.microsoft.com/en-us/library/windows/hardware/ff551106%28v=vs.85%29.aspx * http://msdn.microsoft.com/en-us/library/windows/hardware/ff541327%28v=vs.85%29.aspx The device instance ID unambiguously identifies the device in system and contains necessary values of identifiers, that allows to resolve some issues: * we can abandon a patch: https://codereview.qt-project.org/#change,61633 and Task-number: QTBUG-32684 automatically will be resolved * we can apply a patch: https://codereview.qt-project.org/#change,61752 because instance ID also contains the serial number info Checked on Windows 7 and 8 with USB PL2303 converter, USB Modem ZTE MF180, USB Android Modems, USB Motorola CDC ACM device. Change-Id: If3b67b5b34d65de060a0e7682ba426cd94a01fa7 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Windows: Add PCI vendor and device identifier detectionv5.1.1Denis Shienkov2013-07-251-11/+26
| | | | | | | | | | | | | | | | | | | | | The PCI identifiers are different to the USB identifiers, as in: * USB: VID_, PID_ * PCI: VEN_, DEV_ For more info see MSDN: * USB: http://msdn.microsoft.com/en-us/library/windows/hardware/ff553356%28v=vs.85%29.aspx * PCI: http://msdn.microsoft.com/en-us/library/windows/hardware/ff546262%28v=vs.85%29.aspx Therefore, the method availablePorts() skipped processing of PCI prefixes. Now, problem was resolved. Task-number: QTBUG-32018 Change-Id: I098a35a170043b9c58b74cb278e4daff34b1f84e Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Revert "Refactor the Windows port enumeration from GUID classes to ↵Denis Shienkov2013-04-301-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | devinterfaces" This reverts commit 3bfe998860e0bfd3ce48784188eaa0d58bf86da1. Patch with enumerating of devices through interfaces GUID's enters many regressions, breaks universality and complicates realization. For example, it breaks enumeration of CDC ACM devices. Moreover, some devices (like Nokia phones) has incorrect registration in Windows registry so workaround will greatly complicates code. Decision with use of GUID's interfaces was worse than the previous with use of setup GUID's. Thus, was made the decision to roll away changes on really working decision with Setup Class GUID's. Now tested for devices: * built-in serial port * USB/Serial converter on PL2303 chip * USB/Serial converter on FTDI chip * USB/Bluetooth dongle with standard MS bluetooth stack * USB/CDMA Modem ZTE MF180 * Com0com virtual serial ports * Eltima virtual serial ports * Telit virtual serial ports * CDC ACM serial port on Motorola E398 phone * CDC ACM (and modem) serial port on Nokia E95 phone on Windows XP/7/8. Task-number: QTPLAYGROUND-27 Change-Id: Icc893e9e54e51dbf78da2d132dab6db986d94e03 Reviewed-by: Laszlo Papp <lpapp@kde.org>
* Refactor the Windows port enumeration from GUID classes to devinterfacesDenis Shienkov2013-04-201-12/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Earlier enumeration of devices was made through GUID classes. But MSDN says that this approach became outdated (since Windows 2000), and instead of classes it is necessary to use GUID interfaces. See: * http://msdn.microsoft.com/en-us/library/windows/hardware/ff545036%28v=vs.85%29.aspx * http://msdn.microsoft.com/en-us/library/windows/hardware/ff545046%28v=vs.85%29.aspx Thus there was a changeover of: * GUID_DEVCLASS_PORTS by GUID_DEVINTERFACE_COMPORT * GUID_CLASS_MODEM by GUID_DEVINTERFACE_MODEM Of course, flags for the SetupDiGetClassDevs() function changed also. This approach decided the following: * Use of newer API for enumeration * There is no need GUID classes for non-standard "purely" the virtual devices (like com0com and so forth) * There is no need to check for name "LPT" existence, because GUID_DEVINTERFACE_COMPORT belong only to serial ports devices (instead of GUID_DEVCLASS_PORTS that include serial and parallel ports). It is checked on devices: * Built-in serial ports * USB/Serial converters (PL, FTDI) * USB Bluetooth serial ports (with standard MS stack) * USB modems (ZTE MF180) * Com0com virtual serial ports * Eltima virtual serial ports * Telit virtual serial ports It is checked on OS: Windows XP/Vista/7/8 Change-Id: I9da51d815ac5081a95113659be2b38ebd31275a4 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Laszlo Papp <lpapp@kde.org>
* Add accessor methods for checking the availability of the PID/VIDLaszlo Papp2013-03-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As mentioned in the previous change, this is necessary for those end users who would like to explicitly know if the device on the serial port has a valid vendor or/and product identifier. This is now providing a nice and convenient API for having a dedicated boolean method for making this query possible. It is a lot more readable and convenient to use than other alternatives including the extended scope for the integer query method and so forth. It is more explicit and clear about the intention that one checks if the device has a valid identifier. It would be more vague with error codes and so forth. One somewhat reasonable alternative could be this, albeit this is also more inconvenient: a) bool vendorIdentifier(quint16 &vendorIdentifier) const; b) bool productIdentifier(quint16 &vendorIdentifier) const; ... as this would require an additional variable from the user, and this could not be used with ternary operators so easily, et cetera. There are even worse ideas like how the exceptional conversion happens in QString and so forth, but that also requires an explicit variable or zero if one is sure the conversion should succeed. One can pass zero in there, but that is still inconvenient and more than passing nothing, and zero can become unclear what it supposed to present half or one year later. The change has been tested on Linux with Qt4 and Qt5, and cenumerator works as expected. The documentation has been added accodingly. Task-number: QTPLAYGROUND-21 Change-Id: I905708ce0e67307bf89d69e645462486ad869b0c Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Change the return type of the vendor/productIdentifier() APILaszlo Papp2013-03-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The API was established with a bit of insanity, namely: it returns raw strings for the 16-bit vendor and product _numbers_. This brings lots of limitations into the system aside from its silly nature, like how to handle lower and upper case hex letters (a-f, A-F) and so forth. Also, it is not clear whether the API should return zero aligned strings, or whether or not to return the leading indicator of the hex format (0x). This is now all being eliminated by switching to the 16-bit unsigned integer use. There are mostly two use cases for the usage of this: a) Comparison or mapping to find the requested port and device This is getting very simple because it will mean a simple 16-bit unsigned integer comparison which is cross-platform by its nature for sure. b) Display the string to the end user This is for instance with an enumerator or terminal emulator application, but in this special case the user can format the output of the integer as wished. Then, it can easily become a cross-platform display. Even customizing is simple enough to provide the native look'n feel without the library forcing one particular type. The documentation is being changed correspondingly. As for the future, if the need even arises, the following methods could be considered for the info provider class (QSerialPortInfo): bool hasVendorIdentifier() const; bool hasProductIdentifier() const; ... both can be added without any issues (i.e. in a binary compatible way). The examples are updated now as well with presenting the usage of the new API. The GUI emulator example got the string management a bit updated to be in line with the console based emulator (cenumerator). In general, it is also a way more reasonable way of putting a string together with so many placeholders. Also, the argument and list management got a bit nicer formatting style per line break. Testing: the change has been tested on Linux with Qt4 and Qt5. Task-number: QTPLAYGROUND-21 Change-Id: I33683061787af94a797685794be9ebcfa90c499a Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>