diff options
-rw-r--r-- | tools/runonphone/codasignalhandler.cpp | 10 | ||||
-rw-r--r-- | tools/runonphone/main.cpp | 31 | ||||
-rw-r--r-- | tools/runonphone/symbianutils/symbiandevicemanager.cpp | 3 |
3 files changed, 36 insertions, 8 deletions
diff --git a/tools/runonphone/codasignalhandler.cpp b/tools/runonphone/codasignalhandler.cpp index 2de6fbc..1df7834 100644 --- a/tools/runonphone/codasignalhandler.cpp +++ b/tools/runonphone/codasignalhandler.cpp @@ -188,10 +188,15 @@ int CodaSignalHandler::run() connect(this, SIGNAL(done()), this, SLOT(finished())); d->codaDevice->sendSerialPing(false); - if (d->timeout > 0) - QTimer::singleShot(d->timeout, this, SLOT(timeout())); + QTimer timer; + if (d->timeout > 0) { + connect(&timer, SIGNAL(timeout()), this, SLOT(timeout())); + timer.setSingleShot(true); + timer.start(d->timeout); + } d->eventLoop = new QEventLoop(); d->eventLoop->exec(); + timer.stop(); int result = d->result; reportMessage(tr("Done.")); @@ -199,7 +204,6 @@ int CodaSignalHandler::run() disconnect(d->codaDevice.data(), 0, this, 0); SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(d->codaDevice); - QCoreApplication::quit(); return result; } diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp index 39fa983..6dd53fc 100644 --- a/tools/runonphone/main.cpp +++ b/tools/runonphone/main.cpp @@ -70,7 +70,8 @@ void printUsage(QTextStream& outstream, QString exeName) << "-T, --tempfile <remote file> specify temporary sis file name" << endl << "--nocrashlog Don't capture call stack if test crashes" << endl << "--crashlogpath <dir> Path to save crash logs (default=working dir)" << endl - << "--coda Use CODA instead of TRK (default agent)" << endl + << "--coda Use CODA instead of detecting the debug agent" << endl + << "--trk Use TRK instead of detecting the debug agent" << endl << endl << "USB COM ports can usually be autodetected, use -p or -f to force a specific port." << endl << "TRK is the default debugging agent, use --coda option when using CODA instead of TRK." << endl @@ -99,7 +100,7 @@ int main(int argc, char *argv[]) int loglevel=1; int timeout=0; bool crashlog = true; - bool coda = false; + enum {AgentUnknown, AgentCoda, AgentTRK} debugAgent = AgentUnknown; QString crashlogpath; QListIterator<QString> it(args); it.next(); //skip name of program @@ -154,7 +155,9 @@ int main(int argc, char *argv[]) } } else if (arg == "--coda") - coda = true; + debugAgent = AgentCoda; + else if (arg == "--trk") + debugAgent = AgentTRK; else if (arg == "--tempfile" || arg == "-T") { CHECK_PARAMETER_EXISTS dstName = it.next(); @@ -225,7 +228,24 @@ int main(int argc, char *argv[]) QFileInfo info(exeFile); QFileInfo uploadInfo(uploadLocalFile); - if (coda) { + if (debugAgent == AgentUnknown) { + outstream << "detecting debug agent..." << endl; + CodaSignalHandler codaDetector; + //auto detect agent + codaDetector.setSerialPortName(serialPortName); + codaDetector.setLogLevel(loglevel); + codaDetector.setActionType(ActionPingOnly); + codaDetector.setTimeout(1000); + if (!codaDetector.run()) { + debugAgent = AgentCoda; + outstream << " - Coda is found" << endl; + } else { + debugAgent = AgentTRK; + outstream << " - Coda is not found, defaulting to TRK" << endl; + } + } + + if (debugAgent == AgentCoda) { codaHandler.setSerialPortName(serialPortName); codaHandler.setLogLevel(loglevel); @@ -257,7 +277,8 @@ int main(int argc, char *argv[]) return codaHandler.run(); } else { - launcher.reset(new trk::Launcher(trk::Launcher::ActionPingOnly)); + launcher.reset(new trk::Launcher(trk::Launcher::ActionPingOnly, + SymbianUtils::SymbianDeviceManager::instance()->acquireDevice(serialPortName))); QStringList srcNames, dstNames; if (!sisFile.isEmpty()) { launcher->addStartupActions(trk::Launcher::ActionCopyInstall); diff --git a/tools/runonphone/symbianutils/symbiandevicemanager.cpp b/tools/runonphone/symbianutils/symbiandevicemanager.cpp index e8d0b5e..0b7f581 100644 --- a/tools/runonphone/symbianutils/symbiandevicemanager.cpp +++ b/tools/runonphone/symbianutils/symbiandevicemanager.cpp @@ -183,6 +183,9 @@ SymbianDevice::TrkDevicePtr SymbianDevice::acquireDevice() << "acquired: " << m_data->deviceAcquired << " open: " << isOpen(); if (isNull() || m_data->deviceAcquired) return TrkDevicePtr(); + //if port was opened for coda (but is not acquired) then close it first. + if (m_data->codaDevice) + m_data->codaDevice->device()->close(); if (m_data->device.isNull()) { m_data->device = TrkDevicePtr(new trk::TrkDevice); m_data->device->setPort(m_data->portName); |