diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-19 12:28:13 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-19 12:28:13 (GMT) |
commit | be2f020ada5cc52f91208d82b701958582b109b2 (patch) | |
tree | 00132753f6dc57b8f9379348b1ccee588a27f559 /tools | |
parent | 78b2e9421c47371b68f4c65a181a077ba3a226ac (diff) | |
parent | a34c82bb5a0a0e6c2bdccfef5fb31e7a0667c906 (diff) | |
download | Qt-be2f020ada5cc52f91208d82b701958582b109b2.zip Qt-be2f020ada5cc52f91208d82b701958582b109b2.tar.gz Qt-be2f020ada5cc52f91208d82b701958582b109b2.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public:
Use libusb to auto-detect the port to use to communicate with the phone
Whitespace
Make multimedia only depend on opengl when the latter is build
gcc for Symbian doesn't support gcc extensions like atomicity.h - disable
Diffstat (limited to 'tools')
-rw-r--r-- | tools/runonphone/main.cpp | 48 | ||||
-rw-r--r-- | tools/runonphone/runonphone.pro | 3 | ||||
-rw-r--r-- | tools/runonphone/serenum_stub.cpp | 2 | ||||
-rw-r--r-- | tools/runonphone/serenum_unix.cpp | 71 | ||||
-rw-r--r-- | tools/runonphone/trksignalhandler.cpp | 30 |
5 files changed, 112 insertions, 42 deletions
diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp index 1a5cdee..af08777 100644 --- a/tools/runonphone/main.cpp +++ b/tools/runonphone/main.cpp @@ -44,9 +44,9 @@ #include <QStringList> #include <QScopedPointer> #include <QTimer> -#include "trkutils.h" -#include "trkdevice.h" -#include "launcher.h" +#include "symbianutils/trkutils.h" +#include "symbianutils/trkdevice.h" +#include "symbianutils/launcher.h" #include "trksignalhandler.h" #include "serenum.h" @@ -133,28 +133,28 @@ int main(int argc, char *argv[]) return 1; } - if(serialPortName.isEmpty()) { - if(loglevel > 0) + if (serialPortName.isEmpty()) { + if (loglevel > 0) outstream << "Detecting serial ports" << endl; - QList <SerialPortId> ports = enumerateSerialPorts(); - foreach(SerialPortId id, ports) { - if(loglevel > 0) + foreach (const SerialPortId &id, enumerateSerialPorts()) { + if (loglevel > 0) outstream << "Port Name: " << id.portName << ", " << "Friendly Name:" << id.friendlyName << endl; - if(serialPortName.isEmpty()) { - if(!id.friendlyName.isEmpty() && - serialPortFriendlyName.isEmpty() && - (id.friendlyName.contains("symbian", Qt::CaseInsensitive) || - id.friendlyName.contains("s60", Qt::CaseInsensitive) || - id.friendlyName.contains("nokia", Qt::CaseInsensitive))) - serialPortName = id.portName; - else if (!id.friendlyName.isEmpty() && - !serialPortFriendlyName.isEmpty() && - id.friendlyName.contains(serialPortFriendlyName)) - serialPortName = id.portName; + if (!id.friendlyName.isEmpty() + && serialPortFriendlyName.isEmpty() + && (id.friendlyName.contains("symbian", Qt::CaseInsensitive) + || id.friendlyName.contains("s60", Qt::CaseInsensitive) + || id.friendlyName.contains("nokia", Qt::CaseInsensitive))) { + serialPortName = id.portName; + break; + } else if (!id.friendlyName.isEmpty() + && !serialPortFriendlyName.isEmpty() + && id.friendlyName.contains(serialPortFriendlyName)) { + serialPortName = id.portName; + break; } } - if(serialPortName.isEmpty()) { + if (serialPortName.isEmpty()) { errstream << "No phone found, ensure USB cable is connected or specify manually with -p" << endl; return 1; } @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) QScopedPointer<trk::Launcher> launcher; - if(sisFile.isEmpty()) { + if (sisFile.isEmpty()) { launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyRun)); launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + exeFile); errstream << "System TRK required to copy EXE, use --sis if using Application TRK" << endl; @@ -172,14 +172,14 @@ int main(int argc, char *argv[]) launcher->setCopyFileName(sisFile, "c:\\data\\testtemp.sis"); launcher->setInstallFileName("c:\\data\\testtemp.sis"); } - if(loglevel > 0) + if (loglevel > 0) outstream << "Connecting to target via " << serialPortName << endl; launcher->setTrkServerName(serialPortName); launcher->setFileName(QString("c:\\sys\\bin\\") + exeFile); launcher->setCommandLineArgs(cmdLine); - if(loglevel > 1) + if (loglevel > 1) launcher->setVerbose(1); TrkSignalHandler handler; @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) } QString errorMessage; - if(!launcher->startServer(&errorMessage)) { + if (!launcher->startServer(&errorMessage)) { errstream << errorMessage << endl; return 1; } diff --git a/tools/runonphone/runonphone.pro b/tools/runonphone/runonphone.pro index 7bed3e5..0c63723 100644 --- a/tools/runonphone/runonphone.pro +++ b/tools/runonphone/runonphone.pro @@ -22,7 +22,10 @@ windows { } else:unix:!symbian { SOURCES += serenum_unix.cpp + LIBS += -lusb } else { SOURCES += serenum_stub.cpp } + + diff --git a/tools/runonphone/serenum_stub.cpp b/tools/runonphone/serenum_stub.cpp index f39765e..6f0e1ef 100644 --- a/tools/runonphone/serenum_stub.cpp +++ b/tools/runonphone/serenum_stub.cpp @@ -47,7 +47,7 @@ QList<SerialPortId> enumerateSerialPorts() { QList<SerialPortId> list; - qWarning() << "enumerateSerialPorts not implemented" << endl; + qWarning() << "enumerateSerialPorts not implemented"; return list; } diff --git a/tools/runonphone/serenum_unix.cpp b/tools/runonphone/serenum_unix.cpp index ca6c437..b6f0293 100644 --- a/tools/runonphone/serenum_unix.cpp +++ b/tools/runonphone/serenum_unix.cpp @@ -46,13 +46,80 @@ #include <QFileInfo> #include <QDir> +#include <usb.h> + QList<SerialPortId> enumerateSerialPorts() { + QList<QString> eligableInterfaces; QList<SerialPortId> list; + + usb_init(); + usb_find_busses(); + usb_find_devices(); + + for (struct usb_bus *bus = usb_get_busses(); bus; bus = bus->next) { + for (struct usb_device *device = bus->devices; device; device = device->next) { + for (int n = 0; n < device->descriptor.bNumConfigurations; ++n) { + struct usb_config_descriptor &usbConfig =device->config[n]; + QList<int> usableInterfaces; + for (int m = 0; m < usbConfig.bNumInterfaces; ++m) { + for (int o = 0; o < usbConfig.interface[m].num_altsetting; ++o) { + struct usb_interface_descriptor &descriptor = usbConfig.interface[m].altsetting[o]; + if (descriptor.bInterfaceClass != 2 // "Communication" + || descriptor.bInterfaceSubClass != 2 // Abstract (modem) + || descriptor.bInterfaceProtocol != 255) // Vendor Specific + continue; + + unsigned char *buf = descriptor.extra; + unsigned int size = descriptor.extralen; + while (size >= 2 * sizeof(u_int8_t)) { + // for Communication devices there is a slave interface for the actual + // data transmission. + // the extra info stores that as a index for the interface + if (buf[0] >= 5 && buf[1] == 36 && buf[2] == 6) { // CDC Union + for (int i = 4; i < buf[0]; i++) + usableInterfaces.append((int) buf[i]); + } + size -= buf[0]; + buf += buf[0]; + } + } + } + + // second loop to find the actual data interface. + foreach (int i, usableInterfaces) { + for (int m = 0; m < usbConfig.bNumInterfaces; ++m) { + for (int o = 0; o < usbConfig.interface[m].num_altsetting; ++o) { + struct usb_interface_descriptor &descriptor = usbConfig.interface[m].altsetting[o]; + if (descriptor.bInterfaceNumber != i) + continue; + if (descriptor.bInterfaceClass == 10) { // "CDC Data" + // qDebug() << " found the data port" + // << "bus:" << bus->dirname + // << "device" << device->filename + // << "interface" << descriptor.bInterfaceNumber; + eligableInterfaces << QString("if%1").arg(QString::number(i), 2, QChar('0')); // fix! + } + } + } + } + } + } + } + QDir dir("/dev/serial/by-id/"); - QFileInfoList ports(dir.entryInfoList()); - foreach(QFileInfo info, ports) { + foreach (const QFileInfo &info, dir.entryInfoList()) { if (!info.isDir()) { + bool usable = eligableInterfaces.isEmpty(); + foreach (const QString &iface, eligableInterfaces) { + if (info.fileName().contains(iface)) { + usable = true; + break; + } + } + if (!usable) + continue; + SerialPortId id; id.friendlyName = info.fileName(); id.portName = info.canonicalFilePath(); diff --git a/tools/runonphone/trksignalhandler.cpp b/tools/runonphone/trksignalhandler.cpp index 4fa79f1..9fe2035 100644 --- a/tools/runonphone/trksignalhandler.cpp +++ b/tools/runonphone/trksignalhandler.cpp @@ -58,13 +58,13 @@ private: void TrkSignalHandler::copyingStarted() { - if(d->loglevel > 0) + if (d->loglevel > 0) d->out << "Copying..." << endl; } void TrkSignalHandler::canNotConnect(const QString &errorMessage) { - d->err << "Cannot Connect - " << errorMessage << endl; + d->err << "Cannot connect - " << errorMessage << endl; } void TrkSignalHandler::canNotCreateFile(const QString &filename, const QString &errorMessage) @@ -84,7 +84,7 @@ void TrkSignalHandler::canNotCloseFile(const QString &filename, const QString &e void TrkSignalHandler::installingStarted() { - if(d->loglevel > 0) + if (d->loglevel > 0) d->out << "Installing..." << endl; } @@ -95,19 +95,19 @@ void TrkSignalHandler::canNotInstall(const QString &packageFilename, const QStri void TrkSignalHandler::installingFinished() { - if(d->loglevel > 0) + if (d->loglevel > 0) d->out << "Installing finished" << endl; } void TrkSignalHandler::startingApplication() { - if(d->loglevel > 0) + if (d->loglevel > 0) d->out << "Starting app..." << endl; } void TrkSignalHandler::applicationRunning(uint pid) { - if(d->loglevel > 0) + if (d->loglevel > 0) d->out << "Running..." << endl; } @@ -118,7 +118,7 @@ void TrkSignalHandler::canNotRun(const QString &errorMessage) void TrkSignalHandler::finished() { - if(d->loglevel > 0) + if (d->loglevel > 0) d->out << "Done." << endl; QCoreApplication::quit(); } @@ -130,17 +130,17 @@ void TrkSignalHandler::applicationOutputReceived(const QString &output) void TrkSignalHandler::copyProgress(int percent) { - if(d->loglevel > 0) { + if (d->loglevel > 0) { d->out << percent << "% "; d->out.flush(); - if(percent==100) + if (percent==100) d->out << endl; } } void TrkSignalHandler::stateChanged(int state) { - if(d->loglevel > 1) + if (d->loglevel > 1) d->out << "State" << state << endl; } @@ -164,10 +164,10 @@ void TrkSignalHandler::timeout() emit terminate(); } -TrkSignalHandlerPrivate::TrkSignalHandlerPrivate() : - out(stdout), - err(stderr), - loglevel(0) +TrkSignalHandlerPrivate::TrkSignalHandlerPrivate() + : out(stdout), + err(stderr), + loglevel(0) { } @@ -179,8 +179,8 @@ TrkSignalHandlerPrivate::~TrkSignalHandlerPrivate() } TrkSignalHandler::TrkSignalHandler() + : d(new TrkSignalHandlerPrivate()) { - d = new TrkSignalHandlerPrivate(); } TrkSignalHandler::~TrkSignalHandler() |