summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-09-22 14:57:31 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2011-10-04 12:11:44 (GMT)
commitc9ff25ec9ca7a9c00e4aea7b7ff23e34064a2a1f (patch)
treee122acc53204cf3a3e5fffa7d72a90bcbdd3cf7d
parentd22211b970dbab1382c97ef8259c91adc2b8a4de (diff)
downloadQt-c9ff25ec9ca7a9c00e4aea7b7ff23e34064a2a1f.zip
Qt-c9ff25ec9ca7a9c00e4aea7b7ff23e34064a2a1f.tar.gz
Qt-c9ff25ec9ca7a9c00e4aea7b7ff23e34064a2a1f.tar.bz2
runonphone - Implement CODA autodetection
If runonphone is executed without specifying the debug agent, then it will attempt to autodetect it by sending a CODA ping to the USB port. If there is a reply within 1 second, then CODA mode is used. If not, then TRK mode is used. TRK drops unrecognised messages, so the CODA ping is ignored and initialisation starts normally when the TRK ping is sent. Autodetect can be skipped by using the --coda or --trk arguments on the command line to force use of a specific debug agent. Reviewed-By: mread
-rw-r--r--tools/runonphone/codasignalhandler.cpp10
-rw-r--r--tools/runonphone/main.cpp31
-rw-r--r--tools/runonphone/symbianutils/symbiandevicemanager.cpp3
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);