Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.
/ readsb Public archive

Some improvements for position updating / CPR handling #19

Merged
merged 2 commits into from
Oct 19, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Don't throw away both CPRs, most likely only one is bad.
If we receive a new CPR and the old CPR is the one with bad data, we
will throw the data away again.  But if we are lucky and receive the
CPR that was bad, we get a good position again faster.  Also this
makes the speed check impossible on the next decode, which is bad.
Instead move the position validity closer to expiration.
That should help with wrongly accepting a bad position and failing
all speed checks afterwards.
  • Loading branch information
wiedehopf committed Oct 18, 2019
commit 1aa531588092473c68e2c1f6a4626a2e6c2d6bfb
16 changes: 12 additions & 4 deletions track.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,19 @@ static void updatePosition(struct aircraft *a, struct modesMessage *mm) {
fprintf(stderr, "global CPR failure (invalid) for (%06X).\n", a->addr);
#endif
// Global CPR failed because the position produced implausible results.
// This is bad data. Discard both odd and even messages and wait for a fresh pair.
// Also disable aircraft-relative positions until we have a new good position (but don't discard the
// recorded position itself)
// This is bad data. In case the previously decoded (current)
// position is incorrect, reduce the 70 second expires timer by 25
// seconds, so repeated failures will lead to invalidation of the
// current position and a new position can be determined. Without
// this a bad current position might block valid new positions for
// up to a minute due to the speed check.

Modes.stats_current.cpr_global_bad++;
a->cpr_odd_valid.source = a->cpr_even_valid.source = a->position_valid.source = SOURCE_INVALID;

a->cpr_odd_valid.expires -= 25;
a->cpr_even_valid.expires -= 25;
a->position_valid.expires -= 25;


return;
} else if (location_result == -1) {
Expand Down