diff --git a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/SSP/port.cpp b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/SSP/port.cpp index c0d39daf2..961baeaa8 100644 --- a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/SSP/port.cpp +++ b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/SSP/port.cpp @@ -27,7 +27,7 @@ #include "port.h" #include "delay.h" #include -port::port(QString name, bool debug) : mstatus(port::closed), debug(debug) +port::port(QString name, bool debug) : debug(debug), mstatus(port::closed) { timer.start(); sport = new QSerialPort(); diff --git a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/main.cpp b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/main.cpp index 78a53545d..3d06e03eb 100644 --- a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/main.cpp +++ b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/main.cpp @@ -191,9 +191,9 @@ int main(int argc, char *argv[]) return -1; } } else if (!description.isEmpty()) { - retstatus = dfu.UploadDescription(description); - if (retstatus != OP_DFU::Last_operation_Success) { - standardOutput << "Upload failed with code:" << retstatus << endl; + OP_DFU::Status status = dfu.UploadDescription(description); + if (status != OP_DFU::Last_operation_Success) { + standardOutput << "Upload failed with code:" << status << endl; return -1; } } @@ -206,7 +206,6 @@ int main(int argc, char *argv[]) standardOutput << "ERROR device not readable\n" << endl; return false; } - qint32 size = ((OP_DFU::device)dfu.devices[device]).SizeOfCode; QByteArray fw; dfu.DownloadFirmware(&fw, 0); bool ret = dfu.SaveByteArrayToFile(file.toLatin1(), fw); diff --git a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/op_dfu.cpp b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/op_dfu.cpp index 12323fc36..a5345326f 100644 --- a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/op_dfu.cpp +++ b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/op_dfu.cpp @@ -346,7 +346,7 @@ OP_DFU::Status DFUObject::UploadDescription(QVariant desc) cout << "Starting uploading description\n"; QByteArray array; - if (desc.type() == QMetaType::QString) { + if (desc.type() == QVariant::String) { QString description = desc.toString(); if (description.length() % 4 != 0) { int pad = description.length() / 4; @@ -357,7 +357,7 @@ OP_DFU::Status DFUObject::UploadDescription(QVariant desc) description.append(padding); } array = description.toLatin1(); - } else if (desc.type() == QMetaType::QByteArray) { + } else if (desc.type() == QVariant::ByteArray) { array = desc.toByteArray(); } @@ -1110,6 +1110,10 @@ int DFUObject::receiveData(void *data, int size) if (time.elapsed() > 10000) { qDebug() << "____timeout"; } + if (x > size - 1) { + qDebug() << "Error buffer overrun"; + Q_ASSERT(false); + } return x; } }