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
0ea21917
Commit
0ea21917
authored
Nov 11, 2016
by
Andreas Bircher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reading the message lengthts from the header of the binary log file
Conflicts: src/AnalyzeView/GeoTagController.cc
parent
b36d59c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
11 deletions
+28
-11
GeoTagController.cc
src/AnalyzeView/GeoTagController.cc
+28
-11
No files found.
src/AnalyzeView/GeoTagController.cc
View file @
0ea21917
...
...
@@ -282,14 +282,21 @@ bool GeoTagWorker::parsePX4Log()
{
// general message header
char
header
[]
=
{(
char
)
0xA3
,
(
char
)
0x95
,
(
char
)
0x00
};
// header for GPOS message header
char
gposHeaderHeader
[]
=
{(
char
)
0xA3
,
(
char
)
0x95
,
(
char
)
0x80
,
(
char
)
0x10
,
(
char
)
0x00
};
int
gposHeaderOffset
;
// header for GPOS message
char
gposHeader
[]
=
{(
char
)
0xA3
,
(
char
)
0x95
,
(
char
)
0x10
,
(
char
)
0x00
};
int
gposOffsets
[
3
]
=
{
3
,
7
,
11
};
int
gposLengths
[
3
]
=
{
4
,
4
,
4
};
// header for trigger message header
char
triggerHeaderHeader
[]
=
{(
char
)
0xA3
,
(
char
)
0x95
,
(
char
)
0x80
,
(
char
)
0x37
,
(
char
)
0x00
};
int
triggerHeaderOffset
;
// header for trigger message
char
triggerHeader
[]
=
{(
char
)
0xA3
,
(
char
)
0x95
,
(
char
)
0x37
,
(
char
)
0x00
};
int
triggerOffsets
[
2
]
=
{
3
,
11
};
int
triggerLengths
[
2
]
=
{
8
,
4
};
// load log
QFile
file
(
_logFile
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
...
...
@@ -299,6 +306,12 @@ bool GeoTagWorker::parsePX4Log()
QByteArray
log
=
file
.
readAll
();
file
.
close
();
// extract header information: message lengths
uint8_t
*
iptr
=
reinterpret_cast
<
uint8_t
*>
(
log
.
mid
(
log
.
indexOf
(
gposHeaderHeader
)
+
4
,
1
).
data
());
gposHeaderOffset
=
static_cast
<
int
>
(
qFromLittleEndian
(
*
iptr
));
iptr
=
reinterpret_cast
<
uint8_t
*>
(
log
.
mid
(
log
.
indexOf
(
triggerHeaderHeader
)
+
4
,
1
).
data
());
triggerHeaderOffset
=
static_cast
<
int
>
(
qFromLittleEndian
(
*
iptr
));
// extract trigger data
int
index
=
1
;
int
sequence
=
-
1
;
...
...
@@ -310,20 +323,24 @@ bool GeoTagWorker::parsePX4Log()
}
// first extract trigger
in
t
triggerIn
dex
=
log
.
indexOf
(
triggerHeader
,
index
+
1
);
index
=
log
.
indexOf
(
triggerHeader
,
index
+
1
);
// check for whether last entry has been passed
if
(
triggerI
ndex
<
0
)
{
if
(
i
ndex
<
0
)
{
break
;
}
uint64_t
*
time
=
reinterpret_cast
<
uint64_t
*>
(
log
.
mid
(
triggerIndex
+
triggerOffsets
[
0
],
triggerLengths
[
0
]).
data
());
double
timeDouble
=
static_cast
<
double
>
(
qFromLittleEndian
(
*
time
));
uint32_t
*
seq
=
reinterpret_cast
<
uint32_t
*>
(
log
.
mid
(
triggerIndex
+
triggerOffsets
[
1
],
triggerLengths
[
1
]).
data
());
if
(
log
.
indexOf
(
header
,
index
+
1
)
!=
index
+
triggerHeaderOffset
)
{
continue
;
}
uint64_t
*
time
=
reinterpret_cast
<
uint64_t
*>
(
log
.
mid
(
index
+
triggerOffsets
[
0
],
triggerLengths
[
0
]).
data
());
double
timeDouble
=
static_cast
<
double
>
(
qFromLittleEndian
(
*
time
))
/
1.0e6
;
uint32_t
*
seq
=
reinterpret_cast
<
uint32_t
*>
(
log
.
mid
(
index
+
triggerOffsets
[
1
],
triggerLengths
[
1
]).
data
());
int
seqInt
=
static_cast
<
int
>
(
qFromLittleEndian
(
*
seq
));
if
(
sequence
<
seqInt
&&
sequence
+
20
>
seqInt
)
{
// assume that logging has not skipped more than 20 triggers. this prevents wrong header detection
_triggerTime
.
append
(
timeDouble
/
1000000.0
);
sequence
=
seqInt
;
if
(
sequence
>=
seqInt
||
sequence
+
20
<
seqInt
)
{
// assume that logging has not skipped more than 20 triggers. this prevents wrong header detection
continue
;
}
index
=
triggerIndex
;
// extract next entry gpos
_triggerTime
.
append
(
timeDouble
);
sequence
=
seqInt
;
// second extract position
bool
lookForGpos
=
true
;
...
...
@@ -339,8 +356,8 @@ bool GeoTagWorker::parsePX4Log()
break
;
}
index
=
gposIndex
;
// verify that at an offset of
27
the next log message starts
if
(
gposIndex
+
27
==
log
.
indexOf
(
header
,
gposIndex
+
1
))
{
// verify that at an offset of
gposHeaderOffset
the next log message starts
if
(
gposIndex
+
gposHeaderOffset
==
log
.
indexOf
(
header
,
gposIndex
+
1
))
{
int32_t
*
lat
=
reinterpret_cast
<
int32_t
*>
(
log
.
mid
(
gposIndex
+
gposOffsets
[
0
],
gposLengths
[
0
]).
data
());
double
latitude
=
static_cast
<
double
>
(
qFromLittleEndian
(
*
lat
))
/
1.0e7
;
lastCoordinate
.
setLatitude
(
latitude
);
...
...
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