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
b3b3a97b
Commit
b3b3a97b
authored
May 12, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better handling of connections and plugged in boards
parent
2a9db76e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
197 additions
and
117 deletions
+197
-117
FirmwareUpgrade.qml
src/VehicleSetup/FirmwareUpgrade.qml
+152
-91
FirmwareUpgradeController.cc
src/VehicleSetup/FirmwareUpgradeController.cc
+19
-25
FirmwareUpgradeController.h
src/VehicleSetup/FirmwareUpgradeController.h
+7
-1
PX4FirmwareUpgradeThread.cc
src/VehicleSetup/PX4FirmwareUpgradeThread.cc
+16
-0
PX4FirmwareUpgradeThread.h
src/VehicleSetup/PX4FirmwareUpgradeThread.h
+3
-0
No files found.
src/VehicleSetup/FirmwareUpgrade.qml
View file @
b3b3a97b
...
@@ -24,108 +24,169 @@
...
@@ -24,108 +24,169 @@
import
QtQuick
2.3
import
QtQuick
2.3
import
QtQuick
.
Controls
1.2
import
QtQuick
.
Controls
1.2
import
QtQuick
.
Controls
.
Styles
1.2
import
QtQuick
.
Controls
.
Styles
1.2
import
QtQuick
.
Dialogs
1.2
import
QGroundControl
.
Controls
1.0
import
QGroundControl
.
Controls
1.0
import
QGroundControl
.
FactSystem
1.0
import
QGroundControl
.
FactControls
1.0
import
QGroundControl
.
FactControls
1.0
import
QGroundControl
.
Palette
1.0
import
QGroundControl
.
Palette
1.0
import
QGroundControl
.
Controllers
1.0
import
QGroundControl
.
Controllers
1.0
import
QGroundControl
.
ScreenTools
1.0
import
QGroundControl
.
ScreenTools
1.0
Rectangle
{
QGCView
{
width
:
600
viewComponent
:
viewPanelComponent
height
:
600
property
string
firmwareWarningMessage
property
var
qgcPal
:
QGCPalette
{
colorGroupEnabled
:
true
}
property
FirmwareUpgradeController
controller
:
FirmwareUpgradeController
{
Component
{
upgradeButton
:
upgradeButton
id
:
viewPanelComponent
progressBar
:
progressBar
statusLog
:
statusTextArea
QGCViewPanel
{
firmwareType
:
FirmwareUpgradeController
.
StableFirmware
id
:
panel
}
FirmwareUpgradeController
{
color
:
qgcPal
.
window
id
:
controller
upgradeButton
:
upgradeButton
Column
{
progressBar
:
progressBar
anchors.fill
:
parent
statusLog
:
statusTextArea
firmwareType
:
FirmwareUpgradeController
.
StableFirmware
QGCLabel
{
text
:
"
FIRMWARE UPDATE
"
onShowMessage
:
{
font.pointSize
:
ScreenTools
.
fontPointFactor
*
(
20
);
panel
.
showMessage
(
title
,
message
,
StandardButton
.
Ok
)
}
}
}
Item
{
// Just used as a spacer
Component
{
height
:
20
id
:
firmwareWarningComponent
width
:
10
}
QGCViewMessage
{
message
:
firmwareWarningMessage
Row
{
spacing
:
10
function
accept
()
{
panel
.
hideDialog
()
ListModel
{
controller
.
doFirmwareUpgrade
();
id
:
firmwareItems
}
ListElement
{
}
text
:
qsTr
(
"
Standard Version (stable)
"
);
}
firmwareType
:
FirmwareUpgradeController
.
StableFirmware
Column
{
anchors.fill
:
parent
QGCLabel
{
text
:
"
FIRMWARE UPDATE
"
font.pointSize
:
ScreenTools
.
fontPointFactor
*
(
20
);
}
}
ListElement
{
text
:
qsTr
(
"
Beta Testing (beta)
"
);
Item
{
firmwareType
:
FirmwareUpgradeController
.
BetaFirmware
// Just used as a spacer
height
:
20
width
:
10
}
}
ListElement
{
text
:
qsTr
(
"
Developer Build (master)
"
);
Row
{
firmwareType
:
FirmwareUpgradeController
.
DeveloperFirmware
spacing
:
10
ListModel
{
id
:
firmwareItems
ListElement
{
text
:
qsTr
(
"
Standard Version (stable)
"
);
firmwareType
:
FirmwareUpgradeController
.
StableFirmware
}
ListElement
{
text
:
qsTr
(
"
Beta Testing (beta)
"
);
firmwareType
:
FirmwareUpgradeController
.
BetaFirmware
}
ListElement
{
text
:
qsTr
(
"
Developer Build (master)
"
);
firmwareType
:
FirmwareUpgradeController
.
DeveloperFirmware
}
ListElement
{
text
:
qsTr
(
"
Custom firmware file...
"
);
firmwareType
:
FirmwareUpgradeController
.
CustomFirmware
}
}
QGCComboBox
{
id
:
firmwareCombo
width
:
200
height
:
upgradeButton
.
height
model
:
firmwareItems
}
QGCButton
{
id
:
upgradeButton
text
:
"
UPGRADE
"
primary
:
true
onClicked
:
{
if
(
controller
.
activeQGCConnections
())
{
panel
.
showMessage
(
"
Firmware Upgrade
"
,
"
There are still vehicles connected to QGroundControl.
"
+
"
You must disconnect all vehicles from QGroundControl prior to Firmware Upgrade.
"
,
StandardButton
.
Ok
)
return
}
if
(
controller
.
pluggedInBoard
())
{
panel
.
showMessage
(
"
Firmware Upgrade
"
,
"
You vehicle is currently connected via USB.
"
+
"
You must unplug your vehicle from USB prior to Firmware Upgrade.
"
,
StandardButton
.
Ok
)
return
}
controller
.
firmwareType
=
firmwareItems
.
get
(
firmwareCombo
.
currentIndex
).
firmwareType
if
(
controller
.
firmwareType
==
1
)
{
firmwareWarningMessage
=
"
WARNING: BETA FIRMWARE
\n
"
+
"
This firmware version is ONLY intended for beta testers.
"
+
"
Although it has received FLIGHT TESTING, it represents actively changed code.
"
+
"
Do NOT use for normal operation.
\n\n
"
+
"
Click Cancel to abort upgrade, Click Ok to Upgrade anwyay
"
panel
.
showDialog
(
firmwareWarningComponent
,
"
Firmware Upgrade
"
,
50
,
StandardButton
.
Cancel
|
StandardButton
.
Ok
)
}
else
if
(
controller
.
firmwareType
==
2
)
{
firmwareWarningMessage
=
"
WARNING: CONTINUOUS BUILD FIRMWARE
\n
"
+
"
This firmware has NOT BEEN FLIGHT TESTED.
"
+
"
It is only intended for DEVELOPERS.
"
+
"
Run bench tests without props first.
"
+
"
Do NOT fly this without addional safety precautions.
"
+
"
Follow the mailing list actively when using it.
\n\n
"
+
"
Click Cancel to abort upgrade, Click Ok to Upgrade anwyay
"
panel
.
showDialog
(
firmwareWarningComponent
,
"
Firmware Upgrade
"
,
50
,
StandardButton
.
Cancel
|
StandardButton
.
Ok
)
}
else
{
controller
.
doFirmwareUpgrade
();
}
}
}
}
}
ListElement
{
text
:
qsTr
(
"
Custom firmware file...
"
);
Item
{
firmwareType
:
FirmwareUpgradeController
.
CustomFirmware
// Just used as a spacer
height
:
20
width
:
10
}
}
}
QGCComboBox
{
ProgressBar
{
id
:
firmwareCombo
id
:
progressBar
width
:
200
width
:
parent
.
width
height
:
upgradeButton
.
height
}
model
:
firmwareItems
}
QGCButton
{
TextArea
{
id
:
upgradeButton
id
:
statusTextArea
text
:
"
UPGRADE
"
primary
:
true
width
:
parent
.
width
onClicked
:
{
height
:
300
controller
.
firmwareType
=
firmwareItems
.
get
(
firmwareCombo
.
currentIndex
).
firmwareType
readOnly
:
true
controller
.
doFirmwareUpgrade
();
frameVisible
:
false
font.pointSize
:
ScreenTools
.
defaultFontPointSize
text
:
qsTr
(
"
Please disconnect all vehicles from QGroundControl before selecting Upgrade.
"
)
style
:
TextAreaStyle
{
textColor
:
qgcPal
.
text
backgroundColor
:
qgcPal
.
windowShade
}
}
}
}
}
// Column
}
}
// QGCViewPanel
}
// Component - View Panel
Item
{
}
// QGCView
// Just used as a spacer
\ No newline at end of file
height
:
20
width
:
10
}
ProgressBar
{
id
:
progressBar
width
:
parent
.
width
}
TextArea
{
id
:
statusTextArea
width
:
parent
.
width
height
:
300
readOnly
:
true
frameVisible
:
false
font.pointSize
:
ScreenTools
.
defaultFontPointSize
text
:
qsTr
(
"
Please disconnect all vehicles from QGroundControl before selecting Upgrade.
"
)
style
:
TextAreaStyle
{
textColor
:
qgcPal
.
text
backgroundColor
:
qgcPal
.
windowShade
}
}
}
}
src/VehicleSetup/FirmwareUpgradeController.cc
View file @
b3b3a97b
...
@@ -74,7 +74,11 @@ void FirmwareUpgradeController::_cancel(void)
...
@@ -74,7 +74,11 @@ void FirmwareUpgradeController::_cancel(void)
/// @brief Begins the process or searching for the board
/// @brief Begins the process or searching for the board
void
FirmwareUpgradeController
::
_findBoard
(
void
)
void
FirmwareUpgradeController
::
_findBoard
(
void
)
{
{
_appendStatusLog
(
tr
(
"Plug your board into USB now..."
));
QString
msg
(
"Plug your board into USB now. Press Ok when board is plugged in."
);
_appendStatusLog
(
msg
);
emit
showMessage
(
"Firmware Upgrade"
,
msg
);
_searchingForBoard
=
true
;
_searchingForBoard
=
true
;
_threadController
->
findBoard
(
_findBoardTimeoutMsec
);
_threadController
->
findBoard
(
_findBoardTimeoutMsec
);
}
}
...
@@ -84,9 +88,10 @@ void FirmwareUpgradeController::_foundBoard(bool firstTry, const QString portNam
...
@@ -84,9 +88,10 @@ void FirmwareUpgradeController::_foundBoard(bool firstTry, const QString portNam
{
{
if
(
firstTry
)
{
if
(
firstTry
)
{
// Board is still plugged
// Board is still plugged
_appendStatusLog
(
tr
(
"Please unplug your board before beginning the Firmware Upgrade process."
));
_appendStatusLog
(
tr
(
"Click Upgrade again once the board is unplugged."
));
_cancel
();
_cancel
();
emit
showMessage
(
"Board plugged in"
,
"Please unplug your board before beginning the Firmware Upgrade process. "
"Click Upgrade again once the board is unplugged."
);
}
else
{
}
else
{
_portName
=
portName
;
_portName
=
portName
;
_portDescription
=
portDescription
;
_portDescription
=
portDescription
;
...
@@ -142,8 +147,8 @@ void FirmwareUpgradeController::_findTimeout(void)
...
@@ -142,8 +147,8 @@ void FirmwareUpgradeController::_findTimeout(void)
}
else
{
}
else
{
msg
=
tr
(
"Unable to communicate with Bootloader. If the board is currently connected via USB. Disconnect it and try Upgrade again."
);
msg
=
tr
(
"Unable to communicate with Bootloader. If the board is currently connected via USB. Disconnect it and try Upgrade again."
);
}
}
_appendStatusLog
(
msg
);
_cancel
();
_cancel
();
emit
showMessage
(
"Error"
,
msg
);
}
}
/// @brief Prompts the user to select a firmware file if needed and moves the state machine to the next state.
/// @brief Prompts the user to select a firmware file if needed and moves the state machine to the next state.
...
@@ -602,27 +607,6 @@ void FirmwareUpgradeController::_eraseProgressTick(void)
...
@@ -602,27 +607,6 @@ void FirmwareUpgradeController::_eraseProgressTick(void)
void
FirmwareUpgradeController
::
doFirmwareUpgrade
(
void
)
void
FirmwareUpgradeController
::
doFirmwareUpgrade
(
void
)
{
{
QString
warningMsg
;
if
(
_firmwareType
==
BetaFirmware
)
{
warningMsg
=
tr
(
"WARNING: BETA FIRMWARE
\n
"
"This firmware version is ONLY intended for beta testers. "
"Although it has received FLIGHT TESTING, it represents actively changed code. Do NOT use for normal operation.
\n\n
"
"Are you sure you want to continue?"
);
}
else
if
(
_firmwareType
==
DeveloperFirmware
)
{
warningMsg
=
tr
(
"WARNING: CONTINUOUS BUILD FIRMWARE
\n
"
"This firmware has NOT BEEN FLIGHT TESTED. "
"It is only intended for DEVELOPERS. Run bench tests without props first. "
"Do NOT fly this without addional safety precautions. Follow the mailing "
"list actively when using it.
\n\n
"
"Are you sure you want to continue?"
);
}
if
(
!
warningMsg
.
isEmpty
())
{
if
(
QGCMessageBox
::
warning
(
tr
(
"Firmware Upgrade"
),
warningMsg
,
QGCMessageBox
::
Yes
|
QGCMessageBox
::
No
,
QGCMessageBox
::
No
)
==
QGCMessageBox
::
No
)
{
return
;
}
}
Q_ASSERT
(
_upgradeButton
);
Q_ASSERT
(
_upgradeButton
);
_upgradeButton
->
setEnabled
(
false
);
_upgradeButton
->
setEnabled
(
false
);
...
@@ -641,3 +625,13 @@ void FirmwareUpgradeController::_appendStatusLog(const QString& text)
...
@@ -641,3 +625,13 @@ void FirmwareUpgradeController::_appendStatusLog(const QString& text)
Q_RETURN_ARG
(
QVariant
,
returnedValue
),
Q_RETURN_ARG
(
QVariant
,
returnedValue
),
Q_ARG
(
QVariant
,
varText
));
Q_ARG
(
QVariant
,
varText
));
}
}
bool
FirmwareUpgradeController
::
activeQGCConnections
(
void
)
{
return
LinkManager
::
instance
()
->
anyConnectedLinks
();
}
bool
FirmwareUpgradeController
::
pluggedInBoard
(
void
)
{
return
_threadController
->
pluggedInBoard
();
}
\ No newline at end of file
src/VehicleSetup/FirmwareUpgradeController.h
View file @
b3b3a97b
...
@@ -49,7 +49,7 @@ class FirmwareUpgradeController : public QObject
...
@@ -49,7 +49,7 @@ class FirmwareUpgradeController : public QObject
public:
public:
FirmwareUpgradeController
(
void
);
FirmwareUpgradeController
(
void
);
/// Supported firmware types
/// Supported firmware types
. If you modify these you will need to update the qml file as well.
typedef
enum
{
typedef
enum
{
StableFirmware
,
StableFirmware
,
BetaFirmware
,
BetaFirmware
,
...
@@ -71,6 +71,9 @@ public:
...
@@ -71,6 +71,9 @@ public:
/// Progress bar for you know what
/// Progress bar for you know what
Q_PROPERTY
(
QQuickItem
*
progressBar
READ
progressBar
WRITE
setProgressBar
)
Q_PROPERTY
(
QQuickItem
*
progressBar
READ
progressBar
WRITE
setProgressBar
)
Q_INVOKABLE
bool
activeQGCConnections
(
void
);
Q_INVOKABLE
bool
pluggedInBoard
(
void
);
/// Begins the firware upgrade process
/// Begins the firware upgrade process
Q_INVOKABLE
void
doFirmwareUpgrade
(
void
);
Q_INVOKABLE
void
doFirmwareUpgrade
(
void
);
...
@@ -86,6 +89,9 @@ public:
...
@@ -86,6 +89,9 @@ public:
QQuickItem
*
statusLog
(
void
)
{
return
_statusLog
;
}
QQuickItem
*
statusLog
(
void
)
{
return
_statusLog
;
}
void
setStatusLog
(
QQuickItem
*
statusLog
)
{
_statusLog
=
statusLog
;
}
void
setStatusLog
(
QQuickItem
*
statusLog
)
{
_statusLog
=
statusLog
;
}
signals:
void
showMessage
(
const
QString
&
title
,
const
QString
&
message
);
private
slots
:
private
slots
:
void
_downloadProgress
(
qint64
curr
,
qint64
total
);
void
_downloadProgress
(
qint64
curr
,
qint64
total
);
void
_downloadFinished
(
void
);
void
_downloadFinished
(
void
);
...
...
src/VehicleSetup/PX4FirmwareUpgradeThread.cc
View file @
b3b3a97b
...
@@ -118,6 +118,22 @@ void PX4FirmwareUpgradeThreadWorker::_findBoardOnce(void)
...
@@ -118,6 +118,22 @@ void PX4FirmwareUpgradeThreadWorker::_findBoardOnce(void)
_timerRetry
->
start
();
_timerRetry
->
start
();
}
}
bool
PX4FirmwareUpgradeThreadController
::
pluggedInBoard
(
void
)
{
qDebug
()
<<
"pluggedInBoard"
;
QString
portName
;
QString
portDescription
;
foreach
(
QSerialPortInfo
info
,
QSerialPortInfo
::
availablePorts
())
{
if
(
!
info
.
portName
().
isEmpty
()
&&
(
info
.
description
().
contains
(
"PX4"
)
||
info
.
vendorIdentifier
()
==
9900
/* 3DR */
))
{
return
true
;
}
}
return
false
;
}
void
PX4FirmwareUpgradeThreadWorker
::
findBootloader
(
const
QString
portName
,
int
msecTimeout
)
void
PX4FirmwareUpgradeThreadWorker
::
findBootloader
(
const
QString
portName
,
int
msecTimeout
)
{
{
Q_UNUSED
(
msecTimeout
);
Q_UNUSED
(
msecTimeout
);
...
...
src/VehicleSetup/PX4FirmwareUpgradeThread.h
View file @
b3b3a97b
...
@@ -105,6 +105,9 @@ public:
...
@@ -105,6 +105,9 @@ public:
PX4FirmwareUpgradeThreadController
(
QObject
*
parent
=
NULL
);
PX4FirmwareUpgradeThreadController
(
QObject
*
parent
=
NULL
);
~
PX4FirmwareUpgradeThreadController
(
void
);
~
PX4FirmwareUpgradeThreadController
(
void
);
/// Returns true is a board is currently connected via USB
bool
pluggedInBoard
(
void
);
/// @brief Begins the process of searching for a PX4 board connected to any serial port.
/// @brief Begins the process of searching for a PX4 board connected to any serial port.
/// @param msecTimeout Numbers of msecs to continue looking for a board to become available.
/// @param msecTimeout Numbers of msecs to continue looking for a board to become available.
void
findBoard
(
int
msecTimeout
);
void
findBoard
(
int
msecTimeout
);
...
...
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