From 30c877a5f2a3b856e94743b723504e910ac044ca Mon Sep 17 00:00:00 2001 From: Sean Rhea Date: Sat, 6 Feb 2010 11:18:11 -0800 Subject: [PATCH] fix FTDI required for SRM download bug GC supports two download port types: serial ports and D2XX. Before, if either of these failed to load, the download dialog wouldn't show either port type. With this patch, if both fail, GC displays a warning, but if either one succeeds, GC will proceed with only that port type. This change should fix the problem that users were having to download and install both the FTDI drivers and the PL2303 ones in order to download from the SRM PCV. --- src/CommPort.cpp | 11 +++++++---- src/DownloadRideDialog.cpp | 4 ++-- src/Serial.cpp | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/CommPort.cpp b/src/CommPort.cpp index b590c5eee..c4ecdd311 100644 --- a/src/CommPort.cpp +++ b/src/CommPort.cpp @@ -33,15 +33,18 @@ CommPort::addListFunction(ListFunction f) QVector CommPort::listCommPorts(QString &err) { - err = ""; + QStringList errors; QVector result; for (int i = 0; listFunctions && i < listFunctions->size(); ++i) { - QVector tmp = (*listFunctions)[i](err); - if (err == "") + QString thisError = ""; + QVector tmp = (*listFunctions)[i](thisError); + if (thisError == "") result << tmp; else - err += "\n"; + errors << thisError; } + if (result.isEmpty() && !errors.isEmpty()) + err = errors.join("\n"); return result; } diff --git a/src/DownloadRideDialog.cpp b/src/DownloadRideDialog.cpp index babc9262d..304f0c2e0 100644 --- a/src/DownloadRideDialog.cpp +++ b/src/DownloadRideDialog.cpp @@ -106,8 +106,8 @@ DownloadRideDialog::scanCommPorts() QString err; devList = CommPort::listCommPorts(err); if (err != "") { - QString msg = "Warning:\n\n" + err + "You may need to (re)install " - "the FTDI drivers before downloading."; + QString msg = "Warning(s):\n\n" + err + "\n\nYou may need to (re)install " + "the FTDI or PL2303 drivers before downloading."; QMessageBox::warning(0, "Error Loading Device Drivers", msg, QMessageBox::Ok, QMessageBox::NoButton); } diff --git a/src/Serial.cpp b/src/Serial.cpp index b01c57592..f1340df96 100644 --- a/src/Serial.cpp +++ b/src/Serial.cpp @@ -398,6 +398,8 @@ Serial::myListCommPorts(QString &err) QVector result; char *devices[MAX_DEVICES]; int devcnt = find_devices(devices, MAX_DEVICES); + if (devcnt == 0) + err = "No serial devices found."; for (int i = 0; i < devcnt; ++i) { result.append(CommPortPtr(new Serial(devices[i]))); free(devices[i]);