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
d72f86d8
Commit
d72f86d8
authored
May 28, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show PX4 Stable version
parent
50b4f684
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
1 deletion
+49
-1
FirmwareUpgrade.qml
src/VehicleSetup/FirmwareUpgrade.qml
+1
-1
FirmwareUpgradeController.cc
src/VehicleSetup/FirmwareUpgradeController.cc
+40
-0
FirmwareUpgradeController.h
src/VehicleSetup/FirmwareUpgradeController.h
+8
-0
No files found.
src/VehicleSetup/FirmwareUpgrade.qml
View file @
d72f86d8
...
...
@@ -221,7 +221,7 @@ QGCView {
id
:
px4FlightStack
checked
:
true
exclusiveGroup
:
firmwareGroup
text
:
qsTr
(
"
PX4 Flight Stack
"
)
text
:
qsTr
(
"
PX4 Flight Stack
"
)
+
controller
.
px4StableVersion
visible
:
!
px4Flow
onClicked
:
parent
.
firmwareVersionChanged
(
firmwareTypeList
)
...
...
src/VehicleSetup/FirmwareUpgradeController.cc
View file @
d72f86d8
...
...
@@ -33,6 +33,8 @@
#include <QStandardPaths>
#include <QRegularExpression>
#include <QJsonDocument>
#include <QJsonObject>
struct
FirmwareToUrlElement_t
{
FirmwareUpgradeController
::
AutoPilotStackType_t
stackType
;
...
...
@@ -75,6 +77,7 @@ FirmwareUpgradeController::FirmwareUpgradeController(void)
connect
(
&
_eraseTimer
,
&
QTimer
::
timeout
,
this
,
&
FirmwareUpgradeController
::
_eraseProgressTick
);
_initFirmwareHash
();
_determinePX4StableVersion
();
}
FirmwareUpgradeController
::~
FirmwareUpgradeController
()
...
...
@@ -827,3 +830,40 @@ FirmwareUpgradeController::FirmwareVehicleType_t FirmwareUpgradeController::vehi
return
_apmVehicleTypeFromCurrentVersionList
[
index
];
}
void
FirmwareUpgradeController
::
_determinePX4StableVersion
(
void
)
{
QGCFileDownload
*
downloader
=
new
QGCFileDownload
(
this
);
connect
(
downloader
,
&
QGCFileDownload
::
downloadFinished
,
this
,
&
FirmwareUpgradeController
::
_px4StableGithubDownloadFinished
);
connect
(
downloader
,
&
QGCFileDownload
::
error
,
this
,
&
FirmwareUpgradeController
::
_px4StableGithubDownloadError
);
downloader
->
download
(
QStringLiteral
(
"https://api.github.com/repos/PX4/Firmware/releases/latest"
));
}
void
FirmwareUpgradeController
::
_px4StableGithubDownloadFinished
(
QString
remoteFile
,
QString
localFile
)
{
Q_UNUSED
(
remoteFile
);
QFile
jsonFile
(
localFile
);
if
(
!
jsonFile
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
qWarning
()
<<
"Unable to open github json file"
<<
localFile
<<
jsonFile
.
errorString
();
return
;
}
QByteArray
bytes
=
jsonFile
.
readAll
();
jsonFile
.
close
();
QJsonParseError
jsonParseError
;
QJsonDocument
doc
=
QJsonDocument
::
fromJson
(
bytes
,
&
jsonParseError
);
if
(
jsonParseError
.
error
!=
QJsonParseError
::
NoError
)
{
qWarning
()
<<
"Unable to open json document"
<<
localFile
<<
jsonParseError
.
errorString
();
return
;
}
QJsonObject
json
=
doc
.
object
();
_px4StableVersion
=
json
[
"name"
].
toString
();
emit
px4StableVersionChanged
(
_px4StableVersion
);
}
void
FirmwareUpgradeController
::
_px4StableGithubDownloadError
(
QString
errorMsg
)
{
qWarning
()
<<
"PX4 stable github download failed"
<<
errorMsg
;
}
src/VehicleSetup/FirmwareUpgradeController.h
View file @
d72f86d8
...
...
@@ -111,6 +111,7 @@ public:
Q_PROPERTY
(
QString
boardType
MEMBER
_foundBoardTypeName
NOTIFY
boardFound
)
Q_PROPERTY
(
FirmwareType_t
selectedFirmwareType
READ
selectedFirmwareType
WRITE
setSelectedFirmwareType
NOTIFY
selectedFirmwareTypeChanged
)
Q_PROPERTY
(
QStringList
apmAvailableVersions
READ
apmAvailableVersions
NOTIFY
apmAvailableVersionsChanged
)
Q_PROPERTY
(
QString
px4StableVersion
READ
px4StableVersion
NOTIFY
px4StableVersionChanged
)
/// TextArea for log output
Q_PROPERTY
(
QQuickItem
*
statusLog
READ
statusLog
WRITE
setStatusLog
)
...
...
@@ -150,6 +151,7 @@ public:
QString
firmwareTypeAsString
(
FirmwareType_t
type
)
const
;
QStringList
apmAvailableVersions
(
void
);
QString
px4StableVersion
(
void
)
{
return
_px4StableVersion
;
}
signals:
void
boardFound
(
void
);
...
...
@@ -160,6 +162,7 @@ signals:
void
error
(
void
);
void
selectedFirmwareTypeChanged
(
FirmwareType_t
firmwareType
);
void
apmAvailableVersionsChanged
(
void
);
void
px4StableVersionChanged
(
const
QString
&
px4StableVersion
);
private
slots
:
void
_downloadProgress
(
qint64
curr
,
qint64
total
);
...
...
@@ -178,6 +181,8 @@ private slots:
void
_eraseComplete
(
void
);
void
_eraseProgressTick
(
void
);
void
_apmVersionDownloadFinished
(
QString
remoteFile
,
QString
localFile
);
void
_px4StableGithubDownloadFinished
(
QString
remoteFile
,
QString
localFile
);
void
_px4StableGithubDownloadError
(
QString
errorMsg
);
private:
void
_getFirmwareFile
(
FirmwareIdentifier
firmwareId
);
...
...
@@ -188,6 +193,7 @@ private:
void
_loadAPMVersions
(
QGCSerialPortInfo
::
BoardType_t
boardType
);
QHash
<
FirmwareIdentifier
,
QString
>*
_firmwareHashForBoardId
(
int
boardId
);
QHash
<
FirmwareIdentifier
,
QString
>*
_firmwareHashForBoardType
(
QGCSerialPortInfo
::
BoardType_t
boardType
);
void
_determinePX4StableVersion
(
void
);
QString
_portName
;
QString
_portDescription
;
...
...
@@ -243,6 +249,8 @@ private:
FirmwareType_t
_selectedFirmwareType
;
FirmwareImage
*
_image
;
QString
_px4StableVersion
;
// Version strange for latest PX4 stable
};
// 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