summaryrefslogtreecommitdiffstats
path: root/src/serialport/qserialportinfo_unix.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make independent implementation of QSerialPortInfo for OS XDenis Shienkov2014-07-091-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix mixed up vendor and product identifiersv5.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>
* 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-071-33/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add support for PCI vendor/device informationSergey Belyashov2014-05-241-11/+36
| | | | | | | Tested on Linux x86_64 with Qt 5.1.1 Change-Id: Ibea1204ece921c2c18ee37992380fbc33897be8d Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Inspect lock file to determine busy state.Dyami Caliri2014-05-231-2/+20
| | | | | | | | | | | | | | | | | | QSPI was relying on QLockFile.isLocked() to determine if the port was in use. This was due to a misunderstanding of the QLockFile class design. Ideally the code in QSPI.isBusy() should be moved into a new method, QLockFile.available(), since it contains implementation details of that class. Note that isBusy() is for information purposes only, since checking for a lock without obtaining it is always racy. Change-Id: I675bd4033e4228e6bf864bf2e7a00a2520ccc50e Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Enable QtSerialPort on QNXRafael Roquetto2014-04-281-0/+2
| | | | | | | | | | On QNX, the combination (IHFLOW | OHFLOW) is equivalent to the CRTSCTS flag. Only /dev/ser* ports can be enumerated. Tested on SVTronics UEVM5432 Omap5 board with QNX 6.6 Change-Id: I64b149258a525835e63f231b5291fa86637e3d2a Reviewed-by: Laszlo Papp <lpapp@kde.org>
* Use QScopedPointer (RAII) for avoiding the memory leak for udevv5.3.0-beta1Laszlo Papp2014-03-181-13/+19
| | | | | | | Task-number: QTBUG-37578 Change-Id: I9e9146a1f7339a88c63cb320a47f63f069a6120e Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Fixed info update for FTDI devices on AndroidLuke Andrew2014-03-081-2/+4
| | | | | | | | | Added check for Q_OS_ANDROID. If connected to Android, look for a valid TTY_USB id. Task-number: QTBUG-36296 Change-Id: Ic99b0ddd7afc6621e795e2f6cf2952cae6634fb0 Reviewed-by: Luke Andrew <codereview@lukeandrew.com> Reviewed-by: Laszlo Papp <lpapp@kde.org>
* Add API for querying the serial numberLaszlo Papp2014-03-021-0/+3
| | | | | | | | | | | 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 Q_GLOBAL_STATIC for the udev symbol loading QLibrary instanceLaszlo Papp2014-02-161-1/+5
| | | | | | | | | | | | | | | | | | | | | | 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>
* 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>
* Merge remote-tracking branch 'origin/release' into stableFrederik Gladhorn2013-12-161-0/+4
|\ | | | | | | | | | | | | | | Conflicts: src/serialport/qserialport.cpp src/serialport/qserialportinfo_unix.cpp Change-Id: I12658a9f92c91ab83f404c93a311ef947d1f2503
| * Fix the detection of PCI serial ports with sysfs and without udevv5.2.0-rc1Laszlo Papp2013-11-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unfortunately, 0973537c5471288726b929250199a41435729bee caused a serious regression for obtaining detecting PCI serial ports without udev. This was working before since the hard coded fallback mechanism has been up to this task, but the sysfs alternative took the precedence over. A note has also been added to the udev part of the algorithm because we will need to obtain the vendor and product identifiers in a separate block in the future. The vid/pid will be fixed in a separate change once that is well-tested. This patch has no any risk as far as I can tell since it is just adding a new short block to the existing code without much implication. I have tested the change on Linux for my use cases with Qt 4 and then 5, and I cannot find any regression. Everything works as expected both with udev and without, i.e. with sysfs. Thanks go to Aaron Linville for reporting the issue. Task-number: QTBUG-35064 Change-Id: Ieae6f3e94559fb61ede67ff1d8810bb686d46383 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Aaron Linville <aaron@linville.org>
* | Try to load udev at runtime if we do not link against itLaszlo Papp2013-11-251-26/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was an explicit option previously added into 5.2.0 due to lack of time to implement this runtime resolution properly. The libudev load variable can now be eliminated which also simplifies the packaging. This change also takes care of avoiding the regression by not loading udev at runtime at all for Qt 4. That has always been the case, so there are no regressions there. A TODO comment has been left in the code though about it. The helper free functions cannot be static because they are declared as friend outside that source file. Ideally, we could have a better approach, but that would require more significant refactoring, and such a revamp has to become stable in the 'dev' branch before going into the 'stable' branch. Thereby, this is an acceptable compromise. It does not break binary compatibility either to remove or add friend declarations to a class. The change has been tested on Archlinux (x86_64) with Qt 4 and then 5 using the cenumerator example. The change has been tested both with udev and without that, i.e with sysfs on my Linux system. Change-Id: Ia7d7ecb336c1de1913e1dd60177ae7469e90c329 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Remove the unnecessary and noisy comments for the serial port info filesLaszlo Papp2013-11-241-31/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Do not use parentheses around a single statement for consistencyLaszlo Papp2013-11-241-2/+1
| | | | | | | | | | Change-Id: I54533863c80933eed8f01de190bb7713f64f6999 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Merge two mini-functions for the hard coded listLaszlo Papp2013-11-241-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is done for the following reason: 1) Consistency with the unix backend of the QSerialPort class, where the serialPortLockFilePath free function is also like this. 2) There is no point in having a separate free function for initializing a variable when it is only used in one place. 3) It is less abstraction. 4) It is negligibly faster. 5) It is still a small enough free function, and naturally fits the one page maximum limit for a function which is the general recommendation in projects. 6) Last, but not least: It also makes the code shorter and more concise. Change-Id: Ie07f06521e11038bdd3cc504a56cadcf00e68269 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Eliminate the "canAppendToList" variable usageLaszlo Papp2013-11-241-15/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are problems with this variable: 1) It should have been called "isSerialPortValid" or something like that to be more precise abouts its functionality. 2) It should have had false value by default since we do not assume everything is correct by default, and exclude certain ones, but the other way around, logically. 3) Most importantly: It makes the code unnecessarily longer since the loop can be continued with the next iteration without the need to insert an invalid serial port and an interim variable. Tested the cenumerator example on Linux with udev using Qt 4 and then 5. There are no regressions found. Change-Id: I4f6bdce402f03eac696c0d2ce9448e59baedf56b Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | Remove the very bizarre whitespaces from inconsistent macro usagesLaszlo Papp2013-11-231-4/+4
|/ | | | | | | | | | b8af6f604cd86897c8a04825700892fd9970a616 introduced this for no any valid reason. There was no review back then, so any silly stuff like this could sneak in. Change-Id: I80c21e9f2a7c5eec3b126e8080132ca43a60f12b Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Add /dev/ttyO* to get the native serial port listed on Android with BeagleboardLaszlo Papp2013-11-091-0/+1
| | | | | | | This type of serial port seems to represent the OMAP serial ports. Change-Id: Ie4279cad96f68e618d24bbcd64da9cbc218a9937 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Unify the QString creation from udev return values (char*)Laszlo Papp2013-11-081-11/+7
| | | | | | Change-Id: Ic69fd0d62d3097685bc8c3e25a7d8f6c696d7e2a Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Define QStringLiteral when undefined (e.g. Qt 4)Laszlo Papp2013-11-061-29/+27
| | | | | | | | | | | | 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>
* Replace the home-grown QTtyLocker with QLockFileLaszlo Papp2013-11-061-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This can be more widely adopted later, and not just for the Linux backend. It would be more than a few-liner change for stable, so this change change is kept minimal (of course apart from the big file integration). The only big problem with QLockFile currently is that we cannot change the file name on the fly as it seems, just for construction. Even the copy constructor and assignment operators are private. It means the class currently seems to be non-eligible for QtSerialPort needs where it is necessary to change for open anytime, and be accessible by open/serial for the before and after read/write session for the same file name. Also, I had to get rid of the QTemporary file internals because we cannot have access to the internal engine with Qt 4. I also had to make a small thread class for the protected msleep in QThread for Qt 4. There was a small improvement for the hidden dependency problem with gethostname. That was also sent to QtCore proper. Also, the windows backend for the QLockFile class is not copied for simplicity. It would not be used as of now. There is also a short convenience around QLockFile established to handle system-wide lock file paths. There is also some error handling added if the lock directory paths are not readable or writable. This will end users identify the problems like on Android. Tested on Archlinux with Qt 4 and then 5. Task-number: QTBUG-34474 Change-Id: I7adf29527c01ad331d3eeff5ae4c5a4113bde083 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Add /dev/ttyHS(L)* to the hard coded uart list on UnixLaszlo Papp2013-11-011-0/+2
| | | | | | | | | | Some information can be found on the following link: http://www.anyclub.org/2012/05/8960-android-gsbi-uart-debug-tips.html Change-Id: Ie57d58f5a01c168ff9498694564e43e43c7919e3 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Add support for loading udev at run-timeLaszlo Papp2013-10-281-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | QtSerialPort is linked against udev by default if the development files can be detected on the system. The reason for this is that, it is more common to link against udev than loading it at run-time. People will usually use distribution packages where there cannot be inconsistency between different versions, and hence ABI breaks, etc. The relevant LINK_LIBUDEV variable will be set. This can be overridden by defining LOAD_LIBUDEV for qmake: qmake "DEFINES += LOAD_LIBUDEV" -r It is also worth noting that the common code is separated into a private header, and it can be included for either type of libudev usage. There is no need for its user to handle the compile-time linking or run-time loading separately on top of that. Task-number: QTBUG-34329 Change-Id: I45ffaaede2a74498587a6452fbe3fec7eaf83483 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Use sysfs on Linux when availableDenis Shienkov2013-09-221-102/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change is the continuation of the previous: * sha1: 4bdbbe4c87676ca94daae947ac5908d77966319b The previous operation was to use the nodes in the "/dev" hierarchy. The "sysfs" was only used for extending the information that cannot be obtained from "/dev", like manufacturer, description of the device, etc. This decision had a shortcoming of expansion of the list of filters in case of appearance the new device with the new name. Besides, the Linux kernel has a lot drivers, each of which provide a various names for an serial devices, so we can't know all these names. Now the sysfs is used directly, without filters. To search for devices we use an appropriate "/sys/class/tty" directory that contains all necessary info. Notes: * There are possible some regressions relating to enumeration of rfcomm, ircomm devices. Because this devices can belong to other subsystems which we do not process and skip at present. It needs to be checked and submitted the set of next patches to fix it. * If sysfs is not available, the fallback algorithm uses the "/dev" hierarchy by having a predefined device entry list. Tested on: * Fedora 19 Desktop Edition (64-bit) * Ubuntu 12.04.2 LTS (32-bit) with on-board (PnP) and pluggable (USB) devices using Qt4 and then Qt5. Change-Id: Ia242bb2ed81d17b6f826a187454bb9d2a12d40a9 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Merge branch 'stable' into devSergio Ahumada2013-09-061-2/+2
|\ | | | | | | Change-Id: Ie8f70b5101225453355a1eb6b0fdc3f3d8a34824
| * Linux: Are added the missed QLatin1Char into libudev implementationDenis Shienkov2013-08-241-2/+2
| | | | | | | | | | | | Change-Id: Ic125079bd9154f9094aaf2878c514eeac2753038 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Laszlo Papp <lpapp@kde.org>
* | Linux: Getting properties of USB devices if has no libudevDenis Shienkov2013-08-201-3/+68
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This decision is based on parse of contents of /sys directory. Many distros of Linux use /sys as a virtual file system to export data from the kernel to userspace applications. Thus this decision shall work only at those kernels in which are this feature is enabled at assembling. The initial path are received from the symlink "/sys/class/tty/<device name>", that points to the lowest kernel node with the device properties. For this path name is starting an analysis of matching to the keywords of subsystems (e.g. "pnp", "platform","usb" and so forth), which by implication characterize the type of the device. The device type is used to define a choice of further algorithm of passing each parent directory: * For "pnp" devices (standard onboard devices): The device info with empty properties is added directly to the resulting list. Because we still can not get desired properties for "pnp" devices. * For "platform" devices (pseudo terminals): Skip processing and don't add to the list. Because pseudo-ports aren't support by the library. * For "usb" devices: Pass each parental directory and look the "events" key file. From this file it is reading contents and to find in it the predetermined set of "magic" keywords. If all keywords are found, then we can be sure that current directory is the required. Contents of files "product", "manufacturer", "idVendor", "idProduct" is give requested properties of the device. * For other devices: Skip processing and don't add to the list. This decision was tested in ArchLinux x64 and Fedora 19 x64 with the onboard serial ports, USB PL2303 converter and USB modem ZTE MF180. Change-Id: I5a736a98656e8767b713af837f8b52557176c236 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Linux: Added enumeration of Motorola IMX serial portsDenis Shienkov2013-07-231-0/+1
| | | | | | | | | | | | | | For Embedded "Freescale i.MX Linux" platform is added the filter for the Motorola IMX serial ports. These serial ports has names like "/dev/ttymxc*", see kernel sources: * http://lxr.free-electrons.com/source/drivers/serial/imx.c?v=2.6.31 Task-number: QTBUG-32563 Change-Id: I97b33cdbc8f1a8ff72a171e52ddc10cc0f53b4a2 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Add further device filters on Linux without libudevDenis Shienkov2013-04-191-1/+3
| | | | | | | | | | | | | | Added: * ttyAMA filter for AMBA serial ports, e.g. see http://lxr.free-electrons.com/source/drivers/tty/serial/amba-pl011.c * ircomm filter for infrared serial devices, e.g. see http://www.tldp.org/HOWTO/html_single/Infrared-HOWTO/ Change-Id: I9e1cd04513a937f080978a7ecc7139a906de40f0 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
* 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-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove the QtSerialPort namespace define and hence namespace usageLaszlo Papp2013-02-071-4/+0
| | | | | | | | | | * This is for following the convention in the Qt Project with the rest. * This fixes examples and tests to build now as all of them are broken due to the regression. Change-Id: I3f4d64d97466520aea621da582a64a0d97e32136 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Rename the TtyLocker class to QTtyLocker as it gets to Qt scopeLaszlo Papp2013-02-071-2/+2
| | | | | Change-Id: I74b90ec2a6cb08a9bc75225e04995a3b05f2c6e9 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Fix the potential build breaks introduced by a previous commit (regression)Laszlo Papp2013-02-071-0/+4
| | | | | | | | | | | | | This is due to the fact the Qt namespace is not considered which is normally not a problem as it is empty by default. However, using something like "-qtnamespace MyNamespace" when configuring Qt will break the QtSerialPort build completely. This is intended to be a fix for the library, and the examples/tests will be fixed in a separate commit if necessary. Change-Id: Iecd24dc5135c3a9645910754589dfd8bf4942337 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Refactor certain variable names, remove useless comments and so forthLaszlo Papp2013-02-011-20/+20
| | | | | Change-Id: Id8af629c2b488050b8accd4c552e9b0ebf366e32 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Move the file scope variables to function scopeLaszlo Papp2013-01-311-6/+4
| | | | | | Change-Id: I5f706914af079e81c50bf0eb474737ee82f5cdd1 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Mark the static device name list const as it is not meant to be alteredLaszlo Papp2013-01-301-17/+11
| | | | | | Change-Id: I44166e412912490d97e6f7b10d8947517730900b Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* Make all the file renames and relevant changesLaszlo Papp2013-01-271-0/+264
"git log --follow /path/to/the/file/in/question" can be used, for instance, for the renamed files to get the whole history. Change-Id: I20da087ca88e2c179a6c3232772fa21575e0aa6a Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>