Changeset 846 for trunk/tools/runonphone/symbianutils
- Timestamp:
- May 5, 2011, 5:36:53 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
- 6 copied
-
. (modified) (1 prop)
-
tools/runonphone/symbianutils/bluetoothlistener.cpp (modified) (1 diff)
-
tools/runonphone/symbianutils/bluetoothlistener.h (modified) (1 diff)
-
tools/runonphone/symbianutils/bluetoothlistener_gui.cpp (modified) (1 diff)
-
tools/runonphone/symbianutils/bluetoothlistener_gui.h (modified) (1 diff)
-
tools/runonphone/symbianutils/callback.h (modified) (1 diff)
-
tools/runonphone/symbianutils/communicationstarter.cpp (modified) (1 diff)
-
tools/runonphone/symbianutils/communicationstarter.h (modified) (1 diff)
-
tools/runonphone/symbianutils/json.cpp (copied) (copied from branches/vendor/nokia/qt/4.7.2/tools/runonphone/symbianutils/json.cpp )
-
tools/runonphone/symbianutils/json.h (copied) (copied from branches/vendor/nokia/qt/4.7.2/tools/runonphone/symbianutils/json.h )
-
tools/runonphone/symbianutils/launcher.cpp (modified) (29 diffs)
-
tools/runonphone/symbianutils/launcher.h (modified) (9 diffs)
-
tools/runonphone/symbianutils/symbiandevicemanager.cpp (modified) (19 diffs)
-
tools/runonphone/symbianutils/symbiandevicemanager.h (modified) (10 diffs)
-
tools/runonphone/symbianutils/symbianutils.pri (modified) (3 diffs)
-
tools/runonphone/symbianutils/symbianutils_global.h (modified) (1 diff)
-
tools/runonphone/symbianutils/tcftrkdevice.cpp (copied) (copied from branches/vendor/nokia/qt/4.7.2/tools/runonphone/symbianutils/tcftrkdevice.cpp )
-
tools/runonphone/symbianutils/tcftrkdevice.h (copied) (copied from branches/vendor/nokia/qt/4.7.2/tools/runonphone/symbianutils/tcftrkdevice.h )
-
tools/runonphone/symbianutils/tcftrkmessage.cpp (copied) (copied from branches/vendor/nokia/qt/4.7.2/tools/runonphone/symbianutils/tcftrkmessage.cpp )
-
tools/runonphone/symbianutils/tcftrkmessage.h (copied) (copied from branches/vendor/nokia/qt/4.7.2/tools/runonphone/symbianutils/tcftrkmessage.h )
-
tools/runonphone/symbianutils/trkdevice.cpp (modified) (29 diffs)
-
tools/runonphone/symbianutils/trkdevice.h (modified) (3 diffs)
-
tools/runonphone/symbianutils/trkutils.cpp (modified) (12 diffs)
-
tools/runonphone/symbianutils/trkutils.h (modified) (10 diffs)
-
tools/runonphone/symbianutils/trkutils_p.h (modified) (2 diffs)
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/symbianutils/bluetoothlistener.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/tools/runonphone/symbianutils/bluetoothlistener.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/tools/runonphone/symbianutils/bluetoothlistener_gui.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/tools/runonphone/symbianutils/bluetoothlistener_gui.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/tools/runonphone/symbianutils/callback.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/tools/runonphone/symbianutils/communicationstarter.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/tools/runonphone/symbianutils/communicationstarter.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/tools/runonphone/symbianutils/launcher.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 45 45 #include "trkdevice.h" 46 46 #include "bluetoothlistener.h" 47 47 48 48 49 #include <QtCore/QTimer> … … 54 55 #include <QtCore/QScopedPointer> 55 56 57 58 56 59 namespace trk { 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 57 87 58 88 struct LauncherPrivate { … … 62 92 uint copyFileHandle; 63 93 QScopedPointer<QByteArray> data; 64 int position; 94 qint64 position; 95 QScopedPointer<QFile> localFile; 65 96 }; 66 97 … … 76 107 77 108 CopyState m_copyState; 109 78 110 QString m_fileName; 79 111 QStringList m_commandLineArgs; … … 82 114 Launcher::Actions m_startupActions; 83 115 bool m_closeDevice; 116 84 117 }; 85 118 … … 101 134 { 102 135 d->m_startupActions = startupActions; 103 connect(d->m_device.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult))); 104 connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close())); 136 connect(d->m_device.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult))); 105 137 } 106 138 107 139 Launcher::~Launcher() 108 140 { 141 142 143 144 109 145 logMessage("Shutting down.\n"); 110 146 delete d; … … 155 191 } 156 192 193 194 195 196 197 198 157 199 void Launcher::setInstallFileName(const QString &name) 158 200 { … … 189 231 { 190 232 errorMessage->clear(); 233 191 234 if (d->m_verbose) { 192 const QString msg = QString::fromLatin1("Port=%1 Executable=%2 Arguments=%3 Package=%4 Remote Package=%5 Install file=%6") 193 .arg(trkServerName(), d->m_fileName, 194 d->m_commandLineArgs.join(QString(QLatin1Char(' '))), 195 d->m_copyState.sourceFileName, d->m_copyState.destinationFileName, d->m_installFileName); 235 QString msg; 236 QTextStream str(&msg); 237 str.setIntegerBase(16); 238 str << "Actions=0x" << d->m_startupActions; 239 str.setIntegerBase(10); 240 str << " Port=" << trkServerName(); 241 if (!d->m_fileName.isEmpty()) 242 str << " Executable=" << d->m_fileName; 243 if (!d->m_commandLineArgs.isEmpty()) 244 str << " Arguments= " << d->m_commandLineArgs.join(QString(QLatin1Char(' '))); 245 if (!d->m_copyState.sourceFileName.isEmpty()) 246 str << " Package/Source=" << d->m_copyState.sourceFileName; 247 if (!d->m_copyState.destinationFileName.isEmpty()) 248 str << " Remote Package/Destination=" << d->m_copyState.destinationFileName; 249 if (!d->m_downloadState.sourceFileName.isEmpty()) 250 str << " Source=" << d->m_downloadState.sourceFileName; 251 if (!d->m_downloadState.destinationFileName.isEmpty()) 252 str << " Destination=" << d->m_downloadState.destinationFileName; 253 if (!d->m_installFileName.isEmpty()) 254 str << " Install file=" << d->m_installFileName; 196 255 logMessage(msg); 197 256 } … … 215 274 if (!d->m_device->isOpen() && !d->m_device->open(errorMessage)) 216 275 return false; 217 if (d->m_closeDevice) {218 connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close()));219 } else {220 disconnect(this, SIGNAL(finished()), d->m_device.data(), 0);221 }222 276 setState(Connecting); 223 277 // Set up the temporary 'waiting' state if we do not get immediate connection … … 253 307 else if (d->m_startupActions & ActionRun) 254 308 startInferiorIfNeeded(); 309 310 255 311 } 256 312 … … 265 321 if (d->m_verbose) 266 322 qDebug() << "LAUNCHER: " << qPrintable(msg); 323 324 325 326 327 328 329 267 330 } 268 331 … … 288 351 case WaitingForTrk: 289 352 setState(Disconnected); 290 emit finished();353 inished(); 291 354 break; 292 355 } … … 332 395 QByteArray str = result.toString().toUtf8(); 333 396 if (result.isDebugOutput) { // handle application output 334 logMessage("APPLICATION OUTPUT: " + result.data); 335 emit applicationOutputReceived(result.data); 397 QString msg; 398 if (result.multiplex == MuxTextTrace) { 399 if (result.data.length() > 8) { 400 quint64 timestamp = extractInt64(result.data) & 0x0FFFFFFFFFFFFFFFULL; 401 quint64 secs = timestamp / 1000000000; 402 quint64 ns = timestamp % 1000000000; 403 msg = QString("[%1.%2] %3").arg(secs).arg(ns).arg(QString(result.data.mid(8))); 404 logMessage("TEXT TRACE: " + msg); 405 } 406 } else { 407 logMessage("APPLICATION OUTPUT: " + stringFromArray(result.data)); 408 msg = result.data; 409 } 410 msg.replace("\r\n", "\n"); 411 if(!msg.endsWith('\n')) msg.append('\n'); 412 emit applicationOutputReceived(msg); 336 413 return; 337 414 } … … 369 446 // target->host OS notification 370 447 case TrkNotifyCreated: { // Notify Created 371 /*372 const char *data = result.data.data();373 byte error = result.data.at(0);374 byte type = result.data.at(1); // type: 1 byte; for dll item, this value is 2.375 uint pid = extractInt(data + 2); // ProcessID: 4 bytes;376 uint tid = extractInt(data + 6); //threadID: 4 bytes377 uint codeseg = extractInt(data + 10); //code address: 4 bytes; code base address for the library378 uint dataseg = extractInt(data + 14); //data address: 4 bytes; data base address for the library379 uint len = extractShort(data + 18); //length: 2 bytes; length of the library name string to follow380 QByteArray name = result.data.mid(20, len); // name: library name381 382 logMessage(prefix + "NOTE: LIBRARY LOAD: " + str);383 logMessage(prefix + "TOKEN: " + result.token);384 logMessage(prefix + "ERROR: " + int(error));385 logMessage(prefix + "TYPE: " + int(type));386 logMessage(prefix + "PID: " + pid);387 logMessage(prefix + "TID: " + tid);388 logMessage(prefix + "CODE: " + codeseg);389 logMessage(prefix + "DATA: " + dataseg);390 logMessage(prefix + "LEN: " + len);391 logMessage(prefix + "NAME: " + name);392 */393 448 394 449 if (result.data.size() < 10) 395 450 break; 451 452 453 454 455 456 457 458 459 460 461 396 462 QByteArray ba; 397 463 ba.append(result.data.mid(2, 8)); 398 464 d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE"); 399 //d->m_device->sendTrkAck(result.token)400 465 break; 401 466 } 402 467 case TrkNotifyDeleted: { // NotifyDeleted 403 468 const ushort itemType = (unsigned char)result.data.at(1); 404 const ushort len = result.data.size() > 12 ? extractShort(result.data.data() + 10) : ushort(0); 469 const uint pid = result.data.size() >= 6 ? extractShort(result.data.constData() + 2) : 0; 470 const uint tid = result.data.size() >= 10 ? extractShort(result.data.constData() + 6) : 0; 471 Q_UNUSED(tid) 472 const ushort len = result.data.size() > 12 ? extractShort(result.data.constData() + 10) : ushort(0); 405 473 const QString name = len ? QString::fromAscii(result.data.mid(12, len)) : QString(); 406 474 logMessage(QString::fromLatin1("%1 %2 UNLOAD: %3"). … … 408 476 arg(name)); 409 477 d->m_device->sendTrkAck(result.token); 410 if (itemType == 0// process478 if (itemType == // process 411 479 && result.data.size() >= 10 412 480 && d->m_session.pid == extractInt(result.data.data() + 6)) { 413 disconnectTrk(); 481 if (d->m_startupActions & ActionDownload) 482 copyFileFromRemote(); 483 else 484 disconnectTrk(); 485 } 486 else if (itemType == kDSOSDLLItem && len) { 487 // Remove libraries of process. 488 for (QList<Library>::iterator it = d->m_session.libraries.begin(); it != d->m_session.libraries.end(); ) { 489 if ((*it).pid == pid && (*it).name == name) { 490 emit libraryUnloaded(*it); 491 it = d->m_session.libraries.erase(it); 492 } else { 493 ++it; 494 } 495 } 414 496 } 415 497 break; … … 447 529 if (d->m_startupActions == ActionPingOnly) { 448 530 setState(Disconnected); 449 emit finished();531 inished(); 450 532 } 451 533 return; … … 456 538 d->m_session.trkAppVersion.protocolMinor = result.data.at(4); 457 539 setState(DeviceDescriptionReceived); 540 541 458 542 // Ping mode: Log & Terminate 459 543 if (d->m_startupActions == ActionPingOnly) { 460 qWarning("%s", qPrintable( deviceDescription()));544 qWarning("%s", qPrintable()); 461 545 setState(Disconnected); 462 emit finished(); 463 } 546 handleFinished(); 547 } 548 } 549 550 static inline QString msgCannotOpenRemoteFile(const QString &fileName, const QString &message) 551 { 552 return Launcher::tr("Cannot open remote file '%1': %2").arg(fileName, message); 553 } 554 555 static inline QString msgCannotOpenLocalFile(const QString &fileName, const QString &message) 556 { 557 return Launcher::tr("Cannot open '%1': %2").arg(fileName, message); 464 558 } 465 559 … … 467 561 { 468 562 if (result.errorCode() || result.data.size() < 6) { 469 emit canNotCreateFile(d->m_copyState.destinationFileName, result.errorString()); 563 const QString msg = msgCannotOpenRemoteFile(d->m_copyState.destinationFileName, result.errorString()); 564 logMessage(msg); 565 emit canNotCreateFile(d->m_copyState.destinationFileName, msg); 470 566 disconnectTrk(); 471 567 return; … … 473 569 const char *data = result.data.data(); 474 570 d->m_copyState.copyFileHandle = extractInt(data + 2); 475 QFile file(d->m_copyState.sourceFileName); 476 file.open(QIODevice::ReadOnly); 571 const QString localFileName = d->m_copyState.sourceFileName; 572 QFile file(localFileName); 573 d->m_copyState.position = 0; 574 if (!file.open(QIODevice::ReadOnly)) { 575 const QString msg = msgCannotOpenLocalFile(localFileName, file.errorString()); 576 logMessage(msg); 577 emit canNotOpenLocalFile(localFileName, msg); 578 closeRemoteFile(true); 579 disconnectTrk(); 580 return; 581 } 477 582 d->m_copyState.data.reset(new QByteArray(file.readAll())); 478 d->m_copyState.position = 0;479 583 file.close(); 480 584 continueCopying(); 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 481 641 } 482 642 … … 494 654 void Launcher::continueCopying(uint lastCopiedBlockSize) 495 655 { 496 intsize = d->m_copyState.data->length();656 size = d->m_copyState.data->length(); 497 657 d->m_copyState.position += lastCopiedBlockSize; 498 658 if (size == 0) 499 659 emit copyProgress(100); 500 660 else { 501 int percent = qMin((d->m_copyState.position*100)/size, 100); 502 emit copyProgress(percent); 661 const qint64 hundred = 100; 662 const qint64 percent = qMin( (d->m_copyState.position * hundred) / size, hundred); 663 emit copyProgress(static_cast<int>(percent)); 503 664 } 504 665 if (d->m_copyState.position < size) { … … 533 694 else if (d->m_startupActions & ActionRun) 534 695 startInferiorIfNeeded(); 696 697 535 698 else 536 699 disconnectTrk(); … … 577 740 } 578 741 emit applicationRunning(d->m_session.pid); 742 743 744 745 746 747 748 749 750 579 751 QByteArray ba; 580 752 appendInt(&ba, d->m_session.pid); … … 587 759 logMessage(" FINISHED: " + stringFromArray(result.data)); 588 760 setState(Disconnected); 589 emit finished();761 inished(); 590 762 } 591 763 … … 596 768 const char *data = result.data.data() + 1; 597 769 598 QString str = QLatin1String("SUPPORTED: "); 599 for (int i = 0; i < 32; ++i) { 600 //str.append(" [" + formatByte(data[i]) + "]: "); 601 for (int j = 0; j < 8; ++j) { 602 if (data[i] & (1 << j)) { 603 str.append(QString::number(i * 8 + j, 16)); 604 str.append(QLatin1Char(' ')); 770 if (d->m_verbose > 1) { 771 QString str = QLatin1String("SUPPORTED: "); 772 for (int i = 0; i < 32; ++i) { 773 for (int j = 0; j < 8; ++j) { 774 if (data[i] & (1 << j)) { 775 str.append(QString::number(i * 8 + j, 16)); 776 str.append(QLatin1Char(' ')); 777 } 605 778 } 606 779 } 607 }608 logMessage(str);780 781 609 782 } 610 783 … … 670 843 emit copyingStarted(); 671 844 QByteArray ba; 672 ba.append(char(10)); 845 ba.append(char(10)); 673 846 appendString(&ba, d->m_copyState.destinationFileName.toLocal8Bit(), TargetByteOrder, false); 674 847 d->m_device->sendTrkMessage(TrkOpenFile, TrkCallback(this, &Launcher::handleFileCreation), ba); 848 849 850 851 852 853 854 855 856 675 857 } 676 858 … … 695 877 if (d->m_startupActions & ActionRun) { 696 878 startInferiorIfNeeded(); 879 880 697 881 } else { 698 882 disconnectTrk(); … … 705 889 // It's not started yet 706 890 QByteArray ba; 707 appendShort(&ba, 0, TargetByteOrder); // create new process 891 appendShort(&ba, 0, TargetByteOrder); // create new process 708 892 ba.append(char(0)); // options - currently unused 709 if(arguments.isEmpty()) { 710 appendString(&ba, executable.toLocal8Bit(), TargetByteOrder); 711 return ba; 712 } 713 // Append full command line as one string (leading length information). 714 QByteArray commandLineBa; 715 commandLineBa.append(executable.toLocal8Bit()); 716 commandLineBa.append('\0'); 717 commandLineBa.append(arguments.join(QString(QLatin1Char(' '))).toLocal8Bit()); 718 appendString(&ba, commandLineBa, TargetByteOrder); 893 // One string consisting of binary terminated by '\0' and arguments terminated by '\0' 894 QByteArray commandLineBa = executable.toLocal8Bit(); 895 commandLineBa.append(char(0)); 896 if (!arguments.isEmpty()) 897 commandLineBa.append(arguments.join(QString(QLatin1Char(' '))).toLocal8Bit()); 898 appendString(&ba, commandLineBa, TargetByteOrder, true); 899 return ba; 900 } 901 902 QByteArray Launcher::readMemoryMessage(uint pid, uint tid, uint from, uint len) 903 { 904 QByteArray ba; 905 ba.reserve(11); 906 ba.append(char(0x8)); // Options, FIXME: why? 907 appendShort(&ba, len); 908 appendInt(&ba, from); 909 appendInt(&ba, pid); 910 appendInt(&ba, tid); 911 return ba; 912 } 913 914 QByteArray Launcher::readRegistersMessage(uint pid, uint tid) 915 { 916 QByteArray ba; 917 ba.reserve(15); 918 ba.append(char(0)); // Register set, only 0 supported 919 appendShort(&ba, 0); //R0 920 appendShort(&ba, 16); // last register CPSR 921 appendInt(&ba, pid); 922 appendInt(&ba, tid); 719 923 return ba; 720 924 } … … 738 942 d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE"); 739 943 } 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 740 1036 } // namespace trk -
trunk/tools/runonphone/symbianutils/launcher.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 44 44 45 45 #include "trkdevice.h" 46 46 47 47 48 #include <QtCore/QObject> … … 70 71 ActionCopyInstall = ActionCopy | ActionInstall, 71 72 ActionRun = 0x4, 73 72 74 ActionCopyRun = ActionCopy | ActionRun, 73 75 ActionInstallRun = ActionInstall | ActionRun, … … 95 97 void setFileName(const QString &name); 96 98 void setCopyFileName(const QString &srcName, const QString &dstName); 99 97 100 void setInstallFileName(const QString &name); 98 101 void setCommandLineArgs(const QStringList &args); 99 102 bool startServer(QString *errorMessage); 100 void setVerbose(int v); 103 void setVerbose(int v); 101 104 void setSerialFrame(bool b); 102 105 bool serialFrame() const; … … 110 113 QString deviceDescription(unsigned verbose = 0u) const; 111 114 115 116 117 118 119 120 121 122 123 112 124 static QByteArray startProcessMessage(const QString &executable, 113 125 const QStringList &arguments); 126 127 128 114 129 // Parse a TrkNotifyStopped message 115 130 static bool parseNotifyStopped(const QByteArray &a, … … 120 135 121 136 signals: 137 122 138 void copyingStarted(); 123 139 void canNotConnect(const QString &errorMessage); 124 140 void canNotCreateFile(const QString &filename, const QString &errorMessage); 141 142 125 143 void canNotWriteFile(const QString &filename, const QString &errorMessage); 126 144 void canNotCloseFile(const QString &filename, const QString &errorMessage); … … 136 154 void stateChanged(int); 137 155 void processStopped(uint pc, uint pid, uint tid, const QString& reason); 156 157 158 159 160 161 138 162 139 163 public slots: 140 164 void terminate(); 141 165 void resumeProcess(uint pid, uint tid); 166 167 142 168 143 169 private slots: … … 153 179 void handleConnect(const TrkResult &result); 154 180 void handleFileCreation(const TrkResult &result); 181 155 182 void handleCopy(const TrkResult &result); 183 156 184 void continueCopying(uint lastCopiedBlockSize = 0); 185 157 186 void closeRemoteFile(bool failed = false); 158 187 void handleFileCopied(const TrkResult &result); … … 164 193 void handleSupportMask(const TrkResult &result); 165 194 void handleTrkVersion(const TrkResult &result); 195 196 166 197 167 198 void copyFileToRemote(); 199 168 200 void installRemotePackageSilently(); 169 201 void startInferiorIfNeeded(); 202 170 203 171 204 void logMessage(const QString &msg); -
trunk/tools/runonphone/symbianutils/symbiandevicemanager.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 41 41 42 42 #include "symbiandevicemanager.h" 43 43 44 44 45 #include <QtCore/QSettings> … … 49 50 #include <QtCore/QSharedData> 50 51 #include <QtCore/QScopedPointer> 52 51 53 52 54 namespace SymbianUtils { … … 62 64 class SymbianDeviceData : public QSharedData { 63 65 public: 64 SymbianDeviceData() : type(SerialPortCommunication) {} 66 SymbianDeviceData(); 67 ~SymbianDeviceData(); 68 69 inline bool isOpen() const { return !device.isNull() && device->isOpen(); } 70 void forcedClose(); 65 71 66 72 QString portName; … … 68 74 QString deviceDesc; 69 75 QString manufacturer; 76 77 70 78 DeviceCommunicationType type; 79 80 71 81 }; 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 72 107 73 108 SymbianDevice::SymbianDevice(SymbianDeviceData *data) : 74 109 m_data(data) 75 110 { 76 77 111 } 78 112 … … 97 131 } 98 132 133 134 135 136 137 99 138 QString SymbianDevice::portName() const 100 139 { … … 107 146 } 108 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 109 193 QString SymbianDevice::deviceDesc() const 110 194 { … … 124 208 bool SymbianDevice::isNull() const 125 209 { 126 return !m_data->portName.isEmpty(); 210 return m_data->portName.isEmpty(); 211 } 212 213 bool SymbianDevice::isOpen() const 214 { 215 return m_data->isOpen(); 127 216 } 128 217 … … 159 248 } 160 249 161 QDebug operator<<(QDebug d, const SymbianDevice &cd)250 QDebug operator<<(QDebug d, const SymbianDevice &cd) 162 251 { 163 252 d.nospace() << cd.toString(); … … 167 256 // ------------- SymbianDeviceManagerPrivate 168 257 struct SymbianDeviceManagerPrivate { 169 SymbianDeviceManagerPrivate() : m_initialized(false) {}258 SymbianDeviceManagerPrivate() : m_initialized(false) {} 170 259 171 260 bool m_initialized; 172 261 SymbianDeviceManager::SymbianDeviceList m_devices; 262 173 263 }; 174 264 … … 186 276 SymbianDeviceManager::SymbianDeviceList SymbianDeviceManager::devices() const 187 277 { 188 if (!d->m_initialized) 189 const_cast<SymbianDeviceManager*>(this)->update(false); 278 ensureInitialized(); 190 279 return d->m_devices; 191 280 } … … 195 284 QString rc; 196 285 QTextStream str(&rc); 286 197 287 const int count = d->m_devices.size(); 198 288 for (int i = 0; i < count; i++) { … … 204 294 } 205 295 296 297 298 299 300 301 302 303 304 305 206 306 QString SymbianDeviceManager::friendlyNameForPort(const QString &port) const 207 307 { 208 foreach (const SymbianDevice &device, d->m_devices) { 209 if (device.portName() == port) 210 return device.friendlyName(); 211 } 212 return QString(); 308 const int idx = findByPortName(port); 309 return idx == -1 ? QString() : d->m_devices.at(idx).friendlyName(); 310 } 311 312 SymbianDeviceManager::TrkDevicePtr 313 SymbianDeviceManager::acquireDevice(const QString &port) 314 { 315 ensureInitialized(); 316 const int idx = findByPortName(port); 317 if (idx == -1) { 318 qWarning("Attempt to acquire device '%s' that does not exist.", qPrintable(port)); 319 if (debug) 320 qDebug() << *this; 321 return TrkDevicePtr(); 322 } 323 const TrkDevicePtr rc = d->m_devices[idx].acquireDevice(); 324 if (debug) 325 qDebug() << "SymbianDeviceManager::acquireDevice" << port << " returns " << !rc.isNull(); 326 return rc; 213 327 } 214 328 … … 218 332 } 219 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 220 359 void SymbianDeviceManager::update(bool emitSignals) 221 360 { 361 222 362 typedef SymbianDeviceList::iterator SymbianDeviceListIterator; 223 363 224 364 if (debug) 225 qDebug(">SerialDeviceLister::update( %d)\n%s", int(emitSignals),365 qDebug(">SerialDeviceLister::update(, int(emitSignals), 226 366 qPrintable(toString())); 227 367 … … 231 371 if (newDevices.size() > 1) 232 372 qStableSort(newDevices.begin(), newDevices.end()); 233 if (d->m_devices == newDevices) // Happy, nothing changed. 373 if (d->m_devices == newDevices) { // Happy, nothing changed. 374 if (debug) 375 qDebug("<SerialDeviceLister::update: unchanged\n"); 234 376 return; 377 235 378 // Merge the lists and emit the respective added/removed signals, assuming 236 379 // no one can plug a different device on the same port at the speed of lightning … … 241 384 ++oldIt; 242 385 } else { 243 const SymbianDevice toBeDeleted = *oldIt; 386 SymbianDevice toBeDeleted = *oldIt; 387 toBeDeleted.forcedClose(); 244 388 oldIt = d->m_devices.erase(oldIt); 245 389 if (emitSignals) … … 302 446 // or at least the first one. 303 447 const QString prefix = QLatin1String(linuxBlueToothDeviceRootC); 304 const QString friendlyFormat = QLatin1String("Bluetooth device (%1)");448 const QString friendlyFormat = QLatin1String("Bluetooth device (%1)"); 305 449 for (int d = 0; d < 4; d++) { 306 450 QScopedPointer<SymbianDeviceData> device(new SymbianDeviceData); … … 308 452 device->portName = prefix + QString::number(d); 309 453 if (d == 0 || QFileInfo(device->portName).exists()) { 310 device->friendlyName = friendlyFormat.arg(device->portName);454 device->friendlyName = friendlyFormat.arg(device->portName); 311 455 rc.push_back(SymbianDevice(device.take())); 456 457 458 459 460 461 462 463 464 465 466 467 468 469 312 470 } 313 471 } … … 323 481 } 324 482 325 QDebug operator<<(QDebug d, const SymbianDeviceManager &sdm)483 QDebug operator<<(QDebug d, const SymbianDeviceManager &sdm) 326 484 { 327 485 d.nospace() << sdm.toString(); -
trunk/tools/runonphone/symbianutils/symbiandevicemanager.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 47 47 #include <QtCore/QObject> 48 48 #include <QtCore/QExplicitlySharedDataPointer> 49 49 50 50 51 QT_BEGIN_NAMESPACE … … 52 53 class QTextStream; 53 54 QT_END_NAMESPACE 55 56 57 58 54 59 55 60 namespace SymbianUtils { … … 63 68 }; 64 69 65 // SymbianDevice, explicitly shared. 70 // SymbianDevice: Explicitly shared device data and a TrkDevice 71 // instance that can be acquired (exclusively) for use. 72 // A device removal from the manager will result in the 73 // device being closed. 66 74 class SYMBIANUTILS_EXPORT SymbianDevice { 67 75 explicit SymbianDevice(SymbianDeviceData *data); 68 76 friend class SymbianDeviceManager; 69 77 public: 78 79 70 80 SymbianDevice(); 71 81 SymbianDevice(const SymbianDevice &rhs); … … 78 88 QString portName() const; 79 89 QString friendlyName() const; 90 91 92 93 94 95 96 97 98 99 100 80 101 81 102 // Windows only. … … 87 108 88 109 private: 110 111 89 112 QExplicitlySharedDataPointer<SymbianDeviceData> m_data; 90 113 }; 91 114 92 QDebug operator<<(QDebug d, const SymbianDevice &);115 QDebug operator<<(QDebug d, const SymbianDevice &); 93 116 94 117 inline bool operator==(const SymbianDevice &d1, const SymbianDevice &d2) … … 101 124 /* SymbianDeviceManager: Singleton that maintains a list of Symbian devices. 102 125 * and emits change signals. 103 * On Windows, the update slot must be connected to a signal 104 * emitted from an event handler listening for WM_DEVICECHANGE. */ 126 * On Windows, the update slot must be connected to a [delayed] signal 127 * emitted from an event handler listening for WM_DEVICECHANGE. 128 * Device removal will result in the device being closed. */ 105 129 class SYMBIANUTILS_EXPORT SymbianDeviceManager : public QObject 106 130 { … … 108 132 public: 109 133 typedef QList<SymbianDevice> SymbianDeviceList; 134 110 135 111 136 static const char *linuxBlueToothDeviceRootC; … … 121 146 QString toString() const; 122 147 148 149 150 151 123 152 QString friendlyNameForPort(const QString &port) const; 124 153 125 154 public slots: 126 155 void update(); 156 157 158 127 159 128 160 signals: 129 void deviceRemoved(const Symbian Device &d);130 void deviceAdded(const Symbian Device &d);161 void deviceRemoved(const SymbianDevice &d); 162 void deviceAdded(const SymbianDevice &d); 131 163 void updated(); 132 164 133 165 private: 166 134 167 void update(bool emitSignals); 135 168 SymbianDeviceList serialPorts() const; … … 139 172 }; 140 173 141 QDebug operator<<(QDebug d, const SymbianDeviceManager &);174 QDebug operator<<(QDebug d, const SymbianDeviceManager &); 142 175 143 176 } // namespace SymbianUtils -
trunk/tools/runonphone/symbianutils/symbianutils.pri
r769 r846 1 1 INCLUDEPATH *= $$PWD 2 3 2 4 3 5 # Input … … 10 12 $$PWD/bluetoothlistener.h \ 11 13 $$PWD/communicationstarter.h \ 12 $$PWD/symbiandevicemanager.h 14 $$PWD/symbiandevicemanager.h \ 15 $$PWD/tcftrkdevice.h \ 16 $$PWD/tcftrkmessage.h \ 17 $$PWD/json.h 13 18 14 19 SOURCES += $$PWD/trkutils.cpp \ … … 17 22 $$PWD/bluetoothlistener.cpp \ 18 23 $$PWD/communicationstarter.cpp \ 19 $$PWD/symbiandevicemanager.cpp 24 $$PWD/symbiandevicemanager.cpp \ 25 $$PWD/tcftrkdevice.cpp \ 26 $$PWD/tcftrkmessage.cpp \ 27 $$PWD/json.cpp 20 28 21 29 # Tests/trklauncher is a console application -
trunk/tools/runonphone/symbianutils/symbianutils_global.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/tools/runonphone/symbianutils/trkdevice.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 53 53 #include <QtCore/QWaitCondition> 54 54 #include <QtCore/QSharedPointer> 55 55 56 #include <QtCore/QMetaType> 56 57 … … 103 104 enum { verboseTrk = 0 }; 104 105 106 107 108 109 110 105 111 namespace trk { 106 112 … … 156 162 157 163 class TrkWriteQueue 158 { 164 { 159 165 Q_DISABLE_COPY(TrkWriteQueue) 160 166 public: 161 167 explicit TrkWriteQueue(); 168 162 169 163 170 // Enqueue messages. … … 209 216 } 210 217 218 219 220 221 222 223 224 225 226 227 228 211 229 byte TrkWriteQueue::nextTrkWriteToken() 212 230 { … … 215 233 ++m_trkWriteToken; 216 234 if (verboseTrk) 217 qDebug() << " Write token:" << m_trkWriteToken;235 qDebug() << "" << m_trkWriteToken; 218 236 return m_trkWriteToken; 219 237 } … … 350 368 Q_OBJECT 351 369 Q_DISABLE_COPY(WriterThread) 352 public: 370 public: 353 371 explicit WriterThread(const QSharedPointer<DeviceContext> &context); 354 372 … … 358 376 void queueTrkInitialPing(); 359 377 378 379 360 380 // Call this from the device read notification with the results. 361 381 void slotHandleResult(const TrkResult &result); … … 375 395 void invokeNoopMessage(const trk::TrkMessage &); 376 396 377 private: 397 private: 378 398 bool write(const QByteArray &data, QString *errorMessage); 379 399 inline int writePendingMessage(); … … 463 483 wait(); 464 484 m_terminate = false; 485 465 486 } 466 487 … … 562 583 } 563 584 585 586 587 588 589 590 591 564 592 void WriterThread::queueTrkInitialPing() 565 593 { … … 593 621 public: 594 622 623 624 595 625 signals: 596 626 void messageReceived(const trk::TrkResult &result, const QByteArray &rawData); … … 607 637 608 638 QByteArray m_trkReadBuffer; 639 609 640 }; 610 641 611 642 ReaderThreadBase::ReaderThreadBase(const QSharedPointer<DeviceContext> &context) : 612 m_context(context) 643 m_context(context) 613 644 { 614 645 static const int trkResultMetaId = qRegisterMetaType<trk::TrkResult>(); … … 633 664 TrkResult r; 634 665 QByteArray rawData; 635 while (extractResult(&m_trkReadBuffer, m_context->serialFrame, &r, &rawData)) {666 while (extractResult(&m_trkReadBuffer, m_context->serialFrame, &r, &rawData)) { 636 667 emit messageReceived(r, rawData); 637 668 } … … 693 724 emit error(QString::fromLatin1("ClearCommError failed: %1").arg(winErrorMessage(GetLastError()))); 694 725 return -7; 695 } 726 } 696 727 const DWORD bytesToRead = qMax(DWORD(1), qMin(comStat.cbInQue, DWORD(BufSize))); 697 728 // Trigger read … … 709 740 emit error(QString::fromLatin1("Read error: %1").arg(winErrorMessage(readError))); 710 741 return -1; 711 } 742 } 712 743 // Wait for either termination or data 713 744 const DWORD wr = WaitForMultipleObjects(HandleCount, m_handles, false, INFINITE); … … 784 815 }; 785 816 786 UnixReaderThread::UnixReaderThread(const QSharedPointer<DeviceContext> &context) : 817 UnixReaderThread::UnixReaderThread(const QSharedPointer<DeviceContext> &context) : 787 818 ReaderThreadBase(context) 788 819 { … … 878 909 879 910 QSharedPointer<DeviceContext> deviceContext; 880 QS haredPointer<WriterThread> writerThread;881 QS haredPointer<ReaderThread> readerThread;911 QSedPointer<WriterThread> writerThread; 912 QSedPointer<ReaderThread> readerThread; 882 913 883 914 QByteArray trkReadBuffer; … … 918 949 bool TrkDevice::open(QString *errorMessage) 919 950 { 920 if (d->verbose )951 if (d->verbose) 921 952 qDebug() << "Opening" << port() << "is open: " << isOpen() << " serialFrame=" << serialFrame(); 953 954 922 955 if (d->port.isEmpty()) { 923 956 *errorMessage = QLatin1String("Internal error: No port set on TrkDevice"); 924 957 return false; 925 958 } 926 927 close();928 959 #ifdef Q_OS_WIN 929 960 const QString fullPort = QLatin1String("\\\\.\\") + d->port; … … 976 1007 } 977 1008 #endif 978 d->readerThread = QSharedPointer<ReaderThread>(new ReaderThread(d->deviceContext));1009 d->readerThread(new ReaderThread(d->deviceContext)); 979 1010 connect(d->readerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)), 980 1011 Qt::QueuedConnection); … … 984 1015 d->readerThread->start(); 985 1016 986 d->writerThread = QSharedPointer<WriterThread>(new WriterThread(d->deviceContext));1017 d->writerThread(new WriterThread(d->deviceContext)); 987 1018 connect(d->writerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)), 988 Qt::QueuedConnection); 989 d->writerThread->start(); 990 991 if (d->verbose )992 qDebug() << "Opened" << d->port ;1019 Qt::QueuedConnection); 1020 d->writerThread->start(); 1021 1022 if (d->verbose) 1023 qDebug() << "Opened" << d->port; 993 1024 return true; 994 1025 } … … 996 1027 void TrkDevice::close() 997 1028 { 1029 1030 1031 1032 998 1033 if (!isOpen()) 999 1034 return; … … 1011 1046 d->deviceContext->file.close(); 1012 1047 #endif 1048 1013 1049 if (d->verbose) 1014 1050 emitLogMessage("Close"); … … 1031 1067 void TrkDevice::setPort(const QString &p) 1032 1068 { 1069 1070 1033 1071 d->port = p; 1034 1072 } … … 1046 1084 void TrkDevice::setSerialFrame(bool f) 1047 1085 { 1086 1087 1048 1088 d->deviceContext->serialFrame = f; 1049 1089 } … … 1061 1101 void TrkDevice::slotMessageReceived(const trk::TrkResult &result, const QByteArray &rawData) 1062 1102 { 1063 d->writerThread->slotHandleResult(result); 1064 if (d->verbose > 1) 1065 qDebug() << "Received: " << result.toString(); 1066 emit messageReceived(result); 1067 if (!rawData.isEmpty()) 1068 emit rawDataReceived(rawData); 1103 if (isOpen()) { // Might receive bytes after closing due to queued connections. 1104 d->writerThread->slotHandleResult(result); 1105 if (d->verbose > 1) 1106 qDebug() << "Received: " << result.toString(); 1107 emit messageReceived(result); 1108 if (!rawData.isEmpty()) 1109 emit rawDataReceived(rawData); 1110 } 1069 1111 } 1070 1112 … … 1076 1118 } 1077 1119 1120 1121 1122 1123 1124 1125 1078 1126 void TrkDevice::sendTrkMessage(byte code, TrkCallback callback, 1079 1127 const QByteArray &data, const QVariant &cookie) 1080 1128 { 1129 1130 1131 1132 1081 1133 if (!d->writerThread.isNull()) { 1082 1134 if (d->verbose > 1) { 1083 QByteArray msg = "Sending: ";1135 QByteArray msg = "Sending: "; 1084 1136 msg += QByteArray::number(code, 16); 1085 1137 msg += ": "; 1086 1138 msg += stringFromArray(data).toLatin1(); 1139 1140 1087 1141 qDebug("%s", msg.data()); 1088 1142 } … … 1093 1147 void TrkDevice::sendTrkInitialPing() 1094 1148 { 1149 1150 1151 1152 1095 1153 if (!d->writerThread.isNull()) 1096 1154 d->writerThread->queueTrkInitialPing(); … … 1099 1157 bool TrkDevice::sendTrkAck(byte token) 1100 1158 { 1159 1160 1161 1162 1101 1163 if (d->writerThread.isNull()) 1102 1164 return false; -
trunk/tools/runonphone/symbianutils/trkdevice.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 65 65 * read operation. 66 66 * The serialFrames property specifies whether packets are encapsulated in 67 * "0x90 <length>" frames, which is currently the case for serial ports. 67 * "0x90 <length>" frames, which is currently the case for serial ports. 68 68 * Contains a write message queue allowing 69 69 * for queueing messages with a notification callback. If the message receives 70 70 * an ACK, the callback is invoked. 71 * The special message TRK_WRITE_QUEUE_NOOP_CODE code can be used for synchronisation. 72 * The respective message will not be sent, the callback is just invoked. */ 71 * The special message TRK_WRITE_QUEUE_NOOP_CODE code can be used for synchronization. 72 * The respective message will not be sent, the callback is just invoked. 73 * Note that calling open/close in quick succession can cause crashes 74 * due to the use of queused signals. */ 73 75 74 76 enum { TRK_WRITE_QUEUE_NOOP_CODE = 0x7f }; … … 112 114 bool sendTrkAck(unsigned char token); 113 115 116 117 118 114 119 signals: 115 120 void messageReceived(const trk::TrkResult &result); -
trunk/tools/runonphone/symbianutils/trkutils.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 52 52 53 53 namespace trk { 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 54 73 55 74 TrkAppVersion::TrkAppVersion() … … 78 97 extended2TypeSize = 0; 79 98 pid = 0; 99 80 100 tid = 0; 81 101 codeseg = 0; 82 102 dataseg = 0; 83 103 84 currentThread = 0;85 104 libraries.clear(); 86 105 trkAppVersion.reset(); … … 144 163 } 145 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 146 249 // -------------- 147 250 … … 189 292 const int size = maxLen == -1 ? ba.size() : qMin(ba.size(), maxLen); 190 293 for (int i = 0; i < size; ++i) { 191 //if (i == 5 || i == ba.size() - 2) 192 // str += " "; 193 int c = byte(ba.at(i)); 194 str += QString("%1 ").arg(c, 2, 16, QChar('0')); 195 if (i >= 8 && i < ba.size() - 2) 196 ascii += QChar(c).isPrint() ? QChar(c) : QChar('.'); 294 const int c = byte(ba.at(i)); 295 str += QString::fromAscii("%1 ").arg(c, 2, 16, QChar('0')); 296 ascii += QChar(c).isPrint() ? QChar(c) : QChar('.'); 197 297 } 198 298 if (size != ba.size()) { 199 str += "...";200 ascii += "...";201 } 202 return str + " "+ ascii;299 str += ; 300 ascii += ; 301 } 302 return str + + ascii; 203 303 } 204 304 … … 277 377 /* returns 0 if array doesn't represent a result, 278 378 otherwise returns the length of the result data */ 279 ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame )379 ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame) 280 380 { 281 381 if (serialFrame) { … … 283 383 if (buffer.length() < 4) 284 384 return 0; 285 if (buffer.at(0) != 0x01 || byte(buffer.at(1)) != 0x90) 286 return 0; 385 mux = extractShort(buffer.data()); 287 386 const ushort len = extractShort(buffer.data() + 2); 288 387 return (buffer.size() >= len + 4) ? len : ushort(0); … … 293 392 // Regular message delimited by 0x7e..0x7e 294 393 if (firstDelimiterPos == 0) { 394 295 395 const int endPos = buffer.indexOf(delimiter, firstDelimiterPos + 1); 296 396 return endPos != -1 ? endPos + 1 - firstDelimiterPos : 0; … … 300 400 } 301 401 302 bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, QByteArray *rawData)402 bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, QByteArray *rawData) 303 403 { 304 404 result->clear(); 305 405 if(rawData) 306 406 rawData->clear(); 307 const ushort len = isValidTrkResult(*buffer, serialFrame); 407 ushort len = isValidTrkResult(*buffer, serialFrame, result->multiplex); 408 // handle receiving application output, which is not a regular command 409 const int delimiterPos = serialFrame ? 4 : 0; 410 if (linkEstablishmentMode) { 411 //when "hot connecting" a device, we can receive partial frames. 412 //this code resyncs by discarding data until a TRK frame is found 413 while (buffer->length() > delimiterPos 414 && result->multiplex != MuxTextTrace 415 && !(result->multiplex == MuxTrk && buffer->at(delimiterPos) == 0x7e)) { 416 buffer->remove(0,1); 417 len = isValidTrkResult(*buffer, serialFrame, result->multiplex); 418 } 419 } 308 420 if (!len) 309 421 return false; 310 // handle receiving application output, which is not a regular command311 const int delimiterPos = serialFrame ? 4 : 0;312 422 if (buffer->at(delimiterPos) != 0x7e) { 313 423 result->isDebugOutput = true; 314 424 result->data = buffer->mid(delimiterPos, len); 315 result->data.replace("\r\n", "\n"); 316 *buffer->remove(0, delimiterPos + len); 425 buffer->remove(0, delimiterPos + len); 317 426 return true; 318 427 } … … 322 431 if(rawData) 323 432 *rawData = data; 324 *buffer->remove(0, delimiterPos + len);433 buffer->remove(0, delimiterPos + len); 325 434 326 435 byte sum = 0; … … 337 446 //QByteArray prefix = "READ BUF: "; 338 447 //logMessage((prefix + "HEADER: " + stringFromArray(header).toLatin1()).data()); 448 339 449 return true; 340 450 } … … 351 461 res *= 256; res += byte(data[2]); 352 462 res *= 256; res += byte(data[3]); 463 464 465 466 467 468 469 470 471 472 473 474 475 353 476 return res; 354 477 } -
trunk/tools/runonphone/symbianutils/trkutils.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 44 44 45 45 #include "symbianutils_global.h" 46 46 47 #include <QtCore/QByteArray> 47 48 #include <QtCore/QHash> … … 56 57 57 58 typedef unsigned char byte; 59 58 60 59 61 enum Command { 62 60 63 TrkPing = 0x00, 61 64 TrkConnect = 0x01, 62 65 TrkDisconnect = 0x02, 66 63 67 TrkVersions = 0x04, 64 68 TrkSupported = 0x05, 65 69 TrkCpuType = 0x06, 70 71 66 72 TrkHostVersions = 0x09, 73 74 75 76 77 78 79 80 81 82 83 67 84 TrkContinue = 0x18, 85 86 87 88 89 90 91 92 93 94 95 96 68 97 TrkCreateItem = 0x40, 69 98 TrkDeleteItem = 0x41, 99 100 70 101 71 102 TrkWriteFile = 0x48, 103 72 104 TrkOpenFile = 0x4a, 73 105 TrkCloseFile = 0x4b, 106 74 107 TrkInstallFile = 0x4d, 75 108 TrkInstallFile2 = 0x4e, 76 109 110 111 112 113 114 77 115 TrkNotifyAck = 0x80, 78 116 TrkNotifyNak = 0xff, 117 118 79 119 TrkNotifyStopped = 0x90, 80 120 TrkNotifyException = 0x91, 81 121 TrkNotifyInternalError = 0x92, 122 123 124 82 125 TrkNotifyCreated = 0xa0, 83 126 TrkNotifyDeleted = 0xa1, 84 127 TrkNotifyProcessorStarted = 0xa2, 85 128 TrkNotifyProcessorStandBy = 0xa6, 86 TrkNotifyProcessorReset = 0xa7 129 TrkNotifyProcessorReset = 0xa7, 130 131 //target -> host support commands (these are defined but not implemented in TRK) 132 TrkDSWriteFile = 0xd0, 133 TrkDSReadFile = 0xd1, 134 TrkDSOpenFile = 0xd2, 135 TrkDSCloseFile = 0xd3, 136 TrkDSPositionFile = 0xd4 137 }; 138 139 enum DSOSItemTypes { 140 kDSOSProcessItem = 0x0000, 141 kDSOSThreadItem = 0x0001, 142 kDSOSDLLItem = 0x0002, 143 kDSOSAppItem = 0x0003, 144 kDSOSMemBlockItem = 0x0004, 145 kDSOSProcAttachItem = 0x0005, 146 kDSOSThreadAttachItem = 0x0006, 147 kDSOSProcAttach2Item = 0x0007, 148 kDSOSProcRunItem = 0x0008, 149 /* 0x0009 - 0x00ff reserved for general expansion */ 150 /* 0x0100 - 0xffff available for target-specific use */ 151 }; 152 153 enum SerialMultiplexor { 154 MuxRaw = 0, 155 MuxTextTrace = 0x0102, 156 MuxTrk = 0x0190 87 157 }; 88 158 … … 90 160 SYMBIANUTILS_EXPORT ushort extractShort(const char *data); 91 161 SYMBIANUTILS_EXPORT uint extractInt(const char *data); 162 92 163 93 164 SYMBIANUTILS_EXPORT QString quoteUnprintableLatin1(const QByteArray &ba); … … 109 180 struct SYMBIANUTILS_EXPORT Library 110 181 { 111 Library() {} 182 Library(); 183 explicit Library(const TrkResult &r); 112 184 113 185 QByteArray name; 114 186 uint codeseg; 115 187 uint dataseg; 188 189 116 190 }; 117 191 … … 119 193 { 120 194 TrkAppVersion(); 121 void reset(); 195 void reset(); 122 196 123 197 int trkMajor; … … 132 206 void reset(); 133 207 QString deviceDescription(unsigned verbose) const; 208 209 210 211 212 134 213 135 214 // Trk feedback … … 143 222 TrkAppVersion trkAppVersion; 144 223 uint pid; 224 145 225 uint tid; 146 226 uint codeseg; … … 151 231 Libraries libraries; 152 232 153 typedef uint Thread;154 typedef QList<Thread> Threads;155 Threads threads;156 157 233 // Gdb request 158 uint currentThread;159 234 QStringList modules; 160 235 }; … … 169 244 QString errorString() const; 170 245 246 171 247 byte code; 172 248 byte token; -
trunk/tools/runonphone/symbianutils/trkutils_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 56 56 // the serial frame [0x01 0x90 <len>] and 0x7e encoded7d(ba) 0x7e 57 57 QByteArray frameMessage(byte command, byte token, const QByteArray &data, bool serialFrame); 58 bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *r, QByteArray *rawData = 0);58 bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *r, QByteArray *rawData = 0); 59 59 60 60 } // namespace trk
Note:
See TracChangeset
for help on using the changeset viewer.
