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
edcb532f
Commit
edcb532f
authored
Apr 12, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auto-Disconnect on cable pull
parent
b612e4cd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
8 deletions
+27
-8
LinkInterface.h
src/comm/LinkInterface.h
+3
-0
LinkManager.cc
src/comm/LinkManager.cc
+15
-3
LinkManager.h
src/comm/LinkManager.h
+1
-0
SerialLink.cc
src/comm/SerialLink.cc
+8
-5
No files found.
src/comm/LinkInterface.h
View file @
edcb532f
...
...
@@ -170,6 +170,9 @@ signals:
void
activeChanged
(
bool
active
);
void
_invokeWriteBytes
(
QByteArray
);
/// Signalled when a link suddenly goes away due to it being removed by for example pulling the cable to the connection.
void
connectionRemoved
(
LinkInterface
*
link
);
/**
* @brief New data arrived
*
...
...
src/comm/LinkManager.cc
View file @
edcb532f
...
...
@@ -214,8 +214,12 @@ void LinkManager::_addLink(LinkInterface* link)
_mavlinkProtocol
->
resetMetadataForLink
(
link
);
connect
(
link
,
&
LinkInterface
::
connected
,
this
,
&
LinkManager
::
_linkConnected
);
connect
(
link
,
&
LinkInterface
::
disconnected
,
this
,
&
LinkManager
::
_linkDisconnected
);
connect
(
link
,
&
LinkInterface
::
connected
,
this
,
&
LinkManager
::
_linkConnected
);
connect
(
link
,
&
LinkInterface
::
disconnected
,
this
,
&
LinkManager
::
_linkDisconnected
);
// This connection is queued since it will cloe the link. So we want the link emitter to return otherwise we would
// close the link our from under itself.
connect
(
link
,
&
LinkInterface
::
connectionRemoved
,
this
,
&
LinkManager
::
_linkConnectionRemoved
,
Qt
::
QueuedConnection
);
}
void
LinkManager
::
disconnectAll
(
void
)
...
...
@@ -239,7 +243,9 @@ bool LinkManager::connectLink(LinkInterface* link)
void
LinkManager
::
disconnectLink
(
LinkInterface
*
link
)
{
Q_ASSERT
(
link
);
if
(
!
link
||
!
_links
.
contains
(
link
))
{
return
;
}
link
->
_disconnect
();
LinkConfiguration
*
config
=
link
->
getLinkConfiguration
();
...
...
@@ -306,6 +312,12 @@ void LinkManager::_linkDisconnected(void)
emit
linkDisconnected
((
LinkInterface
*
)
sender
());
}
void
LinkManager
::
_linkConnectionRemoved
(
LinkInterface
*
link
)
{
// Link has been removed from system, disconnect it automatically
disconnectLink
(
link
);
}
void
LinkManager
::
suspendConfigurationUpdates
(
bool
suspend
)
{
_configUpdateSuspended
=
suspend
;
...
...
src/comm/LinkManager.h
View file @
edcb532f
...
...
@@ -202,6 +202,7 @@ signals:
private
slots
:
void
_linkConnected
(
void
);
void
_linkDisconnected
(
void
);
void
_linkConnectionRemoved
(
LinkInterface
*
link
);
#ifndef __ios__
void
_activeLinkCheck
(
void
);
#endif
...
...
src/comm/SerialLink.cc
View file @
edcb532f
...
...
@@ -182,10 +182,6 @@ bool SerialLink::_hardwareConnect(QSerialPort::SerialPortError& error, QString&
}
_port
=
new
QSerialPort
(
_config
->
portName
());
if
(
!
_port
)
{
emit
communicationUpdate
(
getName
(),
"Error opening port: "
+
_config
->
portName
());
return
false
;
// couldn't create serial port.
}
QObject
::
connect
(
_port
,
static_cast
<
void
(
QSerialPort
::*
)(
QSerialPort
::
SerialPortError
)
>
(
&
QSerialPort
::
error
),
this
,
&
SerialLink
::
linkError
);
...
...
@@ -249,12 +245,19 @@ void SerialLink::_readBytes(void)
void
SerialLink
::
linkError
(
QSerialPort
::
SerialPortError
error
)
{
if
(
error
!=
QSerialPort
::
NoError
)
{
switch
(
error
)
{
case
QSerialPort
:
:
NoError
:
break
;
case
QSerialPort
:
:
ResourceError
:
emit
connectionRemoved
(
this
);
break
;
default:
// 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.
//qCDebug(SerialLinkLog) << "SerialLink::linkError" << error;
break
;
}
}
...
...
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