summaryrefslogtreecommitdiffstats
path: root/qdb
Commit message (Collapse)AuthorAgeFilesLines
* Build QDB with CMakeLassi Lehikoinen2021-05-284-79/+36
| | | | | | | | Also some Qt6 related changes. Task-number: QTBUG-86118 Change-Id: Id5bdf646071fcc10415945dfae73b2c66e53f7a7 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Only deliver warnings and higher to clientsKari Oikarinen2018-03-072-4/+4
| | | | | | | | | Unfortunately on Windows there's regularly failures to get config descriptors for some devices. That's something I want in log files even if debug messages are disabled, but it happens too often on Windows to show to users. Change-Id: Ib6f1205074b8b8386175fda0ac1a91344d98ef8c Reviewed-by: Rainer Keller <Rainer.Keller@qt.io>
* Add commands for showing server messagesRainer Keller2018-02-137-1/+153
| | | | | | | | | Some commands allow users to retrieve server messages on the command line. Change-Id: Id9d69c6c9a300cfefadde58321e301eb827e04ce Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io> Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Refactor duplicated error handlerRainer Keller2018-02-122-31/+8
| | | | | | | | | | | For extensions of qdb the default error handler (start server and try again) which was used for askDevices and watchDevices is used very often. In order to not duplicate this function for every additional command the same function is reused. Change-Id: I469ccf6955c5590e295d9182a80cdfb3a4dfbcd0 Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io> Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Store log messages in a bufferRainer Keller2018-02-122-0/+54
| | | | | | | | | For later usage important log messages are stored in a buffer. A logging class will notify listeners about new messages in the buffer. Change-Id: If892c050ffe1e929d9ccf08880db26d98fdb4ed9 Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io> Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Make error conditions more clearRainer Keller2018-02-124-10/+10
| | | | | | Change-Id: I5b27907883ecebd7572b3b7e400179a240199f8f Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io> Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Remove duplicated codeRainer Keller2018-02-082-34/+22
| | | | | | Change-Id: I26c4361900ebfa5691a8ce77ab4226e87cc07219 Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io> Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Show proper error messageRainer Keller2017-08-312-4/+16
| | | | | | | | | End users will not know what LIBUSB_ERROR_ACCESS means. Instead give a hint to read the manual because most probably they forgot to setup the udev rule. Change-Id: I8237d55dfe64976f4d4a279af31dfa743e8cc29c Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Add -f flag to ignore errorsKari Oikarinen2017-06-063-4/+21
| | | | | | | | | If -f is given with a client command, return code is always 0 even if there were errors. This allows using stop-server even when it might fail due to no server being available. Change-Id: I0222b918510ffc47e804da381cfe21f83aa7dfef Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Add command for starting the serverKari Oikarinen2017-05-303-1/+10
| | | | | | | | Existing `qdb server` runs the server on the foreground, which is different. Change-Id: Id4b9cf4b28e856e3dac93d03533a9a7d6d2874b9 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Fix logging raw messages by defaultKari Oikarinen2017-05-301-2/+2
| | | | | | | | | | | The filter rule handling was not updated when the logging categories were renamed to include qdb. This caused the raw messages to be logged always. Amends 2750685b372b78330a9139a98d084bb7a60e367e. Change-Id: I43d37ea9f81f15efce4eefc4b04c74006ee72348 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Relicense to Commercial + GPLv3v1.0.0Kari Oikarinen2017-05-0241-320/+648
| | | | | | Task-number: QTBUG-60434 Change-Id: I73740ae66ab565f32df25fa2c98d5cb6c019d666 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Reuse network configurations set on device if possibleKari Oikarinen2017-05-025-9/+71
| | | | | | | | | | | | | | | | | | | | Don't allow reconfiguring the network on the device without a reset in between. It wouldn't lead to a working configuration, since the host has already gotten an IP from the existing configuration at this point. But if the already configured network happens to be free, use it. This allows devices to work keeping the same address even if host qdb is restarted. This doesn't guard against the possibility that the existing configuration conflicts with a network already in place. But telling apart that situation would be too difficult: How to tell whether the network is the device or something else? In that case the user just has to replug the device. Then it will pick an unused subnet. Task-number: QTBUG-59451 Change-Id: I10c948713736dd79442265ac6a590b8a7cf8345a Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Keep track of used subnetsKari Oikarinen2017-05-027-26/+146
| | | | | | | | | | | | | | | | | If we don't keep track of them, inserting two devices at the same time can lead to both picking the same candidate. This happens if the host does not get an IP in time and thus the network is still free from host perspective as the second call looks for the subnet to use. The tracking is done by UsbDevice and DeviceInformation keeping a SubnetReservation. The SubnetReservation is gotten from findUnusedSubnet(), which uses a SubnetPool singleton to keep track of them. When the SubnetReservations are destructed, they call SubnetPool to free the subnet the reserved. Task-number: QTBUG-59449 Change-Id: I4b28ade4fa7a5660bd699882398facafafc9d795 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Configure DHCP server on device before handshakeKari Oikarinen2017-05-0211-523/+418
| | | | | | | | | | | | | | | | | | | | | | | Change the procedure for a newly detected device: First configure the network and then do the handshake for the device information. The configuring the network part is new and incorporates a new service NetworkConfigurationService. On the device it relies on a script b2qt-gadget-network.sh (or as specified in a command line parameter) which does the actual configuring of the USB network interface. The network configuration to apply is selected from a list of hardcoded candidates from the private use IPv4 ranges available. They are checked against the existing networks on the host and an unused one is picked. On the device the USB interface is configured to use this network and to act as a DHCP server for it. Host will then pick up an IP from this DHCP server automatically. Previous configuration of the host network is thus not necessary and is removed. Task-number: QTBUG-58614 Change-Id: I6a4ed34ef7d5cba9e55e6fa4f07725bb3c00d795 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Store fetched device in DeviceInformationFetcherKari Oikarinen2017-03-284-77/+43
| | | | | | | | | Rather than keeping that state in DeviceManager. DeviceManager can then independently start fetching for new devices instead of keeping a queue for them. Change-Id: I0db131a84eec94aef473fb1a7bca2aa20be3d6d9 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Remove unused HandshakeService::{close,hasStream}Kari Oikarinen2017-03-272-13/+0
| | | | | Change-Id: Ia12faec41ef2bff6b2238848babaf68deea2a822 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Strip non-ASCII characters from USB serial numbersKari Oikarinen2017-03-271-0/+3
| | | | | | | | | | | | | This works around getting the correct serial number prepended with U+033A (COMBINING INVERTED BRIDGE BELOW). That character does not seem to be present when the serial is set up in the qdbd-init.sh script and it is not read by HandshakeExecutor either. This assumes serial numbers shouldn't have non-ASCII and don't have question marks. Change-Id: I133a76020b2ea42a12338485a45fce2679895845 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Add ConnectionPool for ConnectionsKari Oikarinen2017-03-248-22/+119
| | | | | | | | | | | | Rather than directly creating the Connection inside DeviceInformationFetcher, get it from a ConnectionPool that gives an existing connection if there already is one to the device. Change connections to close upon destruction. They will be closed once last shared pointer gotten from ConnectionPool destructs. Change-Id: I44d4b11d71f8b3c5488fdb52266608bfee69c644 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Give up after 5 errors in UsbConnectionReaderKari Oikarinen2017-03-241-1/+1
| | | | | | | | | | | | Previously a zero-length read was raised as a sign of error every 5 errors. However this meant reams of errors and invalid messages being sent if a Connection was active to the device while it was unplugged. The first invalid message is sufficient, since Connection will reset in response. Change-Id: I44cd5e90edf84aee1680f1852b637c0c2b590b2e Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Close streams when resetting ConnectionKari Oikarinen2017-03-241-1/+6
| | | | | | | | | | The streams were only destroyed, not closed. This meant that ongoing Services would have a dangling pointer. Also only reset the connection once in response to Invalid messages. Change-Id: I35ccb149986a76ee9abf9182923ee40bd5174373 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Fix installation on WindowsKari Oikarinen2017-03-101-2/+3
| | | | | | | | | | | | | | | | | | | | | | | Install targets were gated on unix, so nothing intended was actually installed on Windows. One would be excused to think that there's no need to install a static library that has already been linked with the executable. However, the tests streamtest and servicetest link against the library as well. In Coin they are built in a separate machine and only have the source and the installed components available. Thus not installing the static library means that those tests will fail to find the library. Via qt_parts.prf we included qt_example_installs.prf which created an nmake target that attempted to install the qmake files used in the project. The destination path for installing them was malformed, since it was created by concatenating two absolute Windows paths. Because the path contained ':', it led to an error message "The filename, directory name, or volume label syntax is incorrect.". Change-Id: Idab40e3647de863a7b8ab47ff9b42b8990ed52ae Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Make libqdb a static libraryKari Oikarinen2017-03-101-21/+3
| | | | | | | | | | | | Previously it was a shared library, but the symbols were not exported properly, which meant that trying to use them lead to linker failures when using MSVC. This was previously worked around by including the files a second time, so remove those workarounds. Change-Id: Ieafd066c5a3924573cd5e6e397a0e544a35564b3 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Use libusb from env variable LIBUSB_PATH on WindowsKari Oikarinen2017-03-101-8/+1
| | | | | | | | | Some places were setting directly the contents of LIBS, which overwrote the libusb configuration, so instead append in those places. (And all the other places for consistency.) Change-Id: I8177a863a8b866f3e19fb5207e73082ea86352c5 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Add version field to JSON messages on the hostKari Oikarinen2016-12-224-101/+150
| | | | | | | | This allows proper errors if mismatching versions of client and hostserver are running. Change-Id: I4b13e52d6b410cedc8a2a99ae94be77082b113da Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Downgrade failure to fetch config descriptor to a warningKari Oikarinen2016-12-221-10/+16
| | | | | | | | | | | | libusb may also access devices other than QDB devices and at least on my Windows machine fetching the USB config descriptor for two of those fails. Those devices will be ignored. This case would only be critical if it happened to a QDB device, so warning level seems appropriate. This still means warning for each such device on every polling interval. Change-Id: I0ea36206f275296bde18ea66e3519333b73d6670 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Handle host-device version mismatches forward-compatiblyKari Oikarinen2016-12-224-11/+85
| | | | | | | | | There is no support for multiple versions, but the behavior changes in this commit should allow adding that in the future. Device responds with a new Refuse message, if it does not support the requested version. Change-Id: I8a747654edb1c6efab485808b2692cd9689bd100 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Add --version optionKari Oikarinen2016-11-242-0/+4
| | | | | | | | | | | | | | | Derive the version information with git-describe. It will use tags (once they exist) as a reference, but always includes (an abbreviated version) of the SHA1 so that finding the exact version is easy. Also show the used Qt version. A caveat is that since qmake is used, version is only updated after qmake is run and mains are compiled. This should not be a problem for real releases, since they will be built clean. Change-Id: I59e32f99c30a957d624eff0cf04a927328a08212 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Fix build error with GCC 4.8Kari Oikarinen2016-11-231-2/+1
| | | | | | | | Uniform initialization bug. Change-Id: I74d33a81124f32413d4a2080d29e718055ea9f34 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Categorize loggingKari Oikarinen2016-11-2315-117/+148
| | | | | | | | Also use qFormatLogMessage so that QT_MESSAGE_PATTERN is taken into account in host server's own log message handler. Change-Id: I2ae6f70021cbe1ce4cd31ed599bbcc5035081b12 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Add command for watching for plugged and unplugged devicesKari Oikarinen2016-11-228-50/+305
| | | | | | | | A new qdb subcommand `qdb watch-devices` gives a stream of new device information and notifications about disconnected devices. Change-Id: Ib79546e11360907905f721c74e2f623960899423 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Allow concurrent clients in the host serverKari Oikarinen2016-11-225-79/+214
| | | | | | | | Previously only one client at a time could connect via QLocalSocket to the host server. Now a HostServlet is created to serve each client. Change-Id: I885e068495d505676d5dcb7556b507efb642074c Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Handle USB reading errors betterKari Oikarinen2016-11-217-21/+46
| | | | | | | | | Previously reading errors in UsbConnection were not propagated further up the stack. Single errors are still not, since there has been some (apparently harmless) cases of that. Change-Id: Iba04fc4d3bcda9902c74b81f439d1fa7d22d1a92 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Start host server automatically from qdbKari Oikarinen2016-11-219-23/+306
| | | | | | | | | | | Log to a file from the host server process. This can be prevented by setting the environment variable QDB_LOGGING_TO_CONSOLE=1. Add `qdb stop-server` for shutting down a host server process. Task-number: QTBUG-56070 Change-Id: Ie6455c7a2517df90a3e7c42f0256cbbdd31b6cff Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Handle plugged and unplugged USB devicesKari Oikarinen2016-11-0720-87/+1152
| | | | | | | | | | | | | | | | | | Looking for inserted and removed devices is done by polling once a second. libusb hotplug events are not used since they are not supported on Windows and not available in the libusb version in RHEL 7.2. If the IP address is not available for the device on the first check, the device will be checked again after a short delay until the information is complete. In the meanwhile the incomplete information is exposed to the client when asked. Parts that use libusb were moved from libqdb to the host part, since they are only used on the host. Task-number: QTBUG-56067 Change-Id: I0cfbd3659001982609a7d4a77cb1266a7dc6ce8c Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Split host QDB into client and server partsKari Oikarinen2016-11-0718-0/+1836
The two parts live in the same qdb binary. They communicate over QLocalSocket. Other users of host QDB functionality (like QtC QDB plugin) are intended to communicate over the local socket also. For now the server only lists the devices when asked for by the client. It can also handle only one client and one request at the same time. Only listing the devices, getting information from them and configuring the host network are necessary according to the current plans for QDB. Hence file transfer and running processes on the device were not converted to new architecture and are removed. Task-number: QTBUG-56067 Change-Id: I1a49d346c755ef00e332c4fcbed2352486728e6a Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>