Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
f83ccb28
Commit
f83ccb28
authored
Jul 01, 2020
by
DonLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
cc0080b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
57 deletions
+9
-57
FirmwareUpgradeController.cc
src/VehicleSetup/FirmwareUpgradeController.cc
+9
-57
No files found.
src/VehicleSetup/FirmwareUpgradeController.cc
View file @
f83ccb28
...
...
@@ -15,7 +15,8 @@
#include "QGCCorePlugin.h"
#include "FirmwareUpgradeSettings.h"
#include "SettingsManager.h"
#include "QGCTemporaryFile.h"
#include "QGCZlib.h"
#include "JsonHelper.h"
#include <QStandardPaths>
#include <QRegularExpression>
...
...
@@ -892,68 +893,19 @@ void FirmwareUpgradeController::_ardupilotManifestDownloadFinished(QString remot
qCDebug
(
FirmwareUpgradeLog
)
<<
"_ardupilotManifestDownloadFinished"
<<
remoteFile
<<
localFile
;
QFile
inputFile
(
localFile
);
if
(
!
inputFile
.
open
(
QIODevice
::
ReadOnly
))
{
qCWarning
(
FirmwareUpgradeLog
)
<<
"Unable to open ArduPilot firmware manifest file for reading"
<<
localFile
<<
inputFile
.
errorString
();
QFile
::
remove
(
localFile
);
QString
jsonFileName
(
QDir
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
TempLocation
)).
absoluteFilePath
(
"ArduPilot.Manifest.json"
));
if
(
!
QGCZlib
::
inflateGzipFile
(
localFile
,
jsonFileName
))
{
qCWarning
(
FirmwareUpgradeLog
)
<<
"Inflate of compressed manifest failed"
<<
localFile
;
return
;
}
int
ret
;
const
int
cBuffer
=
1024
*
5
;
unsigned
char
inputBuffer
[
cBuffer
];
unsigned
char
outputBuffer
[
cBuffer
];
z_stream
strm
;
QByteArray
jsonBytes
;
strm
.
zalloc
=
nullptr
;
strm
.
zfree
=
nullptr
;
strm
.
opaque
=
nullptr
;
strm
.
avail_in
=
0
;
strm
.
next_in
=
nullptr
;
ret
=
inflateInit2
(
&
strm
,
16
+
MAX_WBITS
);
if
(
ret
!=
Z_OK
)
{
qCWarning
(
FirmwareUpgradeLog
)
<<
"inflateInit2 failed:"
<<
ret
;
QFile
::
remove
(
localFile
);
QString
errorString
;
QJsonDocument
doc
;
if
(
JsonHelper
::
isJsonFile
(
jsonFileName
,
doc
,
errorString
))
{
qCWarning
(
FirmwareUpgradeLog
)
<<
"Json file read failed"
<<
errorString
;
return
;
}
do
{
strm
.
avail_in
=
static_cast
<
unsigned
>
(
inputFile
.
read
((
char
*
)
inputBuffer
,
cBuffer
));
if
(
strm
.
avail_in
==
0
)
{
break
;
}
strm
.
next_in
=
inputBuffer
;
do
{
strm
.
avail_out
=
cBuffer
;
strm
.
next_out
=
outputBuffer
;
ret
=
inflate
(
&
strm
,
Z_NO_FLUSH
);
if
(
ret
!=
Z_OK
&&
ret
!=
Z_STREAM_END
)
{
qCWarning
(
FirmwareUpgradeLog
)
<<
"Inflate failed"
<<
ret
;
inflateEnd
(
&
strm
);
QFile
::
remove
(
localFile
);
return
;
}
unsigned
cBytesInflated
=
cBuffer
-
strm
.
avail_out
;
jsonBytes
.
append
((
char
*
)
outputBuffer
,
static_cast
<
int
>
(
cBytesInflated
));
}
while
(
strm
.
avail_out
==
0
);
}
while
(
ret
!=
Z_STREAM_END
);
inflateEnd
(
&
strm
);
inputFile
.
close
();
QFile
::
remove
(
localFile
);
QJsonParseError
jsonParseError
;
QJsonDocument
doc
=
QJsonDocument
::
fromJson
(
jsonBytes
,
&
jsonParseError
);
if
(
jsonParseError
.
error
!=
QJsonParseError
::
NoError
)
{
qCWarning
(
FirmwareUpgradeLog
)
<<
"Unable to open ArduPilot manifest json document"
<<
localFile
<<
jsonParseError
.
errorString
();
}
QJsonObject
json
=
doc
.
object
();
QJsonArray
rgFirmware
=
json
[
_manifestFirmwareJsonKey
].
toArray
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment