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
ae7ed2cf
Commit
ae7ed2cf
authored
May 29, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3435 from DonLakeFlyer/PX4FlashBeta
Show PX4 beta version info for flash
parents
bc82f6f3
6ddffeeb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
22 deletions
+77
-22
FirmwareUpgrade.qml
src/VehicleSetup/FirmwareUpgrade.qml
+29
-8
FirmwareUpgradeController.cc
src/VehicleSetup/FirmwareUpgradeController.cc
+41
-11
FirmwareUpgradeController.h
src/VehicleSetup/FirmwareUpgradeController.h
+7
-3
No files found.
src/VehicleSetup/FirmwareUpgrade.qml
View file @
ae7ed2cf
...
@@ -111,7 +111,7 @@ QGCView {
...
@@ -111,7 +111,7 @@ QGCView {
// We end up here when we detect a board plugged in after we've started upgrade
// We end up here when we detect a board plugged in after we've started upgrade
statusTextArea
.
append
(
highlightPrefix
+
qsTr
(
"
Found device
"
)
+
highlightSuffix
+
"
:
"
+
controller
.
boardType
)
statusTextArea
.
append
(
highlightPrefix
+
qsTr
(
"
Found device
"
)
+
highlightSuffix
+
"
:
"
+
controller
.
boardType
)
if
(
controller
.
boardType
==
"
Pixhawk
"
||
controller
.
boardType
==
"
AeroCore
"
||
controller
.
boardType
==
"
PX4 Flow
"
||
controller
.
boardType
==
"
PX4 FMU V1
"
||
controller
.
boardType
==
"
MindPX
"
)
{
if
(
controller
.
boardType
==
"
Pixhawk
"
||
controller
.
boardType
==
"
AeroCore
"
||
controller
.
boardType
==
"
PX4 Flow
"
||
controller
.
boardType
==
"
PX4 FMU V1
"
||
controller
.
boardType
==
"
MindPX
"
)
{
showDialog
(
pixhawkFirmwareSelectDialog
,
title
,
qgcView
.
showDialogDefaultWidth
,
StandardButton
.
Ok
|
StandardButton
.
Cancel
)
showDialog
(
pixhawkFirmwareSelectDialog
Component
,
title
,
qgcView
.
showDialogDefaultWidth
,
StandardButton
.
Ok
|
StandardButton
.
Cancel
)
}
}
}
}
}
}
...
@@ -130,13 +130,33 @@ QGCView {
...
@@ -130,13 +130,33 @@ QGCView {
}
}
Component
{
Component
{
id
:
pixhawkFirmwareSelectDialog
id
:
pixhawkFirmwareSelectDialog
Component
QGCViewDialog
{
QGCViewDialog
{
anchors.fill
:
parent
id
:
pixhawkFirmwareSelectDialog
anchors.fill
:
parent
property
bool
showFirmwareTypeSelection
:
_advanced
.
checked
property
bool
px4Flow
:
controller
.
boardType
==
"
PX4 Flow
"
function
updatePX4VersionDisplay
()
{
var
versionString
=
""
if
(
_advanced
.
checked
)
{
switch
(
controller
.
selectedFirmwareType
)
{
case
FirmwareUpgradeController.StableFirmware
:
versionString
=
controller
.
px4StableVersion
break
case
FirmwareUpgradeController.BetaFirmware
:
versionString
=
controller
.
px4BetaVersion
break
}
}
else
{
versionString
=
controller
.
px4StableVersion
}
px4FlightStack
.
text
=
qsTr
(
"
PX4 Flight Stack
"
)
+
versionString
}
property
bool
showFirmwareTypeSelection
:
_advanced
.
checked
Component.onCompleted
:
updatePX4VersionDisplay
()
property
bool
px4Flow
:
controller
.
boardType
==
"
PX4 Flow
"
function
accept
()
{
function
accept
()
{
hideDialog
()
hideDialog
()
...
@@ -221,7 +241,7 @@ QGCView {
...
@@ -221,7 +241,7 @@ QGCView {
id
:
px4FlightStack
id
:
px4FlightStack
checked
:
true
checked
:
true
exclusiveGroup
:
firmwareGroup
exclusiveGroup
:
firmwareGroup
text
:
qsTr
(
"
PX4 Flight Stack
"
)
+
controller
.
px4StableVersion
text
:
qsTr
(
"
PX4 Flight Stack
"
)
visible
:
!
px4Flow
visible
:
!
px4Flow
onClicked
:
parent
.
firmwareVersionChanged
(
firmwareTypeList
)
onClicked
:
parent
.
firmwareVersionChanged
(
firmwareTypeList
)
...
@@ -263,6 +283,7 @@ QGCView {
...
@@ -263,6 +283,7 @@ QGCView {
onClicked
:
{
onClicked
:
{
firmwareVersionCombo
.
currentIndex
=
0
firmwareVersionCombo
.
currentIndex
=
0
firmwareVersionWarningLabel
.
visible
=
false
firmwareVersionWarningLabel
.
visible
=
false
updatePX4VersionDisplay
()
}
}
}
}
...
@@ -307,6 +328,7 @@ QGCView {
...
@@ -307,6 +328,7 @@ QGCView {
}
else
{
}
else
{
firmwareVersionWarningLabel
.
visible
=
false
firmwareVersionWarningLabel
.
visible
=
false
}
}
updatePX4VersionDisplay
()
}
}
}
}
...
@@ -318,8 +340,7 @@ QGCView {
...
@@ -318,8 +340,7 @@ QGCView {
}
}
}
// Column
}
// Column
}
// QGCViewDialog
}
// QGCViewDialog
}
// Component - pixhawkFirmwareSelectDialog
}
// Component - pixhawkFirmwareSelectDialogComponent
Component
{
Component
{
id
:
firmwareWarningDialog
id
:
firmwareWarningDialog
...
...
src/VehicleSetup/FirmwareUpgradeController.cc
View file @
ae7ed2cf
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include <QRegularExpression>
#include <QRegularExpression>
#include <QJsonDocument>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonObject>
#include <QJsonArray>
struct
FirmwareToUrlElement_t
{
struct
FirmwareToUrlElement_t
{
FirmwareUpgradeController
::
AutoPilotStackType_t
stackType
;
FirmwareUpgradeController
::
AutoPilotStackType_t
stackType
;
...
@@ -834,18 +835,18 @@ FirmwareUpgradeController::FirmwareVehicleType_t FirmwareUpgradeController::vehi
...
@@ -834,18 +835,18 @@ FirmwareUpgradeController::FirmwareVehicleType_t FirmwareUpgradeController::vehi
void
FirmwareUpgradeController
::
_determinePX4StableVersion
(
void
)
void
FirmwareUpgradeController
::
_determinePX4StableVersion
(
void
)
{
{
QGCFileDownload
*
downloader
=
new
QGCFileDownload
(
this
);
QGCFileDownload
*
downloader
=
new
QGCFileDownload
(
this
);
connect
(
downloader
,
&
QGCFileDownload
::
downloadFinished
,
this
,
&
FirmwareUpgradeController
::
_px4
Stable
GithubDownloadFinished
);
connect
(
downloader
,
&
QGCFileDownload
::
downloadFinished
,
this
,
&
FirmwareUpgradeController
::
_px4
Releases
GithubDownloadFinished
);
connect
(
downloader
,
&
QGCFileDownload
::
error
,
this
,
&
FirmwareUpgradeController
::
_px4
Stable
GithubDownloadError
);
connect
(
downloader
,
&
QGCFileDownload
::
error
,
this
,
&
FirmwareUpgradeController
::
_px4
Releases
GithubDownloadError
);
downloader
->
download
(
QStringLiteral
(
"https://api.github.com/repos/PX4/Firmware/releases
/latest
"
));
downloader
->
download
(
QStringLiteral
(
"https://api.github.com/repos/PX4/Firmware/releases"
));
}
}
void
FirmwareUpgradeController
::
_px4
Stable
GithubDownloadFinished
(
QString
remoteFile
,
QString
localFile
)
void
FirmwareUpgradeController
::
_px4
Releases
GithubDownloadFinished
(
QString
remoteFile
,
QString
localFile
)
{
{
Q_UNUSED
(
remoteFile
);
Q_UNUSED
(
remoteFile
);
QFile
jsonFile
(
localFile
);
QFile
jsonFile
(
localFile
);
if
(
!
jsonFile
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
if
(
!
jsonFile
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
q
Warning
()
<<
"Unable to open github
json file"
<<
localFile
<<
jsonFile
.
errorString
();
q
CWarning
(
FirmwareUpgradeLog
)
<<
"Unable to open github px4 releases
json file"
<<
localFile
<<
jsonFile
.
errorString
();
return
;
return
;
}
}
QByteArray
bytes
=
jsonFile
.
readAll
();
QByteArray
bytes
=
jsonFile
.
readAll
();
...
@@ -854,16 +855,45 @@ void FirmwareUpgradeController::_px4StableGithubDownloadFinished(QString remoteF
...
@@ -854,16 +855,45 @@ void FirmwareUpgradeController::_px4StableGithubDownloadFinished(QString remoteF
QJsonParseError
jsonParseError
;
QJsonParseError
jsonParseError
;
QJsonDocument
doc
=
QJsonDocument
::
fromJson
(
bytes
,
&
jsonParseError
);
QJsonDocument
doc
=
QJsonDocument
::
fromJson
(
bytes
,
&
jsonParseError
);
if
(
jsonParseError
.
error
!=
QJsonParseError
::
NoError
)
{
if
(
jsonParseError
.
error
!=
QJsonParseError
::
NoError
)
{
q
Warning
()
<<
"Unable to open
json document"
<<
localFile
<<
jsonParseError
.
errorString
();
q
CWarning
(
FirmwareUpgradeLog
)
<<
"Unable to open px4 releases
json document"
<<
localFile
<<
jsonParseError
.
errorString
();
return
;
return
;
}
}
QJsonObject
json
=
doc
.
object
();
_px4StableVersion
=
json
[
"name"
].
toString
();
// Json should be an array of release objects
emit
px4StableVersionChanged
(
_px4StableVersion
);
if
(
!
doc
.
isArray
())
{
qCWarning
(
FirmwareUpgradeLog
)
<<
"px4 releases json document is not an array"
<<
localFile
;
return
;
}
QJsonArray
releases
=
doc
.
array
();
// The first release marked prerelease=false is stable
// The first release marked prerelease=true is beta
bool
foundStable
=
false
;
bool
foundBeta
=
false
;
for
(
int
i
=
0
;
i
<
releases
.
count
()
&&
(
!
foundStable
||
!
foundBeta
);
i
++
)
{
QJsonObject
release
=
releases
[
i
].
toObject
();
if
(
!
foundStable
&&
!
release
[
"prerelease"
].
toBool
())
{
_px4StableVersion
=
release
[
"name"
].
toString
();
emit
px4StableVersionChanged
(
_px4StableVersion
);
qCDebug
(
FirmwareUpgradeLog
())
<<
"Found px4 stable version"
<<
_px4StableVersion
;
foundStable
=
true
;
}
else
if
(
!
foundBeta
&&
release
[
"prerelease"
].
toBool
())
{
_px4BetaVersion
=
release
[
"name"
].
toString
();
emit
px4StableVersionChanged
(
_px4BetaVersion
);
qCDebug
(
FirmwareUpgradeLog
())
<<
"Found px4 beta version"
<<
_px4BetaVersion
;
foundBeta
=
true
;
}
}
if
(
!
foundStable
)
{
qCDebug
(
FirmwareUpgradeLog
())
<<
"Unable to find px4 stable version"
<<
localFile
;
}
if
(
!
foundBeta
)
{
qCDebug
(
FirmwareUpgradeLog
())
<<
"Unable to find px4 beta version"
<<
localFile
;
}
}
}
void
FirmwareUpgradeController
::
_px4
Stable
GithubDownloadError
(
QString
errorMsg
)
void
FirmwareUpgradeController
::
_px4
Releases
GithubDownloadError
(
QString
errorMsg
)
{
{
q
Warning
()
<<
"PX4 stable
github download failed"
<<
errorMsg
;
q
CWarning
(
FirmwareUpgradeLog
)
<<
"PX4 releases
github download failed"
<<
errorMsg
;
}
}
src/VehicleSetup/FirmwareUpgradeController.h
View file @
ae7ed2cf
...
@@ -112,6 +112,7 @@ public:
...
@@ -112,6 +112,7 @@ public:
Q_PROPERTY
(
FirmwareType_t
selectedFirmwareType
READ
selectedFirmwareType
WRITE
setSelectedFirmwareType
NOTIFY
selectedFirmwareTypeChanged
)
Q_PROPERTY
(
FirmwareType_t
selectedFirmwareType
READ
selectedFirmwareType
WRITE
setSelectedFirmwareType
NOTIFY
selectedFirmwareTypeChanged
)
Q_PROPERTY
(
QStringList
apmAvailableVersions
READ
apmAvailableVersions
NOTIFY
apmAvailableVersionsChanged
)
Q_PROPERTY
(
QStringList
apmAvailableVersions
READ
apmAvailableVersions
NOTIFY
apmAvailableVersionsChanged
)
Q_PROPERTY
(
QString
px4StableVersion
READ
px4StableVersion
NOTIFY
px4StableVersionChanged
)
Q_PROPERTY
(
QString
px4StableVersion
READ
px4StableVersion
NOTIFY
px4StableVersionChanged
)
Q_PROPERTY
(
QString
px4BetaVersion
READ
px4BetaVersion
NOTIFY
px4BetaVersionChanged
)
/// TextArea for log output
/// TextArea for log output
Q_PROPERTY
(
QQuickItem
*
statusLog
READ
statusLog
WRITE
setStatusLog
)
Q_PROPERTY
(
QQuickItem
*
statusLog
READ
statusLog
WRITE
setStatusLog
)
...
@@ -152,6 +153,7 @@ public:
...
@@ -152,6 +153,7 @@ public:
QStringList
apmAvailableVersions
(
void
);
QStringList
apmAvailableVersions
(
void
);
QString
px4StableVersion
(
void
)
{
return
_px4StableVersion
;
}
QString
px4StableVersion
(
void
)
{
return
_px4StableVersion
;
}
QString
px4BetaVersion
(
void
)
{
return
_px4BetaVersion
;
}
signals:
signals:
void
boardFound
(
void
);
void
boardFound
(
void
);
...
@@ -163,7 +165,8 @@ signals:
...
@@ -163,7 +165,8 @@ signals:
void
selectedFirmwareTypeChanged
(
FirmwareType_t
firmwareType
);
void
selectedFirmwareTypeChanged
(
FirmwareType_t
firmwareType
);
void
apmAvailableVersionsChanged
(
void
);
void
apmAvailableVersionsChanged
(
void
);
void
px4StableVersionChanged
(
const
QString
&
px4StableVersion
);
void
px4StableVersionChanged
(
const
QString
&
px4StableVersion
);
void
px4BetaVersionChanged
(
const
QString
&
px4BetaVersion
);
private
slots
:
private
slots
:
void
_downloadProgress
(
qint64
curr
,
qint64
total
);
void
_downloadProgress
(
qint64
curr
,
qint64
total
);
void
_downloadFinished
(
void
);
void
_downloadFinished
(
void
);
...
@@ -181,8 +184,8 @@ private slots:
...
@@ -181,8 +184,8 @@ private slots:
void
_eraseComplete
(
void
);
void
_eraseComplete
(
void
);
void
_eraseProgressTick
(
void
);
void
_eraseProgressTick
(
void
);
void
_apmVersionDownloadFinished
(
QString
remoteFile
,
QString
localFile
);
void
_apmVersionDownloadFinished
(
QString
remoteFile
,
QString
localFile
);
void
_px4
Stable
GithubDownloadFinished
(
QString
remoteFile
,
QString
localFile
);
void
_px4
Releases
GithubDownloadFinished
(
QString
remoteFile
,
QString
localFile
);
void
_px4
Stable
GithubDownloadError
(
QString
errorMsg
);
void
_px4
Releases
GithubDownloadError
(
QString
errorMsg
);
private:
private:
void
_getFirmwareFile
(
FirmwareIdentifier
firmwareId
);
void
_getFirmwareFile
(
FirmwareIdentifier
firmwareId
);
...
@@ -251,6 +254,7 @@ private:
...
@@ -251,6 +254,7 @@ private:
FirmwareImage
*
_image
;
FirmwareImage
*
_image
;
QString
_px4StableVersion
;
// Version strange for latest PX4 stable
QString
_px4StableVersion
;
// Version strange for latest PX4 stable
QString
_px4BetaVersion
;
// Version strange for latest PX4 beta
};
};
// global hashing function
// global hashing function
...
...
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