Fix update_position being called when neither CPR changed
When we have ADS-B CPRs and get for example a MLAT synthetic CPR, don't call updatePosition as this messes up the position state.
This commit is contained in:
parent
089684e20f
commit
aa2b205481
8
track.c
8
track.c
|
|
@ -898,6 +898,8 @@ static int altitude_to_feet(int raw, altitude_unit_t unit)
|
||||||
struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
|
struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
|
||||||
{
|
{
|
||||||
struct aircraft *a;
|
struct aircraft *a;
|
||||||
|
unsigned int cpr_new = 0;
|
||||||
|
|
||||||
|
|
||||||
if (mm->msgtype == 32) {
|
if (mm->msgtype == 32) {
|
||||||
// Mode A/C, just count it (we ignore SPI)
|
// Mode A/C, just count it (we ignore SPI)
|
||||||
|
|
@ -1123,6 +1125,7 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
|
||||||
a->cpr_even_lat = mm->cpr_lat;
|
a->cpr_even_lat = mm->cpr_lat;
|
||||||
a->cpr_even_lon = mm->cpr_lon;
|
a->cpr_even_lon = mm->cpr_lon;
|
||||||
compute_nic_rc_from_message(mm, a, &a->cpr_even_nic, &a->cpr_even_rc);
|
compute_nic_rc_from_message(mm, a, &a->cpr_even_nic, &a->cpr_even_rc);
|
||||||
|
cpr_new = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CPR, odd
|
// CPR, odd
|
||||||
|
|
@ -1131,6 +1134,7 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
|
||||||
a->cpr_odd_lat = mm->cpr_lat;
|
a->cpr_odd_lat = mm->cpr_lat;
|
||||||
a->cpr_odd_lon = mm->cpr_lon;
|
a->cpr_odd_lon = mm->cpr_lon;
|
||||||
compute_nic_rc_from_message(mm, a, &a->cpr_odd_nic, &a->cpr_odd_rc);
|
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)) {
|
if (mm->accuracy.sda_valid && accept_data(&a->sda_valid, mm->source)) {
|
||||||
|
|
@ -1182,8 +1186,8 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
|
||||||
combine_validity(&a->altitude_geom_valid, &a->altitude_baro_valid, &a->geom_delta_valid);
|
combine_validity(&a->altitude_geom_valid, &a->altitude_baro_valid, &a->geom_delta_valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've got a new cprlat or cprlon
|
// If we've got a new cpr_odd or cpr_even
|
||||||
if (mm->cpr_valid) {
|
if (cpr_new) {
|
||||||
updatePosition(a, mm);
|
updatePosition(a, mm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue