Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
d127d07c
Commit
d127d07c
authored
Jul 08, 2020
by
DonLakeFlyer
Browse files
Serial number based composite usb check
parent
665ef88d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/comm/QGCSerialPortInfo.cc
View file @
d127d07c
...
@@ -294,35 +294,17 @@ QString QGCSerialPortInfo::_boardTypeToString(BoardType_t boardType)
...
@@ -294,35 +294,17 @@ QString QGCSerialPortInfo::_boardTypeToString(BoardType_t boardType)
QList
<
QGCSerialPortInfo
>
QGCSerialPortInfo
::
availablePorts
(
void
)
QList
<
QGCSerialPortInfo
>
QGCSerialPortInfo
::
availablePorts
(
void
)
{
{
// Cube Orange/Yellow are composite devices which expose two usb ports over a single usb connection.
// The first port is the mavlink connection, the second is the SLCAN connection by default.
// We don't expose the second port as being available to QGC.
static
const
int
hexCubeVID
=
11694
;
static
const
int
hexCubeOrangePID
=
4118
;
static
const
int
hexCubeYellowPID
=
4114
;
bool
cubeOrangeAlreadySeen
=
false
;
bool
cubeYellowAlreadySeen
=
false
;
QList
<
QGCSerialPortInfo
>
list
;
QList
<
QGCSerialPortInfo
>
list
;
QStringList
seenSerialNumbers
;
for
(
QSerialPortInfo
portInfo
:
QSerialPortInfo
::
availablePorts
())
{
for
(
QSerialPortInfo
portInfo
:
QSerialPortInfo
::
availablePorts
())
{
if
(
!
isSystemPort
(
&
portInfo
))
{
if
(
!
isSystemPort
(
&
portInfo
))
{
if
(
portInfo
.
vendorIdentifier
()
==
hexCubeVID
&&
portInfo
.
productIdentifier
()
==
hexCubeOrangePID
)
{
if
(
seenSerialNumbers
.
contains
(
portInfo
.
serialNumber
()))
{
if
(
cubeOrangeAlreadySeen
)
{
// Some boards are a composite USB device, with the first port being mavlink and the second something else
continue
;
qCDebug
(
QGCSerialPortInfoLog
)
<<
"Skipping secondary port on same device"
<<
portInfo
.
portName
()
<<
portInfo
.
serialNumber
();
}
continue
;
qCDebug
(
QGCSerialPortInfoLog
)
<<
"Skipping secondary port on Cube Orange"
<<
portInfo
.
portName
();
cubeOrangeAlreadySeen
=
true
;
}
if
(
portInfo
.
vendorIdentifier
()
==
hexCubeVID
&&
portInfo
.
productIdentifier
()
==
hexCubeYellowPID
)
{
if
(
cubeYellowAlreadySeen
)
{
continue
;
}
qCDebug
(
QGCSerialPortInfoLog
)
<<
"Skipping secondary port on Cube Yellow"
<<
portInfo
.
portName
();
cubeYellowAlreadySeen
=
true
;
}
}
seenSerialNumbers
.
append
(
portInfo
.
serialNumber
());
list
<<
*
((
QGCSerialPortInfo
*
)
&
portInfo
);
list
<<
*
((
QGCSerialPortInfo
*
)
&
portInfo
);
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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