Changeset 846 for trunk/tools/runonphone/main.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/tools/runonphone/main.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 45 45 #include <QScopedPointer> 46 46 #include <QTimer> 47 #include <QFileInfo> 47 48 #include "symbianutils/trkutils.h" 48 49 #include "symbianutils/trkdevice.h" … … 51 52 #include "trksignalhandler.h" 52 53 #include "serenum.h" 53 54 void printUsage(QTextStream& outstream) 54 #include "ossignalconverter.h" 55 56 void printUsage(QTextStream& outstream, QString exeName) 55 57 { 56 outstream << "runtest [options] <program> [program arguments]" << endl 57 << "-s, --sis <file> specify sis file to install" << endl 58 << "-p, --portname <COMx> specify COM port to use by device name" << endl 59 << "-f, --portfriendlyname <substring> specify COM port to use by friendly name" << endl 60 << "-t, --timeout <milliseconds> terminate test if timeout occurs" << endl 61 << "-v, --verbose show debugging output" << endl 62 << "-q, --quiet hide progress messages" << endl 58 outstream << exeName << " [options] [program] [program arguments]" << endl 59 << "-s, --sis <file> specify sis file to install" << endl 60 << "-p, --portname <COMx> specify COM port to use by device name" << endl 61 << "-f, --portfriendlyname <substring> specify COM port to use by friendly name" << endl 62 << "-t, --timeout <milliseconds> terminate test if timeout occurs" << endl 63 << "-v, --verbose show debugging output" << endl 64 << "-q, --quiet hide progress messages" << endl 65 << "-d, --download <remote file> <local file> copy file from phone to PC after running test" << endl 66 << "--nocrashlog Don't capture call stack if test crashes" << endl 67 << "--crashlogpath <dir> Path to save crash logs (default=working dir)" << endl 63 68 << endl 64 << "USB COM ports can usually be autodetected" << endl; 69 << "USB COM ports can usually be autodetected, use -p or -f to force a specific port." << endl 70 << "If using System TRK, it is possible to copy the program directly to sys/bin on the phone." << endl 71 << "-s can be used with both System and Application TRK to install the program" << endl; 65 72 } 66 73 74 #define CHECK_PARAMETER_EXISTS if(!it.hasNext()) { printUsage(outstream, args[0]); return 1; } 67 75 int main(int argc, char *argv[]) 68 76 { … … 77 85 QTextStream outstream(stdout); 78 86 QTextStream errstream(stderr); 87 QString downloadRemoteFile; 88 QString downloadLocalFile; 79 89 int loglevel=1; 80 90 int timeout=0; 81 for (int i=1;i<args.size();i++) { 82 QString arg = args.at(i); 91 bool crashlog = true; 92 QString crashlogpath; 93 QListIterator<QString> it(args); 94 it.next(); //skip name of program 95 while (it.hasNext()) { 96 QString arg = it.next(); 97 83 98 if (arg.startsWith("-")) { 84 if (args.size() < i+2) { 85 errstream << "Command line missing argument parameters" << endl; 86 return 1; 87 } 88 QString param = args.at(i+1); 89 if(arg.compare("--portname", Qt::CaseSensitive) == 0 90 || arg.compare("-p", Qt::CaseSensitive) == 0) { 91 serialPortName = param; 92 i++; 93 } 94 else if(arg.compare("--portfriendlyname", Qt::CaseSensitive) == 0 95 || arg.compare("-f", Qt::CaseSensitive) == 0) { 96 serialPortFriendlyName = param; 97 i++; 98 } 99 else if(arg.compare("--sis", Qt::CaseSensitive) == 0 100 || arg.compare("-s", Qt::CaseSensitive) == 0) { 101 sisFile = param; 102 i++; 103 } 104 else if(arg.compare("--timeout", Qt::CaseSensitive) == 0 105 || arg.compare("-t", Qt::CaseSensitive) == 0) { 99 if (arg == "--portname" || arg == "-p") { 100 CHECK_PARAMETER_EXISTS 101 serialPortName = it.next(); 102 } 103 else if (arg == "--portfriendlyname" || arg == "-f") { 104 CHECK_PARAMETER_EXISTS 105 serialPortFriendlyName = it.next(); 106 } 107 else if (arg == "--sis" || arg == "-s") { 108 CHECK_PARAMETER_EXISTS 109 sisFile = it.next(); 110 if (!QFileInfo(sisFile).exists()) { 111 errstream << "Sis file (" << sisFile << ") doesn't exist" << endl; 112 return 1; 113 } 114 } 115 else if (arg == "--download" || arg == "-d") { 116 CHECK_PARAMETER_EXISTS 117 downloadRemoteFile = it.next(); 118 CHECK_PARAMETER_EXISTS 119 downloadLocalFile = it.next(); 120 } 121 else if (arg == "--timeout" || arg == "-t") { 122 CHECK_PARAMETER_EXISTS 106 123 bool ok; 107 timeout = param.toInt(&ok);124 timeout = it.next().toInt(&ok); 108 125 if (!ok) { 109 126 errstream << "Timeout must be specified in milliseconds" << endl; 110 127 return 1; 111 128 } 112 i++; 113 } 114 else if(arg.compare("--verbose", Qt::CaseSensitive) == 0 115 || arg.compare("-v", Qt::CaseSensitive) == 0) 129 } 130 else if (arg == "--verbose" || arg == "-v") 116 131 loglevel=2; 117 else if(arg.compare("--quiet", Qt::CaseSensitive) == 0 118 || arg.compare("-q", Qt::CaseSensitive) == 0) 132 else if (arg == "--quiet" || arg == "-q") 119 133 loglevel=0; 134 else if (arg == "--nocrashlog") 135 crashlog = false; 136 else if (arg == "--crashlogpath") { 137 CHECK_PARAMETER_EXISTS 138 crashlogpath = it.next(); 139 } 120 140 else 121 141 errstream << "unknown command line option " << arg << endl; 122 142 } else { 123 143 exeFile = arg; 124 i++; 125 for(;i<args.size();i++) { 126 cmdLine.append(args.at(i)); 144 while(it.hasNext()) { 145 cmdLine.append(it.next()); 127 146 } 128 147 } 129 148 } 130 149 131 if(exeFile.isEmpty()) { 132 printUsage(outstream); 150 if (exeFile.isEmpty() && sisFile.isEmpty() && 151 (downloadLocalFile.isEmpty() || downloadRemoteFile.isEmpty())) { 152 printUsage(outstream, args[0]); 133 153 return 1; 134 154 } … … 137 157 if (loglevel > 0) 138 158 outstream << "Detecting serial ports" << endl; 139 QList <SerialPortId> ports = enumerateSerialPorts(); 140 foreach(SerialPortId id, ports) { 159 foreach (const SerialPortId &id, enumerateSerialPorts(loglevel)) { 141 160 if (loglevel > 0) 142 161 outstream << "Port Name: " << id.portName << ", " 143 162 << "Friendly Name:" << id.friendlyName << endl; 144 if (serialPortName.isEmpty()) { 145 if (!id.friendlyName.isEmpty() 146 && serialPortFriendlyName.isEmpty() 147 && (id.friendlyName.contains("symbian", Qt::CaseInsensitive) 148 || id.friendlyName.contains("s60", Qt::CaseInsensitive) 149 || id.friendlyName.contains("nokia", Qt::CaseInsensitive))) 150 serialPortName = id.portName; 151 else if (!id.friendlyName.isEmpty() 152 && !serialPortFriendlyName.isEmpty() 153 && id.friendlyName.contains(serialPortFriendlyName)) 154 serialPortName = id.portName; 163 if (!id.friendlyName.isEmpty() 164 && serialPortFriendlyName.isEmpty() 165 && (id.friendlyName.contains("symbian", Qt::CaseInsensitive) 166 || id.friendlyName.contains("s60", Qt::CaseInsensitive) 167 || id.friendlyName.contains("nokia", Qt::CaseInsensitive))) { 168 serialPortName = id.portName; 169 break; 170 } else if (!id.friendlyName.isEmpty() 171 && !serialPortFriendlyName.isEmpty() 172 && id.friendlyName.contains(serialPortFriendlyName)) { 173 serialPortName = id.portName; 174 break; 155 175 } 156 176 } … … 162 182 163 183 QScopedPointer<trk::Launcher> launcher; 164 165 if (sisFile.isEmpty()) { 166 launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyRun)); 167 launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + exeFile); 168 errstream << "System TRK required to copy EXE, use --sis if using Application TRK" << endl; 169 } else { 170 launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyInstallRun)); 171 launcher->addStartupActions(trk::Launcher::ActionInstall); 184 launcher.reset(new trk::Launcher(trk::Launcher::ActionPingOnly)); 185 QFileInfo info(exeFile); 186 if (!sisFile.isEmpty()) { 187 launcher->addStartupActions(trk::Launcher::ActionCopyInstall); 172 188 launcher->setCopyFileName(sisFile, "c:\\data\\testtemp.sis"); 173 189 launcher->setInstallFileName("c:\\data\\testtemp.sis"); 190 } 191 else if (info.exists()) { 192 launcher->addStartupActions(trk::Launcher::ActionCopy); 193 launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + info.fileName()); 194 } 195 if (!exeFile.isEmpty()) { 196 launcher->addStartupActions(trk::Launcher::ActionRun); 197 launcher->setFileName(QString("c:\\sys\\bin\\") + info.fileName()); 198 launcher->setCommandLineArgs(cmdLine); 199 } 200 if (!downloadRemoteFile.isEmpty() && !downloadLocalFile.isEmpty()) { 201 launcher->addStartupActions(trk::Launcher::ActionDownload); 202 launcher->setDownloadFileName(downloadRemoteFile, downloadLocalFile); 174 203 } 175 204 if (loglevel > 0) … … 177 206 launcher->setTrkServerName(serialPortName); 178 207 179 launcher->setFileName(QString("c:\\sys\\bin\\") + exeFile);180 launcher->setCommandLineArgs(cmdLine);181 182 208 if (loglevel > 1) 183 209 launcher->setVerbose(1); … … 185 211 TrkSignalHandler handler; 186 212 handler.setLogLevel(loglevel); 213 handler.setCrashLogging(crashlog); 214 handler.setCrashLogPath(crashlogpath); 187 215 188 216 QObject::connect(launcher.data(), SIGNAL(copyingStarted()), &handler, SLOT(copyingStarted())); … … 201 229 QObject::connect(launcher.data(), SIGNAL(stateChanged(int)), &handler, SLOT(stateChanged(int))); 202 230 QObject::connect(launcher.data(), SIGNAL(processStopped(uint,uint,uint,QString)), &handler, SLOT(stopped(uint,uint,uint,QString))); 231 QObject::connect(launcher.data(), SIGNAL(libraryLoaded(trk::Library)), &handler, SLOT(libraryLoaded(trk::Library))); 232 QObject::connect(launcher.data(), SIGNAL(libraryUnloaded(trk::Library)), &handler, SLOT(libraryUnloaded(trk::Library))); 233 QObject::connect(launcher.data(), SIGNAL(registersAndCallStackReadComplete(const QList<uint> &,const QByteArray &)), &handler, SLOT(registersAndCallStackReadComplete(const QList<uint> &,const QByteArray &))); 203 234 QObject::connect(&handler, SIGNAL(resume(uint,uint)), launcher.data(), SLOT(resumeProcess(uint,uint))); 204 235 QObject::connect(&handler, SIGNAL(terminate()), launcher.data(), SLOT(terminate())); 236 QObject::connect(&handler, SIGNAL(getRegistersAndCallStack(uint,uint)), launcher.data(), SLOT(getRegistersAndCallStack(uint,uint))); 205 237 QObject::connect(launcher.data(), SIGNAL(finished()), &handler, SLOT(finished())); 238 239 QObject::connect(OsSignalConverter::instance(), SIGNAL(terminate()), launcher.data(), SLOT(terminate()), Qt::QueuedConnection); 206 240 207 241 QTimer timer;
Note:
See TracChangeset
for help on using the changeset viewer.