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
e388f8be
Commit
e388f8be
authored
Feb 10, 2015
by
Susurrus
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1213 from mavlink/comm_fix
Fix setting the baud rate.
parents
d6c39c38
5730af5c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
51 deletions
+33
-51
SerialLink.cc
src/comm/SerialLink.cc
+0
-40
SerialLink.h
src/comm/SerialLink.h
+0
-5
SerialConfigurationWindow.cc
src/ui/SerialConfigurationWindow.cc
+29
-6
SerialConfigurationWindow.h
src/ui/SerialConfigurationWindow.h
+4
-0
No files found.
src/comm/SerialLink.cc
View file @
e388f8be
...
...
@@ -770,17 +770,8 @@ bool SerialLink::setBaudRateType(int rateIndex)
return
result
;
}
bool
SerialLink
::
setBaudRateString
(
const
QString
&
rate
)
{
bool
ok
;
int
intrate
=
rate
.
toInt
(
&
ok
);
if
(
!
ok
)
return
false
;
return
setBaudRate
(
intrate
);
}
bool
SerialLink
::
setBaudRate
(
int
rate
)
{
bool
accepted
=
false
;
if
(
rate
!=
m_baud
)
{
m_baud
=
rate
;
...
...
@@ -839,37 +830,6 @@ bool SerialLink::setParityType(int parity)
return
accepted
;
}
bool
SerialLink
::
setDataBits
(
int
dataBits
)
{
qDebug
(
"SET DATA BITS"
);
bool
accepted
=
false
;
if
(
dataBits
!=
m_dataBits
)
{
m_dataBits
=
static_cast
<
QSerialPort
::
DataBits
>
(
dataBits
);
accepted
=
true
;
if
(
m_port
&&
!
m_is_cdc
)
accepted
=
m_port
->
setDataBits
(
static_cast
<
QSerialPort
::
DataBits
>
(
dataBits
));
emit
updateLink
(
this
);
}
return
accepted
;
}
bool
SerialLink
::
setStopBits
(
int
stopBits
)
{
// Note 3 is OneAndAHalf stopbits.
bool
accepted
=
false
;
if
(
stopBits
!=
m_stopBits
)
{
m_stopBits
=
static_cast
<
QSerialPort
::
StopBits
>
(
stopBits
);
accepted
=
true
;
if
(
m_port
&&
!
m_is_cdc
)
accepted
=
m_port
->
setStopBits
(
static_cast
<
QSerialPort
::
StopBits
>
(
stopBits
));
emit
updateLink
(
this
);
}
return
accepted
;
}
bool
SerialLink
::
setDataBitsType
(
int
dataBits
)
{
...
...
src/comm/SerialLink.h
View file @
e388f8be
...
...
@@ -123,11 +123,6 @@ signals: //[TODO] Refactor to Linkinterface
public
slots
:
bool
setPortName
(
QString
portName
);
bool
setBaudRate
(
int
rate
);
bool
setDataBits
(
int
dataBits
);
bool
setStopBits
(
int
stopBits
);
// Set string rate
bool
setBaudRateString
(
const
QString
&
rate
);
// Set ENUM values
bool
setBaudRateType
(
int
rateIndex
);
...
...
src/ui/SerialConfigurationWindow.cc
View file @
e388f8be
...
...
@@ -29,13 +29,14 @@ This file is part of the QGROUNDCONTROL project
*/
#include <QDebug>
#include <SerialConfigurationWindow.h>
#include <SerialLinkInterface.h>
#include <QDir>
#include <QSettings>
#include <QFileInfoList>
#include "SerialConfigurationWindow.h"
#include "SerialLinkInterface.h"
#include "SerialLink.h"
SerialConfigurationWindow
::
SerialConfigurationWindow
(
LinkInterface
*
link
,
QWidget
*
parent
,
Qt
::
WindowFlags
flags
)
:
QWidget
(
parent
,
flags
),
userConfigured
(
false
)
{
...
...
@@ -125,13 +126,13 @@ SerialConfigurationWindow::SerialConfigurationWindow(LinkInterface* link, QWidge
// 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
(
QString
)),
this
->
link
,
SLOT
(
setBaudRateString
(
QString
))
);
connect
(
ui
.
baudRate
,
static_cast
<
void
(
QComboBox
::*
)(
const
QString
&
)
>
(
&
QComboBox
::
activated
),
this
,
&
SerialConfigurationWindow
::
setBaudRate
);
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
->
link
,
SLOT
(
setDataBits
(
int
))
);
connect
(
ui
.
stopBitsSpinBox
,
SIGNAL
(
valueChanged
(
int
)),
this
->
link
,
SLOT
(
setStopBits
(
int
))
);
connect
(
ui
.
dataBitsSpinBox
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
&
SerialConfigurationWindow
::
setDataBits
);
connect
(
ui
.
stopBitsSpinBox
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
&
SerialConfigurationWindow
::
setStopBits
);
connect
(
ui
.
advCheckBox
,
SIGNAL
(
clicked
(
bool
)),
ui
.
advGroupBox
,
SLOT
(
setVisible
(
bool
)));
ui
.
advCheckBox
->
setCheckable
(
true
);
ui
.
advCheckBox
->
setChecked
(
false
);
...
...
@@ -284,6 +285,28 @@ void SerialConfigurationWindow::setPortName(QString port)
userConfigured
=
true
;
}
void
SerialConfigurationWindow
::
setBaudRate
(
QString
rate
)
{
bool
ok
;
int
intrate
=
rate
.
toInt
(
&
ok
);
if
(
ok
)
{
link
->
setBaudRate
(
intrate
);
}
userConfigured
=
true
;
}
void
SerialConfigurationWindow
::
setDataBits
(
int
dataBits
)
{
link
->
setDataBitsType
(
static_cast
<
QSerialPort
::
DataBits
>
(
dataBits
));
userConfigured
=
true
;
}
void
SerialConfigurationWindow
::
setStopBits
(
int
stopBits
)
{
link
->
setStopBitsType
(
static_cast
<
QSerialPort
::
DataBits
>
(
stopBits
));
userConfigured
=
true
;
}
void
SerialConfigurationWindow
::
setLinkName
(
QString
name
)
{
Q_UNUSED
(
name
);
...
...
src/ui/SerialConfigurationWindow.h
View file @
e388f8be
...
...
@@ -59,6 +59,10 @@ public slots:
void
setParityOdd
(
bool
accept
);
void
setParityEven
(
bool
accept
);
void
setPortName
(
QString
port
);
void
setBaudRate
(
QString
rate
);
void
setDataBits
(
int
dataBits
);
void
setStopBits
(
int
stopBits
);
void
setLinkName
(
QString
name
);
/**
* @brief setupPortList Populates the dropdown with the list of available serial ports.
...
...
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