Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qgroundcontrol
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Valentin Platzgummer
qgroundcontrol
Commits
5b22bf87
Commit
5b22bf87
authored
4 years ago
by
Don Gagne
Browse files
Options
Downloads
Patches
Plain Diff
Fix crash
parent
f0568496
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/VehicleSetup/Bootloader.cc
+17
-23
17 additions, 23 deletions
src/VehicleSetup/Bootloader.cc
src/VehicleSetup/Bootloader.h
+1
-1
1 addition, 1 deletion
src/VehicleSetup/Bootloader.h
with
18 additions
and
24 deletions
src/VehicleSetup/Bootloader.cc
+
17
−
23
View file @
5b22bf87
...
@@ -51,14 +51,12 @@ bool Bootloader::_write(QSerialPort* port, const uint8_t byte)
...
@@ -51,14 +51,12 @@ bool Bootloader::_write(QSerialPort* port, const uint8_t byte)
return
_write
(
port
,
buf
,
1
);
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
;
QElapsedTimer
timeout
;
timeout
.
start
();
timeout
.
start
();
while
(
port
->
bytesAvailable
()
<
1
)
{
while
(
port
->
bytesAvailable
()
<
cBytesExpected
)
{
if
(
timeout
.
elapsed
()
>
readTimeout
)
{
if
(
timeout
.
elapsed
()
>
readTimeout
)
{
_errorString
=
tr
(
"Timeout waiting for bytes to be available"
);
_errorString
=
tr
(
"Timeout waiting for bytes to be available"
);
return
false
;
return
false
;
...
@@ -67,15 +65,11 @@ bool Bootloader::_read(QSerialPort* port, uint8_t* data, qint64 maxSize, int rea
...
@@ -67,15 +65,11 @@ bool Bootloader::_read(QSerialPort* port, uint8_t* data, qint64 maxSize, int rea
}
}
qint64
bytesRead
;
qint64
bytesRead
;
bytesRead
=
port
->
read
((
char
*
)
&
data
[
bytesAlreadyRead
],
maxSize
);
bytesRead
=
port
->
read
((
char
*
)
data
,
cBytesExpected
);
if
(
bytesRead
=
=
-
1
)
{
if
(
bytesRead
!
=
cBytesExpected
)
{
_errorString
=
tr
(
"Read failed: error: %1"
).
arg
(
port
->
errorString
());
_errorString
=
tr
(
"Read failed: error: %1"
).
arg
(
port
->
errorString
());
return
false
;
return
false
;
}
else
{
Q_ASSERT
(
bytesRead
!=
0
);
bytesAlreadyRead
+=
bytesRead
;
}
}
}
return
true
;
return
true
;
...
...
This diff is collapsed.
Click to expand it.
src/VehicleSetup/Bootloader.h
+
1
−
1
View file @
5b22bf87
...
@@ -96,7 +96,7 @@ private:
...
@@ -96,7 +96,7 @@ private:
bool
_write
(
QSerialPort
*
port
,
const
uint8_t
*
data
,
qint64
maxSize
);
bool
_write
(
QSerialPort
*
port
,
const
uint8_t
*
data
,
qint64
maxSize
);
bool
_write
(
QSerialPort
*
port
,
const
uint8_t
byte
);
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
_sendCommand
(
QSerialPort
*
port
,
uint8_t
cmd
,
int
responseTimeout
=
_responseTimeout
);
bool
_getCommandResponse
(
QSerialPort
*
port
,
const
int
responseTimeout
=
_responseTimeout
);
bool
_getCommandResponse
(
QSerialPort
*
port
,
const
int
responseTimeout
=
_responseTimeout
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment