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
a8dabf1f
Commit
a8dabf1f
authored
Dec 01, 2015
by
dogmaphobic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Serial Link Settings completed (QML)
parent
ab167a25
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
515 additions
and
90 deletions
+515
-90
LinkConfiguration.cc
src/comm/LinkConfiguration.cc
+3
-0
LinkConfiguration.h
src/comm/LinkConfiguration.h
+23
-6
LinkManager.cc
src/comm/LinkManager.cc
+160
-35
LinkManager.h
src/comm/LinkManager.h
+21
-6
SerialLink.cc
src/comm/SerialLink.cc
+41
-24
SerialLink.h
src/comm/SerialLink.h
+27
-8
LinkSettings.qml
src/ui/preferences/LinkSettings.qml
+240
-11
No files found.
src/comm/LinkConfiguration.cc
View file @
a8dabf1f
...
...
@@ -45,6 +45,7 @@ LinkConfiguration::LinkConfiguration(const QString& name)
:
_link
(
NULL
)
,
_name
(
name
)
,
_dynamic
(
false
)
,
_autoConnect
(
false
)
{
_name
=
name
;
if
(
_name
.
isEmpty
())
{
...
...
@@ -57,6 +58,7 @@ LinkConfiguration::LinkConfiguration(LinkConfiguration* copy)
_link
=
copy
->
link
();
_name
=
copy
->
name
();
_dynamic
=
copy
->
isDynamic
();
_autoConnect
=
copy
->
isAutoConnect
();
Q_ASSERT
(
!
_name
.
isEmpty
());
}
...
...
@@ -66,6 +68,7 @@ void LinkConfiguration::copyFrom(LinkConfiguration* source)
_link
=
source
->
link
();
_name
=
source
->
name
();
_dynamic
=
source
->
isDynamic
();
_autoConnect
=
source
->
isAutoConnect
();
}
/*!
...
...
src/comm/LinkConfiguration.h
View file @
a8dabf1f
...
...
@@ -40,9 +40,11 @@ public:
LinkConfiguration
(
LinkConfiguration
*
copy
);
virtual
~
LinkConfiguration
()
{}
Q_PROPERTY
(
QString
name
READ
name
WRITE
setName
NOTIFY
nameChanged
)
Q_PROPERTY
(
LinkInterface
*
link
READ
link
WRITE
setLink
NOTIFY
linkChanged
)
Q_PROPERTY
(
QString
name
READ
name
WRITE
setName
NOTIFY
nameChanged
)
Q_PROPERTY
(
LinkInterface
*
link
READ
link
WRITE
setLink
NOTIFY
linkChanged
)
Q_PROPERTY
(
LinkType
linkType
READ
type
CONSTANT
)
Q_PROPERTY
(
bool
dynamic
READ
isDynamic
WRITE
setDynamic
NOTIFY
dynamicChanged
)
Q_PROPERTY
(
bool
autoConnect
READ
isAutoConnect
WRITE
setAutoConnect
NOTIFY
autoConnectChanged
)
// Property accessors
...
...
@@ -77,10 +79,22 @@ public:
*/
bool
isDynamic
()
{
return
_dynamic
;
}
/*!
*
* Is this an Auto Connect configuration?
* @return True if this is an Auto Connect configuration (connects automatically at boot time).
*/
bool
isAutoConnect
()
{
return
_autoConnect
;
}
/*!
* Set if this is this a dynamic configuration. (decided at runtime)
*/
void
setDynamic
(
bool
dynamic
=
true
)
{
_dynamic
=
dynamic
;
}
void
setDynamic
(
bool
dynamic
=
true
)
{
_dynamic
=
dynamic
;
emit
dynamicChanged
();
}
/*!
* Set if this is this an Auto Connect configuration.
*/
void
setAutoConnect
(
bool
autoc
=
true
)
{
_autoConnect
=
autoc
;
emit
autoConnectChanged
();
}
/// Virtual Methods
...
...
@@ -152,14 +166,17 @@ public:
static
LinkConfiguration
*
duplicateSettings
(
LinkConfiguration
*
source
);
signals:
void
nameChanged
(
const
QString
&
name
);
void
linkChanged
(
LinkInterface
*
link
);
void
nameChanged
(
const
QString
&
name
);
void
linkChanged
(
LinkInterface
*
link
);
void
dynamicChanged
();
void
autoConnectChanged
();
protected:
LinkInterface
*
_link
;
///< Link currently using this configuration (if any)
private:
QString
_name
;
bool
_dynamic
;
///< A connection added automatically and not persistent (unless it's edited).
bool
_dynamic
;
///< A connection added automatically and not persistent (unless it's edited).
bool
_autoConnect
;
///< This connection is started automatically at boot
};
#endif // LINKCONFIGURATION_H
src/comm/LinkManager.cc
View file @
a8dabf1f
This diff is collapsed.
Click to expand it.
src/comm/LinkManager.h
View file @
a8dabf1f
...
...
@@ -80,15 +80,25 @@ public:
Q_PROPERTY
(
bool
autoconnectPX4Flow
READ
autoconnectPX4Flow
WRITE
setAutoconnectPX4Flow
NOTIFY
autoconnectPX4FlowChanged
)
/// LinkInterface Accessor
Q_PROPERTY
(
QmlObjectListModel
*
links
READ
links
CONSTANT
)
Q_PROPERTY
(
QmlObjectListModel
*
links
READ
links
CONSTANT
)
/// LinkConfiguration Accessor
Q_PROPERTY
(
QmlObjectListModel
*
linkConfigurations
READ
linkConfigurations
CONSTANT
)
Q_PROPERTY
(
QmlObjectListModel
*
linkConfigurations
READ
linkConfigurations
NOTIFY
linkConfigurationsChanged
)
/// List of comm type strings
Q_PROPERTY
(
QStringList
linkTypeStrings
READ
linkTypeStrings
CONSTANT
)
Q_PROPERTY
(
QStringList
linkTypeStrings
READ
linkTypeStrings
CONSTANT
)
/// List of supported baud rates for serial links
Q_PROPERTY
(
QStringList
serialBaudRates
READ
serialBaudRates
CONSTANT
)
Q_PROPERTY
(
QStringList
serialBaudRates
READ
serialBaudRates
CONSTANT
)
/// List of comm ports display names
Q_PROPERTY
(
QStringList
serialPortStrings
READ
serialPortStrings
NOTIFY
commPortStringsChanged
)
/// List of comm ports
Q_PROPERTY
(
QStringList
serialPortStrings
READ
serialPortStrings
NOTIFY
commPortStringsChanged
)
Q_PROPERTY
(
QStringList
serialPorts
READ
serialPorts
NOTIFY
commPortsChanged
)
// Create/Edit Link Configuration
Q_INVOKABLE
LinkConfiguration
*
createConfiguration
(
int
type
,
const
QString
&
name
);
Q_INVOKABLE
LinkConfiguration
*
startConfigurationEditing
(
LinkConfiguration
*
config
);
Q_INVOKABLE
void
cancelConfigurationEditing
(
LinkConfiguration
*
config
)
{
delete
config
;
}
Q_INVOKABLE
bool
endConfigurationEditing
(
LinkConfiguration
*
config
,
LinkConfiguration
*
editedConfig
);
Q_INVOKABLE
bool
endCreateConfiguration
(
LinkConfiguration
*
config
);
Q_INVOKABLE
void
removeConfiguration
(
LinkConfiguration
*
config
);
// Property accessors
...
...
@@ -104,6 +114,7 @@ public:
QStringList
linkTypeStrings
(
void
)
const
;
QStringList
serialBaudRates
(
void
);
QStringList
serialPortStrings
(
void
);
QStringList
serialPorts
(
void
);
void
setAutoconnectUDP
(
bool
autoconnect
);
void
setAutoconnectPixhawk
(
bool
autoconnect
);
...
...
@@ -186,8 +197,9 @@ signals:
// No longer hearing from any vehicles on this link.
void
linkInactive
(
LinkInterface
*
link
);
void
linkConfigurationChanged
();
void
commPortStringsChanged
();
void
commPortsChanged
();
void
linkConfigurationsChanged
();
private
slots
:
void
_linkConnected
(
void
);
...
...
@@ -197,6 +209,8 @@ private slots:
private:
bool
_connectionsSuspendedMsg
(
void
);
void
_updateAutoConnectLinks
(
void
);
void
_updateSerialPorts
();
void
_fixUnnamed
(
LinkConfiguration
*
config
);
#ifndef __ios__
SerialConfiguration
*
_autoconnectConfigurationsContainsPort
(
const
QString
&
portName
);
...
...
@@ -218,6 +232,7 @@ private:
QStringList
_autoconnectWaitList
;
QStringList
_commPortList
;
QStringList
_commPortDisplayList
;
bool
_autoconnectUDP
;
bool
_autoconnectPixhawk
;
...
...
src/comm/SerialLink.cc
View file @
a8dabf1f
...
...
@@ -395,12 +395,13 @@ SerialConfiguration::SerialConfiguration(const QString& name) : LinkConfiguratio
SerialConfiguration
::
SerialConfiguration
(
SerialConfiguration
*
copy
)
:
LinkConfiguration
(
copy
)
{
_baud
=
copy
->
baud
();
_flowControl
=
copy
->
flowControl
();
_parity
=
copy
->
parity
();
_dataBits
=
copy
->
dataBits
();
_stopBits
=
copy
->
stopBits
();
_portName
=
copy
->
portName
();
_baud
=
copy
->
baud
();
_flowControl
=
copy
->
flowControl
();
_parity
=
copy
->
parity
();
_dataBits
=
copy
->
dataBits
();
_stopBits
=
copy
->
stopBits
();
_portName
=
copy
->
portName
();
_portDisplayName
=
copy
->
portDisplayName
();
}
void
SerialConfiguration
::
copyFrom
(
LinkConfiguration
*
source
)
...
...
@@ -408,12 +409,13 @@ void SerialConfiguration::copyFrom(LinkConfiguration *source)
LinkConfiguration
::
copyFrom
(
source
);
SerialConfiguration
*
ssource
=
dynamic_cast
<
SerialConfiguration
*>
(
source
);
Q_ASSERT
(
ssource
!=
NULL
);
_baud
=
ssource
->
baud
();
_flowControl
=
ssource
->
flowControl
();
_parity
=
ssource
->
parity
();
_dataBits
=
ssource
->
dataBits
();
_stopBits
=
ssource
->
stopBits
();
_portName
=
ssource
->
portName
();
_baud
=
ssource
->
baud
();
_flowControl
=
ssource
->
flowControl
();
_parity
=
ssource
->
parity
();
_dataBits
=
ssource
->
dataBits
();
_stopBits
=
ssource
->
stopBits
();
_portName
=
ssource
->
portName
();
_portDisplayName
=
ssource
->
portDisplayName
();
}
void
SerialConfiguration
::
updateSettings
()
...
...
@@ -457,30 +459,45 @@ void SerialConfiguration::setPortName(const QString& portName)
QString
pname
=
portName
.
trimmed
();
if
(
!
pname
.
isEmpty
()
&&
pname
!=
_portName
)
{
_portName
=
pname
;
_portDisplayName
=
cleanPortDisplayname
(
pname
);
}
}
QString
SerialConfiguration
::
cleanPortDisplayname
(
const
QString
name
)
{
QString
pname
=
name
.
trimmed
();
#ifdef Q_OS_WIN32
pname
.
replace
(
"
\\\\
.
\\
"
,
""
);
#else
pname
.
replace
(
"/dev/cu."
,
""
);
pname
.
replace
(
"/dev/"
,
""
);
#endif
return
pname
;
}
void
SerialConfiguration
::
saveSettings
(
QSettings
&
settings
,
const
QString
&
root
)
{
settings
.
beginGroup
(
root
);
settings
.
setValue
(
"baud"
,
_baud
);
settings
.
setValue
(
"dataBits"
,
_dataBits
);
settings
.
setValue
(
"flowControl"
,
_flowControl
);
settings
.
setValue
(
"stopBits"
,
_stopBits
);
settings
.
setValue
(
"parity"
,
_parity
);
settings
.
setValue
(
"portName"
,
_portName
);
settings
.
setValue
(
"baud"
,
_baud
);
settings
.
setValue
(
"dataBits"
,
_dataBits
);
settings
.
setValue
(
"flowControl"
,
_flowControl
);
settings
.
setValue
(
"stopBits"
,
_stopBits
);
settings
.
setValue
(
"parity"
,
_parity
);
settings
.
setValue
(
"portName"
,
_portName
);
settings
.
setValue
(
"portDisplayName"
,
_portDisplayName
);
settings
.
endGroup
();
}
void
SerialConfiguration
::
loadSettings
(
QSettings
&
settings
,
const
QString
&
root
)
{
settings
.
beginGroup
(
root
);
if
(
settings
.
contains
(
"baud"
))
_baud
=
settings
.
value
(
"baud"
).
toInt
();
if
(
settings
.
contains
(
"dataBits"
))
_dataBits
=
settings
.
value
(
"dataBits"
).
toInt
();
if
(
settings
.
contains
(
"flowControl"
))
_flowControl
=
settings
.
value
(
"flowControl"
).
toInt
();
if
(
settings
.
contains
(
"stopBits"
))
_stopBits
=
settings
.
value
(
"stopBits"
).
toInt
();
if
(
settings
.
contains
(
"parity"
))
_parity
=
settings
.
value
(
"parity"
).
toInt
();
if
(
settings
.
contains
(
"portName"
))
_portName
=
settings
.
value
(
"portName"
).
toString
();
if
(
settings
.
contains
(
"baud"
))
_baud
=
settings
.
value
(
"baud"
).
toInt
();
if
(
settings
.
contains
(
"dataBits"
))
_dataBits
=
settings
.
value
(
"dataBits"
).
toInt
();
if
(
settings
.
contains
(
"flowControl"
))
_flowControl
=
settings
.
value
(
"flowControl"
).
toInt
();
if
(
settings
.
contains
(
"stopBits"
))
_stopBits
=
settings
.
value
(
"stopBits"
).
toInt
();
if
(
settings
.
contains
(
"parity"
))
_parity
=
settings
.
value
(
"parity"
).
toInt
();
if
(
settings
.
contains
(
"portName"
))
_portName
=
settings
.
value
(
"portName"
).
toString
();
if
(
settings
.
contains
(
"portDisplayName"
))
_portDisplayName
=
settings
.
value
(
"portDisplayName"
).
toString
();
settings
.
endGroup
();
}
...
...
src/comm/SerialLink.h
View file @
a8dabf1f
...
...
@@ -66,22 +66,32 @@ public:
SerialConfiguration
(
const
QString
&
name
);
SerialConfiguration
(
SerialConfiguration
*
copy
);
Q_PROPERTY
(
int
baud
READ
baud
WRITE
setBaud
NOTIFY
baudChanged
)
Q_PROPERTY
(
int
dataBits
READ
dataBits
WRITE
setDataBits
NOTIFY
dataBitsChanged
)
Q_PROPERTY
(
int
flowControl
READ
flowControl
WRITE
setFlowControl
NOTIFY
flowControlChanged
)
Q_PROPERTY
(
int
stopBits
READ
stopBits
WRITE
setStopBits
NOTIFY
stopBitsChanged
)
Q_PROPERTY
(
int
parity
READ
parity
WRITE
setParity
NOTIFY
parityChanged
)
Q_PROPERTY
(
QString
portName
READ
portName
WRITE
setPortName
NOTIFY
portNameChanged
)
Q_PROPERTY
(
QString
portDisplayName
READ
portDisplayName
NOTIFY
portDisplayNameChanged
)
int
baud
()
{
return
_baud
;
}
int
dataBits
()
{
return
_dataBits
;
}
int
flowControl
()
{
return
_flowControl
;
}
///< QSerialPort Enums
int
stopBits
()
{
return
_stopBits
;
}
int
parity
()
{
return
_parity
;
}
///< QSerialPort Enums
const
QString
portName
()
{
return
_portName
;
}
const
QString
portName
()
{
return
_portName
;
}
const
QString
portDisplayName
()
{
return
_portDisplayName
;
}
void
setBaud
(
int
baud
);
void
setDataBits
(
int
databits
);
void
setFlowControl
(
int
flowControl
);
///< QSerialPort Enums
void
setStopBits
(
int
stopBits
);
void
setParity
(
int
parity
);
///< QSerialPort Enums
void
setPortName
(
const
QString
&
portName
);
void
setBaud
(
int
baud
);
void
setDataBits
(
int
databits
);
void
setFlowControl
(
int
flowControl
);
///< QSerialPort Enums
void
setStopBits
(
int
stopBits
);
void
setParity
(
int
parity
);
///< QSerialPort Enums
void
setPortName
(
const
QString
&
portName
);
static
QStringList
supportedBaudRates
();
static
QString
cleanPortDisplayname
(
const
QString
name
);
/// From LinkConfiguration
LinkType
type
()
{
return
LinkConfiguration
::
TypeSerial
;
}
...
...
@@ -90,6 +100,15 @@ public:
void
saveSettings
(
QSettings
&
settings
,
const
QString
&
root
);
void
updateSettings
();
signals:
void
baudChanged
();
void
dataBitsChanged
();
void
flowControlChanged
();
void
stopBitsChanged
();
void
parityChanged
();
void
portNameChanged
();
void
portDisplayNameChanged
();
private:
static
void
_initBaudRates
();
...
...
@@ -100,9 +119,9 @@ private:
int
_stopBits
;
int
_parity
;
QString
_portName
;
QString
_portDisplayName
;
};
/**
* @brief The SerialLink class provides cross-platform access to serial links.
* It takes care of the link management and provides a common API to higher
...
...
src/ui/preferences/LinkSettings.qml
View file @
a8dabf1f
This diff is collapsed.
Click to expand it.
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