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
5b22bf87
Commit
5b22bf87
authored
Jul 06, 2020
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crash
parent
f0568496
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
24 deletions
+18
-24
Bootloader.cc
src/VehicleSetup/Bootloader.cc
+17
-23
Bootloader.h
src/VehicleSetup/Bootloader.h
+1
-1
No files found.
src/VehicleSetup/Bootloader.cc
View file @
5b22bf87
...
...
@@ -51,33 +51,27 @@ bool Bootloader::_write(QSerialPort* port, const uint8_t byte)
return
_write
(
port
,
buf
,
1
);
}
bool
Bootloader
::
_read
(
QSerialPort
*
port
,
uint8_t
*
data
,
qint64
maxSize
,
int
readTimeout
)
bool
Bootloader
::
_read
(
QSerialPort
*
port
,
uint8_t
*
data
,
qint64
cBytesExpected
,
int
readTimeout
)
{
qint64
bytesAlreadyRead
=
0
;
while
(
bytesAlreadyRead
<
maxSize
)
{
QElapsedTimer
timeout
;
timeout
.
start
();
while
(
port
->
bytesAvailable
()
<
1
)
{
if
(
timeout
.
elapsed
()
>
readTimeout
)
{
_errorString
=
tr
(
"Timeout waiting for bytes to be available"
);
return
false
;
}
port
->
waitForReadyRead
(
100
);
}
qint64
bytesRead
;
bytesRead
=
port
->
read
((
char
*
)
&
data
[
bytesAlreadyRead
],
maxSize
);
if
(
bytesRead
==
-
1
)
{
_errorString
=
tr
(
"Read failed: error: %1"
).
arg
(
port
->
errorString
());
QElapsedTimer
timeout
;
timeout
.
start
();
while
(
port
->
bytesAvailable
()
<
cBytesExpected
)
{
if
(
timeout
.
elapsed
()
>
readTimeout
)
{
_errorString
=
tr
(
"Timeout waiting for bytes to be available"
);
return
false
;
}
else
{
Q_ASSERT
(
bytesRead
!=
0
);
bytesAlreadyRead
+=
bytesRead
;
}
port
->
waitForReadyRead
(
100
);
}
qint64
bytesRead
;
bytesRead
=
port
->
read
((
char
*
)
data
,
cBytesExpected
);
if
(
bytesRead
!=
cBytesExpected
)
{
_errorString
=
tr
(
"Read failed: error: %1"
).
arg
(
port
->
errorString
());
return
false
;
}
return
true
;
}
...
...
src/VehicleSetup/Bootloader.h
View file @
5b22bf87
...
...
@@ -96,7 +96,7 @@ private:
bool
_write
(
QSerialPort
*
port
,
const
uint8_t
*
data
,
qint64
maxSize
);
bool
_write
(
QSerialPort
*
port
,
const
uint8_t
byte
);
bool
_read
(
QSerialPort
*
port
,
uint8_t
*
data
,
qint64
maxSize
,
int
readTimeout
=
_readTimout
);
bool
_read
(
QSerialPort
*
port
,
uint8_t
*
data
,
qint64
cBytesExpected
,
int
readTimeout
=
_readTimout
);
bool
_sendCommand
(
QSerialPort
*
port
,
uint8_t
cmd
,
int
responseTimeout
=
_responseTimeout
);
bool
_getCommandResponse
(
QSerialPort
*
port
,
const
int
responseTimeout
=
_responseTimeout
);
...
...
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