summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2010-07-09 12:31:04 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2010-07-09 12:57:18 (GMT)
commit0efc71b7af2818f2f40438b2807efe361352f7a9 (patch)
tree34d18f92122821d3090571cf8cf9fb3f64c10257
parent767aa8d648bf81a3303da66a4fef98657ea5ece3 (diff)
downloadQt-0efc71b7af2818f2f40438b2807efe361352f7a9.zip
Qt-0efc71b7af2818f2f40438b2807efe361352f7a9.tar.gz
Qt-0efc71b7af2818f2f40438b2807efe361352f7a9.tar.bz2
Linux runonphone - tell the user which driver to load
The linux usbserial driver doesn't attach to devices automatically, to avoid conflicts with the real driver (if there is one). So the user must run modprobe to load the driver before runonphone can be used. Since runonphone has found the correct device(s) using libusb, this patch will tell the user the modprobe command that is required to load the generic usbserial driver. Reviewed-By: Gareth Stockwell
-rw-r--r--tools/runonphone/serenum_unix.cpp51
1 files changed, 45 insertions, 6 deletions
diff --git a/tools/runonphone/serenum_unix.cpp b/tools/runonphone/serenum_unix.cpp
index 4c90d7a..db6375e 100644
--- a/tools/runonphone/serenum_unix.cpp
+++ b/tools/runonphone/serenum_unix.cpp
@@ -48,9 +48,32 @@
#include <usb.h>
+class InterfaceInfo
+{
+public:
+ InterfaceInfo(const QString &mf, const QString &pr, int mfid, int prid);
+ QString manufacturer;
+ QString product;
+ int manufacturerid;
+ int productid;
+};
+
+InterfaceInfo::InterfaceInfo(const QString &mf, const QString &pr, int mfid, int prid) :
+ manufacturer(mf),
+ product(pr),
+ manufacturerid(mfid),
+ productid(prid)
+{
+ if(mf.isEmpty())
+ manufacturer = QString("[%1]").arg(mfid, 4, 16, QChar('0'));
+ if(pr.isEmpty())
+ product = QString("[%1]").arg(prid, 4, 16, QChar('0'));
+}
+
QList<SerialPortId> enumerateSerialPorts(int loglevel)
{
- QList<QString> eligableInterfaces;
+ QList<QString> eligibleInterfaces;
+ QList<InterfaceInfo> eligibleInterfacesInfo;
QList<SerialPortId> list;
usb_init();
@@ -137,13 +160,14 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel)
}
// ### manufacturer and product strings are only readable as root :(
if (!manufacturerString.isEmpty() && !productString.isEmpty()) {
- eligableInterfaces << QString("usb-%1_%2-if%3")
+ eligibleInterfaces << QString("usb-%1_%2-if%3")
.arg(manufacturerString.replace(QChar(' '), QChar('_')))
.arg(productString.replace(QChar(' '), QChar('_')))
.arg(i, 2, 16, QChar('0'));
} else {
- eligableInterfaces << QString("if%1").arg(i, 2, 16, QChar('0')); // fix!
+ eligibleInterfaces << QString("if%1").arg(i, 2, 16, QChar('0')); // fix!
}
+ eligibleInterfacesInfo << InterfaceInfo(manufacturerString, productString, device->descriptor.idVendor, device->descriptor.idProduct);
}
}
}
@@ -153,13 +177,13 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel)
}
if (loglevel > 1)
- qDebug() << " searching for interfaces:" << eligableInterfaces;
+ qDebug() << " searching for interfaces:" << eligibleInterfaces;
QDir dir("/dev/serial/by-id/");
foreach (const QFileInfo &info, dir.entryInfoList()) {
if (!info.isDir()) {
- bool usable = eligableInterfaces.isEmpty();
- foreach (const QString &iface, eligableInterfaces) {
+ bool usable = eligibleInterfaces.isEmpty();
+ foreach (const QString &iface, eligibleInterfaces) {
if (info.fileName().contains(iface)) {
if (loglevel > 1)
qDebug() << " found device file:" << info.fileName() << endl;
@@ -176,6 +200,21 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel)
list << id;
}
}
+
+ if (list.isEmpty() && !eligibleInterfacesInfo.isEmpty() && loglevel > 0) {
+ qDebug() << "Possible USB devices found, but without serial drivers:";
+ foreach(const InterfaceInfo &iface, eligibleInterfacesInfo) {
+ qDebug() << " Manufacturer:"
+ << iface.manufacturer
+ << "Product:"
+ << iface.product
+ << 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'));
+ }
+ }
return list;
}