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
50101778
Commit
50101778
authored
Mar 13, 2015
by
dogmaphobic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show user friendly port name in Serial Settings combo box.
parent
eb811905
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
57 deletions
+53
-57
SerialLink.cc
src/comm/SerialLink.cc
+1
-12
SerialLink.h
src/comm/SerialLink.h
+0
-3
QGCLinkConfiguration.cc
src/ui/QGCLinkConfiguration.cc
+1
-0
SerialConfigurationWindow.cc
src/ui/SerialConfigurationWindow.cc
+43
-35
SerialConfigurationWindow.h
src/ui/SerialConfigurationWindow.h
+1
-3
SerialSettings.ui
src/ui/SerialSettings.ui
+7
-4
No files found.
src/comm/SerialLink.cc
View file @
50101778
...
...
@@ -62,7 +62,7 @@ SerialLink::~SerialLink()
bool
SerialLink
::
_isBootloader
()
{
QList
<
QSerialPortInfo
>
portList
=
QSerialPortInfo
::
availablePorts
();
QList
<
QSerialPortInfo
>
portList
=
QSerialPortInfo
::
availablePorts
();
if
(
portList
.
count
()
==
0
){
return
false
;
}
...
...
@@ -581,14 +581,3 @@ void SerialConfiguration::loadSettings(QSettings& settings, const QString& root)
if
(
settings
.
contains
(
"portName"
))
_portName
=
settings
.
value
(
"portName"
).
toString
();
settings
.
endGroup
();
}
QList
<
QString
>
SerialConfiguration
::
getCurrentPorts
()
{
QList
<
QString
>
ports
;
QList
<
QSerialPortInfo
>
portList
=
QSerialPortInfo
::
availablePorts
();
foreach
(
const
QSerialPortInfo
&
info
,
portList
)
{
ports
.
append
(
info
.
systemLocation
());
}
return
ports
;
}
src/comm/SerialLink.h
View file @
50101778
...
...
@@ -81,9 +81,6 @@ public:
void
saveSettings
(
QSettings
&
settings
,
const
QString
&
root
);
void
updateSettings
();
/*! @brief Get a list of the currently available ports */
static
QList
<
QString
>
getCurrentPorts
();
private:
int
_baud
;
int
_dataBits
;
...
...
src/ui/QGCLinkConfiguration.cc
View file @
50101778
...
...
@@ -142,6 +142,7 @@ void QGCLinkConfiguration::_fixUnnamed(LinkConfiguration* config)
#ifdef Q_OS_WIN32
tname
.
replace
(
"
\\\\
.
\\
"
,
""
);
#else
tname
.
replace
(
"/dev/cu."
,
""
);
tname
.
replace
(
"/dev/"
,
""
);
#endif
config
->
setName
(
QString
(
"Serial Device on %1"
).
arg
(
tname
));
...
...
src/ui/SerialConfigurationWindow.cc
View file @
50101778
...
...
@@ -32,6 +32,7 @@ This file is part of the QGROUNDCONTROL project
#include <QSettings>
#include <QFileInfoList>
#include <QDebug>
#include <QSerialPortInfo>
#include <SerialConfigurationWindow.h>
#include <SerialLink.h>
...
...
@@ -42,7 +43,6 @@ This file is part of the QGROUNDCONTROL project
SerialConfigurationWindow
::
SerialConfigurationWindow
(
SerialConfiguration
*
config
,
QWidget
*
parent
,
Qt
::
WindowFlags
flags
)
:
QWidget
(
parent
,
flags
)
,
_userConfigured
(
false
)
{
_ui
.
setupUi
(
this
);
Q_ASSERT
(
config
!=
NULL
);
...
...
@@ -112,16 +112,15 @@ SerialConfigurationWindow::SerialConfigurationWindow(SerialConfiguration *config
}
// Connect the individual user interface inputs
connect
(
_ui
.
portName
,
SIGNAL
(
editTextChanged
(
QString
)),
this
,
SLOT
(
setPortName
(
QString
)));
connect
(
_ui
.
portName
,
SIGNAL
(
currentIndexChanged
(
QString
)),
this
,
SLOT
(
setPortName
(
QString
)));
connect
(
_ui
.
baudRate
,
SIGNAL
(
activated
(
int
)),
this
,
SLOT
(
setBaudRate
(
int
)));
connect
(
_ui
.
flowControlCheckBox
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
enableFlowControl
(
bool
)));
connect
(
_ui
.
parNone
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setParityNone
(
bool
)));
connect
(
_ui
.
parOdd
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setParityOdd
(
bool
)));
connect
(
_ui
.
parEven
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setParityEven
(
bool
)));
connect
(
_ui
.
dataBitsSpinBox
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
setDataBits
(
int
)));
connect
(
_ui
.
stopBitsSpinBox
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
setStopBits
(
int
)));
connect
(
_ui
.
advCheckBox
,
SIGNAL
(
clicked
(
bool
)),
_ui
.
advGroupBox
,
SLOT
(
setVisible
(
bool
)));
connect
(
_ui
.
portName
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
setPortName
(
int
)));
connect
(
_ui
.
baudRate
,
SIGNAL
(
activated
(
int
)),
this
,
SLOT
(
setBaudRate
(
int
)));
connect
(
_ui
.
flowControlCheckBox
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
enableFlowControl
(
bool
)));
connect
(
_ui
.
parNone
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setParityNone
(
bool
)));
connect
(
_ui
.
parOdd
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setParityOdd
(
bool
)));
connect
(
_ui
.
parEven
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setParityEven
(
bool
)));
connect
(
_ui
.
dataBitsSpinBox
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
setDataBits
(
int
)));
connect
(
_ui
.
stopBitsSpinBox
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
setStopBits
(
int
)));
connect
(
_ui
.
advCheckBox
,
SIGNAL
(
clicked
(
bool
)),
_ui
.
advGroupBox
,
SLOT
(
setVisible
(
bool
)));
_ui
.
advCheckBox
->
setCheckable
(
true
);
_ui
.
advCheckBox
->
setChecked
(
false
);
...
...
@@ -179,26 +178,38 @@ void SerialConfigurationWindow::hideEvent(QHideEvent* event)
bool
SerialConfigurationWindow
::
setupPortList
()
{
// Get the ports available on this system
QList
<
QString
>
ports
=
SerialConfiguration
::
getCurrentPorts
();
QString
storedName
=
_config
->
portName
();
bool
storedFound
=
false
;
// Add the ports in reverse order, because we prepend them to the list
for
(
int
i
=
ports
.
count
()
-
1
;
i
>=
0
;
--
i
)
bool
changed
=
false
;
// Iterate found ports
QList
<
QSerialPortInfo
>
portList
=
QSerialPortInfo
::
availablePorts
();
foreach
(
const
QSerialPortInfo
&
info
,
portList
)
{
// Prepend newly found port to the list
if
(
_ui
.
portName
->
findText
(
ports
[
i
])
<
0
)
QString
name
=
info
.
portName
();
// Append newly found port to the list
if
(
_ui
.
portName
->
findText
(
name
)
<
0
)
{
_ui
.
portName
->
insertItem
(
0
,
ports
[
i
]);
if
(
!
_userConfigured
)
_ui
.
portName
->
setEditText
(
ports
[
i
]);
// We show the user the "short name" but store the full port name
_ui
.
portName
->
addItem
(
name
,
QVariant
(
info
.
systemLocation
()));
changed
=
true
;
}
// Check if the stored link name is still present
if
(
ports
[
i
].
contains
(
storedName
)
||
storedName
.
contains
(
ports
[
i
]))
storedFound
=
true
;
}
if
(
storedFound
)
_ui
.
portName
->
setEditText
(
storedName
);
return
(
ports
.
count
()
>
0
);
// See if configured port (if any) is present
if
(
changed
)
{
int
idx
=
_ui
.
portName
->
count
()
-
1
;
if
(
!
_config
->
portName
().
isEmpty
())
{
idx
=
_ui
.
portName
->
findData
(
QVariant
(
_config
->
portName
()));
if
(
idx
<
0
)
{
idx
=
0
;
}
}
_ui
.
portName
->
setCurrentIndex
(
idx
);
if
(
_ui
.
portName
->
count
()
>
0
)
{
_ui
.
portName
->
setEditText
(
_ui
.
portName
->
itemText
(
idx
));
}
if
(
_config
->
portName
().
isEmpty
())
{
setPortName
(
idx
);
}
}
return
(
_ui
.
portName
->
count
()
>
0
);
}
void
SerialConfigurationWindow
::
enableFlowControl
(
bool
flow
)
...
...
@@ -221,16 +232,13 @@ void SerialConfigurationWindow::setParityEven(bool accept)
if
(
accept
)
_config
->
setParity
(
QSerialPort
::
EvenParity
);
}
void
SerialConfigurationWindow
::
setPortName
(
QString
port
)
void
SerialConfigurationWindow
::
setPortName
(
int
index
)
{
#ifdef Q_OS_WIN
port
=
port
.
split
(
"-"
).
first
();
#endif
port
=
port
.
trimmed
();
if
(
_config
->
portName
()
!=
port
)
{
_config
->
setPortName
(
port
);
// Get the full port name and store it in the config
QString
pname
=
_ui
.
portName
->
itemData
(
index
).
toString
();
if
(
_config
->
portName
()
!=
pname
)
{
_config
->
setPortName
(
pname
);
}
userConfigured
=
true
;
}
void
SerialConfigurationWindow
::
setBaudRate
(
int
index
)
...
...
src/ui/SerialConfigurationWindow.h
View file @
50101778
...
...
@@ -53,7 +53,7 @@ public slots:
void
setParityNone
(
bool
accept
);
void
setParityOdd
(
bool
accept
);
void
setParityEven
(
bool
accept
);
void
setPortName
(
QString
port
);
void
setPortName
(
int
index
);
void
setBaudRate
(
int
index
);
void
setDataBits
(
int
bits
);
void
setStopBits
(
int
bits
);
...
...
@@ -72,8 +72,6 @@ protected:
bool
userConfigured
;
///< Switch to detect if current values are user-selected and shouldn't be overriden
private:
bool
_userConfigured
;
Ui
::
serialSettings
_ui
;
SerialConfiguration
*
_config
;
QTimer
*
_portCheckTimer
;
...
...
src/ui/SerialSettings.ui
View file @
50101778
...
...
@@ -32,16 +32,19 @@
</size>
</property>
<property
name=
"toolTip"
>
<string>
The serial port to which the system is connected.
All ports listed here should work.
</string>
<string>
The serial port to which the system is connected.
</string>
</property>
<property
name=
"statusTip"
>
<string>
The serial port to which the system is connected.
All ports listed here should work.
</string>
<string>
The serial port to which the system is connected.
</string>
</property>
<property
name=
"whatsThis"
>
<string>
The serial port to which the system is connected.
All ports listed here should work.
</string>
<string>
The serial port to which the system is connected.
</string>
</property>
<property
name=
"editable"
>
<bool>
true
</bool>
<bool>
false
</bool>
</property>
<property
name=
"maxCount"
>
<number>
100
</number>
</property>
<property
name=
"sizeAdjustPolicy"
>
<enum>
QComboBox::AdjustToContents
</enum>
...
...
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