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.
This commit is contained in:
Sean Rhea
2010-02-06 11:18:11 -08:00
parent 9147369c41
commit f323780848
3 changed files with 11 additions and 6 deletions

View File

@@ -33,15 +33,18 @@ CommPort::addListFunction(ListFunction f)
QVector<CommPortPtr>
CommPort::listCommPorts(QString &err)
{
err = "";
QStringList errors;
QVector<CommPortPtr> result;
for (int i = 0; listFunctions && i < listFunctions->size(); ++i) {
QVector<CommPortPtr> tmp = (*listFunctions)[i](err);
if (err == "")
QString thisError = "";
QVector<CommPortPtr> tmp = (*listFunctions)[i](thisError);
if (thisError == "")
result << tmp;
else
err += "\n";
errors << thisError;
}
if (result.isEmpty() && !errors.isEmpty())
err = errors.join("\n");
return result;
}

View File

@@ -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);
}

View File

@@ -398,6 +398,8 @@ Serial::myListCommPorts(QString &err)
QVector<CommPortPtr> 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]);