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
946b7ea8
Commit
946b7ea8
authored
Nov 14, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Centralize board type detection
parent
e855eb08
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
154 additions
and
10 deletions
+154
-10
qgroundcontrol.pro
qgroundcontrol.pro
+2
-0
QGCSerialPortInfo.cc
src/comm/QGCSerialPortInfo.cc
+106
-0
QGCSerialPortInfo.h
src/comm/QGCSerialPortInfo.h
+40
-4
main.cc
src/main.cc
+6
-6
No files found.
qgroundcontrol.pro
View file @
946b7ea8
...
...
@@ -302,6 +302,7 @@ WindowsBuild {
!
iOSBuild
{
HEADERS
+=
\
src
/
comm
/
QGCSerialPortInfo
.
h
\
src
/
comm
/
SerialLink
.
h
\
src
/
ui
/
SerialConfigurationWindow
.
h
\
}
...
...
@@ -407,6 +408,7 @@ SOURCES += \
!
iOSBuild
{
SOURCES
+=
\
src
/
comm
/
QGCSerialPortInfo
.
cc
\
src
/
comm
/
SerialLink
.
cc
\
src
/
ui
/
SerialConfigurationWindow
.
cc
\
}
...
...
src/comm/QGCSerialPortInfo.cc
0 → 100644
View file @
946b7ea8
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include "QGCSerialPortInfo.h"
QGC_LOGGING_CATEGORY
(
QGCSerialPortInfoLog
,
"QGCSerialPortInfoLog"
)
QGCSerialPortInfo
::
QGCSerialPortInfo
(
const
QSerialPort
&
port
)
:
QSerialPortInfo
(
port
)
{
}
QGCSerialPortInfo
::
BoardType_t
QGCSerialPortInfo
::
boardType
(
void
)
const
{
if
(
isNull
())
{
return
BoardTypeUnknown
;
}
BoardType_t
boardType
=
BoardTypeUnknown
;
switch
(
vendorIdentifier
())
{
case
px4VendorId
:
if
(
productIdentifier
()
==
pixhawkFMUV2ProductId
||
productIdentifier
()
==
pixhawkFMUV2OldBootloaderProductId
)
{
qCDebug
(
QGCSerialPortInfoLog
)
<<
"Found PX4 FMU V2"
;
boardType
=
BoardTypePX4FMUV2
;
}
else
if
(
productIdentifier
()
==
pixhawkFMUV1ProductId
)
{
qCDebug
(
QGCSerialPortInfoLog
)
<<
"Found PX4 FMU V1"
;
boardType
=
BoardTypePX4FMUV1
;
}
else
if
(
productIdentifier
()
==
px4FlowProductId
)
{
qCDebug
(
QGCSerialPortInfoLog
)
<<
"Found PX4 Flow"
;
boardType
=
BoardTypePX4Flow
;
}
else
if
(
productIdentifier
()
==
AeroCoreProductId
)
{
qCDebug
(
QGCSerialPortInfoLog
)
<<
"Found AeroCore"
;
boardType
=
BoardTypeAeroCore
;
}
break
;
case
threeDRRadioVendorId
:
if
(
productIdentifier
()
==
threeDRRadioProductId
)
{
qCDebug
(
QGCSerialPortInfoLog
)
<<
"Found 3DR Radio"
;
boardType
=
BoardType3drRadio
;
}
break
;
}
if
(
boardType
==
BoardTypeUnknown
)
{
// Fall back to port name matching which could lead to incorrect board mapping. But in some cases the
// vendor and product id do not come through correctly so this is used as a last chance detection method.
if
(
description
()
==
"PX4 FMU v2.x"
||
description
()
==
"PX4 BL FMU v2.x"
)
{
qCDebug
(
QGCSerialPortInfoLog
)
<<
"Found PX4 FMU V2 (by name matching fallback)"
;
boardType
=
BoardTypePX4FMUV2
;
}
else
if
(
description
()
==
"PX4 FMU v1.x"
||
description
()
==
"PX4 BL FMU v1.x"
)
{
qCDebug
(
QGCSerialPortInfoLog
)
<<
"Found PX4 FMU V1 (by name matching fallback)"
;
boardType
=
BoardTypePX4FMUV1
;
}
else
if
(
description
().
startsWith
(
"PX4 FMU"
))
{
qCDebug
(
QGCSerialPortInfoLog
)
<<
"Found PX4 FMU, assuming V2 (by name matching fallback)"
;
boardType
=
BoardTypePX4FMUV2
;
}
}
return
boardType
;
}
QList
<
QGCSerialPortInfo
>
QGCSerialPortInfo
::
availablePorts
(
void
)
{
QList
<
QGCSerialPortInfo
>
list
;
foreach
(
QSerialPortInfo
portInfo
,
QSerialPortInfo
::
availablePorts
())
{
list
<<
*
((
QGCSerialPortInfo
*
)
&
portInfo
);
}
return
list
;
}
bool
QGCSerialPortInfo
::
boardTypePixhawk
(
void
)
const
{
BoardType_t
boardType
=
this
->
boardType
();
return
boardType
==
BoardTypePX4FMUV1
||
boardType
==
BoardTypePX4FMUV2
||
boardType
==
BoardTypeAeroCore
;
}
bool
QGCSerialPortInfo
::
isBootloader
(
void
)
const
{
// FIXME: Check SerialLink bootloade detect code which is different
return
boardTypePixhawk
()
&&
description
().
contains
(
"BL"
);
}
src/
SerialPortIds
.h
→
src/
comm/QGCSerialPortInfo
.h
View file @
946b7ea8
...
...
@@ -21,13 +21,35 @@
======================================================================*/
#ifndef
SerialPortIds
_H
#define
SerialPortIds
_H
#ifndef
QGCSerialPortInfo
_H
#define
QGCSerialPortInfo
_H
// SerialPortInfo Vendor and Product Ids for known boards
class
SerialPortIds
{
#ifdef __android__
#include "qserialportinfo.h"
#else
#include <QSerialPortInfo>
#endif
#include "QGCLoggingCategory.h"
Q_DECLARE_LOGGING_CATEGORY
(
QGCSerialPortInfoLog
)
/// QGC's version of Qt QSerialPortInfo. It provides additional information about board types
/// that QGC cares about.
class
QGCSerialPortInfo
:
public
QSerialPortInfo
{
public:
typedef
enum
{
BoardTypePX4FMUV1
,
BoardTypePX4FMUV2
,
BoardTypePX4Flow
,
BoardType3drRadio
,
BoardTypeAeroCore
,
BoardTypeUnknown
}
BoardType_t
;
// Vendor and products ids for the boards we care about
static
const
int
px4VendorId
=
9900
;
///< Vendor ID for Pixhawk board (V2 and V1) and PX4 Flow
static
const
int
pixhawkFMUV2ProductId
=
17
;
///< Product ID for Pixhawk V2 board
...
...
@@ -40,6 +62,20 @@ public:
static
const
int
threeDRRadioVendorId
=
1027
;
///< Vendor ID for 3DR Radio
static
const
int
threeDRRadioProductId
=
24597
;
///< Product ID for 3DR Radio
QGCSerialPortInfo
(
const
QSerialPort
&
port
);
/// Override of QSerialPortInfo::availablePorts
static
QList
<
QGCSerialPortInfo
>
availablePorts
(
void
);
BoardType_t
boardType
(
void
)
const
;
/// @return true: board is a Pixhawk board
bool
boardTypePixhawk
(
void
)
const
;
/// @return true: Board is currently in bootloader
bool
isBootloader
(
void
)
const
;
};
#endif
src/main.cc
View file @
946b7ea8
...
...
@@ -33,13 +33,13 @@ This file is part of the QGROUNDCONTROL project
#include <QSslSocket>
#include <QProcessEnvironment>
#ifndef __mobile__
#include <QSerialPortInfo>
#endif
#include "QGCApplication.h"
#include "MainWindow.h"
#ifndef __mobile__
#include "QGCSerialPortInfo.h"
#endif
#ifdef QT_DEBUG
#ifndef __mobile__
#include "UnitTest.h"
...
...
@@ -58,7 +58,7 @@ This file is part of the QGROUNDCONTROL project
#endif
#ifndef __mobile__
Q_DECLARE_METATYPE
(
Q
SerialPortInfo
)
Q_DECLARE_METATYPE
(
QGC
SerialPortInfo
)
#endif
#ifdef Q_OS_WIN
...
...
@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
#endif
qRegisterMetaType
<
QAbstractSocket
::
SocketError
>
();
#ifndef __mobile__
qRegisterMetaType
<
QSerialPortInfo
>
();
qRegisterMetaType
<
Q
GC
SerialPortInfo
>
();
#endif
// We statically link our own QtLocation plugin
...
...
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