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
Next Next commit
Fix update_position being called when neither CPR changed
When we have ADS-B CPRs and get a MLAT synthetic CPR, don't call
updatePosition as this messes up the position state.
  • Loading branch information
wiedehopf committed Oct 18, 2019
commit 3388c27e58f9a7f53440fd57952f4f644f6bc0bc
7 changes: 5 additions & 2 deletions track.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ static int altitude_to_feet(int raw, altitude_unit_t unit) {

struct aircraft *trackUpdateFromMessage(struct modesMessage *mm) {
struct aircraft *a;
unsigned int cpr_new = 0;

if (mm->msgtype == 32) {
// Mode A/C, just count it (we ignore SPI)
Expand Down Expand Up @@ -1014,6 +1015,7 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm) {
a->cpr_even_lat = mm->cpr_lat;
a->cpr_even_lon = mm->cpr_lon;
compute_nic_rc_from_message(mm, a, &a->cpr_even_nic, &a->cpr_even_rc);
cpr_new = 1;
}

// CPR, odd
Expand All @@ -1022,6 +1024,7 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm) {
a->cpr_odd_lat = mm->cpr_lat;
a->cpr_odd_lon = mm->cpr_lon;
compute_nic_rc_from_message(mm, a, &a->cpr_odd_nic, &a->cpr_odd_rc);
cpr_new = 1;
}

if (mm->accuracy.sda_valid && accept_data(&a->sda_valid, mm->source)) {
Expand Down Expand Up @@ -1073,8 +1076,8 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm) {
combine_validity(&a->altitude_geom_valid, &a->altitude_baro_valid, &a->geom_delta_valid);
}

// If we've got a new cprlat or cprlon
if (mm->cpr_valid) {
// If we've got a new cpr_odd or cpr_even
if (cpr_new) {
updatePosition(a, mm);
}

Expand Down