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
7f4cb987
Commit
7f4cb987
authored
May 14, 2013
by
Michael Carpenter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
On no serial data, now attempts both a "reboot" reset, and then a DTR reset of the autopilot
parent
7588d140
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
SerialLink.cc
src/comm/SerialLink.cc
+38
-1
SerialLink.h
src/comm/SerialLink.h
+1
-0
No files found.
src/comm/SerialLink.cc
View file @
7f4cb987
...
...
@@ -213,7 +213,8 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl,
int
dataBits
,
int
stopBits
)
:
port
(
NULL
),
ports
(
new
QVector
<
QString
>
()),
m_stopp
(
false
)
m_stopp
(
false
),
bytesRead
(
0
)
{
// Setup settings
this
->
porthandle
=
portname
.
trimmed
();
...
...
@@ -396,6 +397,10 @@ void SerialLink::run()
hardwareConnect
();
// Qt way to make clear what a while(1) loop does
quint64
msecs
=
QDateTime
::
currentMSecsSinceEpoch
();
quint64
bytes
=
0
;
bool
triedreset
=
false
;
bool
triedDTR
=
false
;
forever
{
{
...
...
@@ -408,6 +413,37 @@ void SerialLink::run()
}
// Check if new bytes have arrived, if yes, emit the notification signal
checkForBytes
();
if
(
bytes
!=
bytesRead
)
{
bytes
=
bytesRead
;
msecs
=
QDateTime
::
currentMSecsSinceEpoch
();
}
else
{
if
(
QDateTime
::
currentMSecsSinceEpoch
()
-
msecs
>
10000
)
{
//It's been 10 seconds since the last data came in. Reset and try again
msecs
=
QDateTime
::
currentMSecsSinceEpoch
();
if
(
!
triedDTR
&&
triedreset
)
{
triedDTR
=
true
;
qDebug
()
<<
"No data!!! Attempting reset via DTR."
;
port
->
setDtr
(
true
);
this
->
msleep
(
250
);
port
->
setDtr
(
false
);
}
else
if
(
!
triedreset
)
{
qDebug
()
<<
"No data!!! Attempting reset via reboot command."
;
port
->
write
(
"reboot
\r\n
"
,
8
);
triedreset
=
true
;
}
else
{
qDebug
()
<<
"No data!!!"
;
}
}
}
/* Serial data isn't arriving that fast normally, this saves the thread
* from consuming too much processing time
*/
...
...
@@ -435,6 +471,7 @@ void SerialLink::checkForBytes()
if
(
available
>
0
)
{
readBytes
();
bytesRead
+=
available
;
}
else
if
(
available
<
0
)
{
/* Error, close port */
...
...
src/comm/SerialLink.h
View file @
7f4cb987
...
...
@@ -144,6 +144,7 @@ protected slots:
void
checkForBytes
();
protected:
quint64
bytesRead
;
TNX
::
QSerialPort
*
port
;
TNX
::
QPortSettings
portSettings
;
#ifdef _WIN32
...
...
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