1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

LP-10 Fix bugs and warnings in USB_UPLOAD_TOOL

This commit is contained in:
Stefan Karlsson 2015-07-12 17:20:16 +02:00
parent a28d668758
commit 1a0f5f1bef
3 changed files with 10 additions and 7 deletions

View File

@ -27,7 +27,7 @@
#include "port.h"
#include "delay.h"
#include <QDebug>
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();

View File

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

View File

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