Skip to content
This repository has been archived by the owner on Sep 14, 2019. It is now read-only.

Commit

Permalink
Use the right inter-CPR max interval for surface position messages. F…
Browse files Browse the repository at this point in the history
…ixes #18.
  • Loading branch information
mutability committed Feb 9, 2015
1 parent 9fd0c82 commit f19eee8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion track.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,19 @@ static int doLocalCPR(struct aircraft *a, int fflag, int surface, time_t now)
static void updatePosition(struct aircraft *a, struct modesMessage *mm, time_t now)
{
int location_result = -1;
int max_elapsed;

if (mm->bFlags & MODES_ACFLAGS_AOG) {
// Surface: 25 seconds if >25kt or speed unknown, 50 seconds otherwise

if ((mm->bFlags & MODES_ACFLAGS_SPEED_VALID) && mm->velocity <= 25)
max_elapsed = 50000;
else
max_elapsed = 25000;
} else {
// Airborne: 10 seconds
max_elapsed = 10000;
}

if (mm->bFlags & MODES_ACFLAGS_LLODD_VALID) {
a->odd_cprlat = mm->raw_latitude;
Expand All @@ -247,7 +260,7 @@ static void updatePosition(struct aircraft *a, struct modesMessage *mm, time_t n
}

// If we have enough recent data, try global CPR
if (((mm->bFlags | a->bFlags) & MODES_ACFLAGS_LLEITHER_VALID) == MODES_ACFLAGS_LLBOTH_VALID && abs((int)(a->even_cprtime - a->odd_cprtime)) <= 10000) {
if (((mm->bFlags | a->bFlags) & MODES_ACFLAGS_LLEITHER_VALID) == MODES_ACFLAGS_LLBOTH_VALID && abs((int)(a->even_cprtime - a->odd_cprtime)) <= max_elapsed) {
location_result = doGlobalCPR(a, (mm->bFlags & MODES_ACFLAGS_LLODD_VALID), (mm->bFlags & MODES_ACFLAGS_AOG));
if (location_result == -2) {
// Global CPR failed because an airborne position produced implausible results.
Expand Down

0 comments on commit f19eee8

Please sign in to comment.