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
02352b14
Commit
02352b14
authored
Mar 05, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #567 from DonLakeFlyer/QSerialPortFix
QSerialPort emitting stream of errors
parents
f5e5d137
9e38f8ca
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
6 deletions
+32
-6
qserialport_unix.cpp
libs/serialport/qserialport_unix.cpp
+4
-2
SerialLink.cc
src/comm/SerialLink.cc
+7
-2
SerialLink.h
src/comm/SerialLink.h
+5
-1
TCPLink.h
src/comm/TCPLink.h
+7
-1
main.cc
src/main.cc
+9
-0
No files found.
libs/serialport/qserialport_unix.cpp
View file @
02352b14
...
@@ -429,7 +429,8 @@ bool QSerialPortPrivate::waitForReadyRead(int msecs)
...
@@ -429,7 +429,8 @@ bool QSerialPortPrivate::waitForReadyRead(int msecs)
bool
timedOut
=
false
;
bool
timedOut
=
false
;
if
(
!
waitForReadOrWrite
(
&
readyToRead
,
&
readyToWrite
,
true
,
!
writeBuffer
.
isEmpty
(),
if
(
!
waitForReadOrWrite
(
&
readyToRead
,
&
readyToWrite
,
true
,
!
writeBuffer
.
isEmpty
(),
timeoutValue
(
msecs
,
stopWatch
.
elapsed
()),
&
timedOut
))
{
timeoutValue
(
msecs
,
stopWatch
.
elapsed
()),
&
timedOut
))
{
q_ptr
->
setError
(
decodeSystemError
());
if
(
!
timedOut
)
q_ptr
->
setError
(
decodeSystemError
());
return
false
;
return
false
;
}
}
...
@@ -460,7 +461,8 @@ bool QSerialPortPrivate::waitForBytesWritten(int msecs)
...
@@ -460,7 +461,8 @@ bool QSerialPortPrivate::waitForBytesWritten(int msecs)
bool
timedOut
=
false
;
bool
timedOut
=
false
;
if
(
!
waitForReadOrWrite
(
&
readyToRead
,
&
readyToWrite
,
true
,
!
writeBuffer
.
isEmpty
(),
if
(
!
waitForReadOrWrite
(
&
readyToRead
,
&
readyToWrite
,
true
,
!
writeBuffer
.
isEmpty
(),
timeoutValue
(
msecs
,
stopWatch
.
elapsed
()),
&
timedOut
))
{
timeoutValue
(
msecs
,
stopWatch
.
elapsed
()),
&
timedOut
))
{
q_ptr
->
setError
(
decodeSystemError
());
if
(
!
timedOut
)
q_ptr
->
setError
(
decodeSystemError
());
return
false
;
return
false
;
}
}
...
...
src/comm/SerialLink.cc
View file @
02352b14
...
@@ -26,7 +26,6 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl,
...
@@ -26,7 +26,6 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl,
m_stopp
(
false
),
m_stopp
(
false
),
m_reqReset
(
false
)
m_reqReset
(
false
)
{
{
// Get the name of the current port in use.
// Get the name of the current port in use.
m_portName
=
portname
.
trimmed
();
m_portName
=
portname
.
trimmed
();
if
(
m_portName
==
""
&&
getCurrentPorts
().
size
()
>
0
)
if
(
m_portName
==
""
&&
getCurrentPorts
().
size
()
>
0
)
...
@@ -445,7 +444,13 @@ bool SerialLink::hardwareConnect()
...
@@ -445,7 +444,13 @@ bool SerialLink::hardwareConnect()
void
SerialLink
::
linkError
(
QSerialPort
::
SerialPortError
error
)
void
SerialLink
::
linkError
(
QSerialPort
::
SerialPortError
error
)
{
{
qDebug
()
<<
error
;
if
(
error
!=
QSerialPort
::
NoError
)
{
// You can use the following qDebug output as needed during development. Make sure to comment it back out
// when you are done. The reason for this is that this signal is very noisy. For example if you try to
// connect to a PixHawk before it is ready to accept the connection it will output a continuous stream
// of errors until the Pixhawk responds.
//qDebug() << "SerialLink::linkError" << error;
}
}
}
...
...
src/comm/SerialLink.h
View file @
02352b14
...
@@ -36,10 +36,14 @@ This file is part of the QGROUNDCONTROL project
...
@@ -36,10 +36,14 @@ This file is part of the QGROUNDCONTROL project
#include <QThread>
#include <QThread>
#include <QMutex>
#include <QMutex>
#include <QString>
#include <QString>
#include <qserialport.h>
#include <configuration.h>
#include <configuration.h>
#include "SerialLinkInterface.h"
#include "SerialLinkInterface.h"
// We use QSerialPort::SerialPortError in a signal so we must declare it as a meta type
#include <qserialport.h>
#include <QMetaType>
Q_DECLARE_METATYPE
(
QSerialPort
::
SerialPortError
)
/**
/**
* @brief The SerialLink class provides cross-platform access to serial links.
* @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
* It takes care of the link management and provides a common API to higher
...
...
src/comm/TCPLink.h
View file @
02352b14
...
@@ -34,10 +34,16 @@
...
@@ -34,10 +34,16 @@
#include <QMap>
#include <QMap>
#include <QMutex>
#include <QMutex>
#include <QHostAddress>
#include <QHostAddress>
#include <QTcpSocket>
#include <LinkInterface.h>
#include <LinkInterface.h>
#include <configuration.h>
#include <configuration.h>
// Even though QAbstractSocket::SocketError is used in a signal by Qt, Qt doesn't declare it as a meta type.
// This in turn causes debug output to be kicked out about not being able to queue the signal. We declare it
// as a meta type to silence that.
#include <QMetaType>
#include <QTcpSocket>
Q_DECLARE_METATYPE
(
QAbstractSocket
::
SocketError
)
//#define TCPLINK_READWRITE_DEBUG // Use to debug data reads/writes
//#define TCPLINK_READWRITE_DEBUG // Use to debug data reads/writes
class
TCPLink
:
public
LinkInterface
class
TCPLink
:
public
LinkInterface
...
...
src/main.cc
View file @
02352b14
...
@@ -32,6 +32,8 @@ This file is part of the QGROUNDCONTROL project
...
@@ -32,6 +32,8 @@ This file is part of the QGROUNDCONTROL project
#include "QGCCore.h"
#include "QGCCore.h"
#include "MainWindow.h"
#include "MainWindow.h"
#include "configuration.h"
#include "configuration.h"
#include "SerialLink.h"
#include "TCPLink.h"
#ifdef QT_DEBUG
#ifdef QT_DEBUG
#include "AutoTest.h"
#include "AutoTest.h"
#endif
#endif
...
@@ -70,6 +72,13 @@ int main(int argc, char *argv[])
...
@@ -70,6 +72,13 @@ int main(int argc, char *argv[])
#ifdef Q_OS_WIN
#ifdef Q_OS_WIN
qInstallMsgHandler
(
msgHandler
);
qInstallMsgHandler
(
msgHandler
);
#endif
#endif
// The following calls to qRegisterMetaType are done to silence debug output which warns
// that we use these types in signals, and without calling qRegisterMetaType we can't queue
// these signals. In general we don't queue these signals, but we do what the warning says
// anyway to silence the debug output.
qRegisterMetaType
<
QSerialPort
::
SerialPortError
>
();
qRegisterMetaType
<
QAbstractSocket
::
SocketError
>
();
#ifdef QT_DEBUG
#ifdef QT_DEBUG
if
(
argc
>
1
&&
QString
(
argv
[
1
]).
compare
(
"--unittest"
,
Qt
::
CaseInsensitive
)
==
0
)
{
if
(
argc
>
1
&&
QString
(
argv
[
1
]).
compare
(
"--unittest"
,
Qt
::
CaseInsensitive
)
==
0
)
{
...
...
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