mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-27 16:54:15 +01:00
OP-1476 - AutoUpload description from OPFW firmwares
This commit is contained in:
parent
8712a1dfdc
commit
5b968389a0
@ -168,11 +168,29 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
standardOutput << "Uploading..." << endl;
|
||||
bool retstatus = dfu.UploadFirmware(file.toLatin1(), verify, device);
|
||||
|
||||
if (!retstatus) {
|
||||
standardOutput << "Upload failed with code:" << retstatus << endl;
|
||||
return -1;
|
||||
}
|
||||
if (!description.isEmpty()) {
|
||||
while (!dfu.isFinished()) {
|
||||
QThread::msleep(500);
|
||||
}
|
||||
if (file.endsWith("opfw")) {
|
||||
QByteArray firmware;
|
||||
QFile fwfile(file);
|
||||
if (!fwfile.open(QIODevice::ReadOnly)) {
|
||||
standardOutput << "Cannot open file " << file << endl;
|
||||
return -1;
|
||||
}
|
||||
firmware = fwfile.readAll();
|
||||
QByteArray desc = firmware.right(100);
|
||||
OP_DFU::Status status = dfu.UploadDescription(desc);
|
||||
if (status != OP_DFU::Last_operation_Success) {
|
||||
standardOutput << "Upload failed with code:" << retstatus << endl;
|
||||
return -1;
|
||||
}
|
||||
} else if (!description.isEmpty()) {
|
||||
retstatus = dfu.UploadDescription(description);
|
||||
if (retstatus != OP_DFU::Last_operation_Success) {
|
||||
standardOutput << "Upload failed with code:" << retstatus << endl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user