Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dump1090
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
Container registry
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Schumb
dump1090
Commits
474fe452
Commit
474fe452
authored
Feb 9, 2015
by
Oliver Jowett
Browse files
Options
Downloads
Patches
Plain Diff
Don't mark undecodable altitudes as ALTITUDE_VALID when decoding.
parent
54677f3a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mode_s.c
+15
-6
15 additions, 6 deletions
mode_s.c
with
15 additions
and
6 deletions
mode_s.c
+
15
−
6
View file @
474fe452
...
...
@@ -101,6 +101,9 @@ static int decodeID13Field(int ID13Field) {
return
(
hexGillham
);
}
#define INVALID_ALTITUDE (-9999)
//
//=========================================================================
//
...
...
@@ -123,15 +126,17 @@ static int decodeAC13Field(int AC13Field, int *unit) {
}
else
{
// N is an 11 bit Gillham coded altitude
int
n
=
ModeAToModeC
(
decodeID13Field
(
AC13Field
));
if
(
n
<
-
12
)
{
n
=
0
;}
if
(
n
<
-
12
)
{
return
INVALID_ALTITUDE
;
}
return
(
100
*
n
);
}
}
else
{
*
unit
=
MODES_UNIT_METERS
;
// TODO: Implement altitude when meter unit is selected
return
INVALID_ALTITUDE
;
}
return
0
;
}
//
//=========================================================================
...
...
@@ -153,7 +158,9 @@ static int decodeAC12Field(int AC12Field, int *unit) {
int
n
=
((
AC12Field
&
0x0FC0
)
<<
1
)
|
(
AC12Field
&
0x003F
);
n
=
ModeAToModeC
(
decodeID13Field
(
n
));
if
(
n
<
-
12
)
{
n
=
0
;}
if
(
n
<
-
12
)
{
return
INVALID_ALTITUDE
;
}
return
(
100
*
n
);
}
...
...
@@ -561,8 +568,9 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg)
if
(
mm
->
msgtype
==
0
||
mm
->
msgtype
==
4
||
mm
->
msgtype
==
16
||
mm
->
msgtype
==
20
)
{
int
AC13Field
=
((
msg
[
2
]
<<
8
)
|
msg
[
3
])
&
0x1FFF
;
if
(
AC13Field
)
{
// Only attempt to decode if a valid (non zero) altitude is present
mm
->
bFlags
|=
MODES_ACFLAGS_ALTITUDE_VALID
;
mm
->
altitude
=
decodeAC13Field
(
AC13Field
,
&
mm
->
unit
);
if
(
mm
->
altitude
!=
INVALID_ALTITUDE
)
mm
->
bFlags
|=
MODES_ACFLAGS_ALTITUDE_VALID
;
}
}
...
...
@@ -883,8 +891,9 @@ static void decodeExtendedSquitter(struct modesMessage *mm)
}
if
(
AC12Field
)
{
// Only attempt to decode if a valid (non zero) altitude is present
mm
->
bFlags
|=
MODES_ACFLAGS_ALTITUDE_VALID
;
mm
->
altitude
=
decodeAC12Field
(
AC12Field
,
&
mm
->
unit
);
if
(
mm
->
altitude
!=
INVALID_ALTITUDE
)
mm
->
bFlags
|=
MODES_ACFLAGS_ALTITUDE_VALID
;
}
if
(
metype
==
0
||
metype
==
18
||
metype
==
22
)
...
...
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