diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-12-23 10:11:11 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-12-23 10:11:11 (GMT) |
commit | a315c693d0f3dd64711b8459d86b89ddc48e8c1a (patch) | |
tree | 8f966269d797f97d41847c5bb7283297cee20b47 /tools/runonphone | |
parent | d37a3529ec883985b2967265f0797d749db74308 (diff) | |
parent | e6694ebe4081b807b1bb0946e17e73840019ec6d (diff) | |
download | Qt-a315c693d0f3dd64711b8459d86b89ddc48e8c1a.zip Qt-a315c693d0f3dd64711b8459d86b89ddc48e8c1a.tar.gz Qt-a315c693d0f3dd64711b8459d86b89ddc48e8c1a.tar.bz2 |
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts:
src/s60main/newallocator_hook.cpp
tools/runonphone/serenum_unix.cpp
Diffstat (limited to 'tools/runonphone')
-rw-r--r-- | tools/runonphone/serenum_unix.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/tools/runonphone/serenum_unix.cpp b/tools/runonphone/serenum_unix.cpp index f5b2521..f5b616b 100644 --- a/tools/runonphone/serenum_unix.cpp +++ b/tools/runonphone/serenum_unix.cpp @@ -82,7 +82,7 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel) 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) { + for (int n = 0; n < device->descriptor.bNumConfigurations && device->config; ++n) { struct usb_config_descriptor &usbConfig =device->config[n]; QList<int> usableInterfaces; for (int m = 0; m < usbConfig.bNumInterfaces; ++m) { @@ -146,6 +146,10 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel) // second loop to find the actual data interface. foreach (int i, usableInterfaces) { +#ifdef Q_OS_MAC + eligibleInterfaces << QString("^cu\\.usbmodem.*%1$") + .arg(QString("%1").arg(descriptor.bInterfaceNumber, 1, 16).toUpper()); +#else // ### manufacturer and product strings are only readable as root :( if (!manufacturerString.isEmpty() && !productString.isEmpty()) { eligibleInterfaces << QString("usb-%1_%2-if%3") @@ -155,6 +159,7 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel) } else { eligibleInterfaces << QString("if%1").arg(i, 2, 16, QChar('0')); // fix! } +#endif } eligibleInterfacesInfo << InterfaceInfo(manufacturerString, productString, device->descriptor.idVendor, device->descriptor.idProduct); } @@ -164,14 +169,24 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel) if (loglevel > 1) qDebug() << " searching for interfaces:" << eligibleInterfaces; +#ifdef Q_OS_MAC + QDir dir("/dev/"); + bool allowAny = false; +#else QDir dir("/dev/serial/by-id/"); - foreach (const QFileInfo &info, dir.entryInfoList()) { + bool allowAny = eligibleInterfaces.isEmpty(); +#endif + foreach (const QFileInfo &info, dir.entryInfoList(QDir::System)) { if (!info.isDir()) { - bool usable = eligibleInterfaces.isEmpty(); + bool usable = allowAny; + QString friendlyName = info.fileName(); foreach (const QString &iface, eligibleInterfaces) { - if (info.fileName().contains(iface)) { + if (info.fileName().contains(QRegExp(iface))) { if (loglevel > 1) qDebug() << " found device file:" << info.fileName() << endl; +#ifdef Q_OS_MAC + friendlyName = eligibleInterfacesInfo[eligibleInterfaces.indexOf(iface)].product; +#endif usable = true; break; } @@ -180,7 +195,7 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel) continue; SerialPortId id; - id.friendlyName = info.fileName(); + id.friendlyName = friendlyName; id.portName = info.canonicalFilePath(); list << id; } @@ -193,11 +208,15 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel) << iface.manufacturer << "Product:" << iface.product +#ifdef Q_OS_LINUX << endl << " Load generic driver using:" << QString("sudo modprobe usbserial vendor=0x%1 product=0x%2") .arg(iface.manufacturerid, 4, 16, QChar('0')) .arg(iface.productid, 4, 16, QChar('0')); +#else + ; +#endif } } return list; |