Extract NUCp from message type; needed for #16.

This commit is contained in:
Oliver Jowett 2015-02-09 14:14:12 +00:00
parent e7e7f9e7c2
commit 9fd0c822f6
2 changed files with 12 additions and 1 deletions

View file

@ -381,6 +381,7 @@ struct modesMessage {
int heading; // Reported by aircraft, or computed from from EW and NS velocity int heading; // Reported by aircraft, or computed from from EW and NS velocity
int raw_latitude; // Non decoded latitude. int raw_latitude; // Non decoded latitude.
int raw_longitude; // Non decoded longitude. int raw_longitude; // Non decoded longitude.
unsigned nuc_p; // NUCp value implied by message type
double fLat; // Coordinates obtained from CPR encoded data if/when decoded double fLat; // Coordinates obtained from CPR encoded data if/when decoded
double fLon; // Coordinates obtained from CPR encoded data if/when decoded double fLon; // Coordinates obtained from CPR encoded data if/when decoded
char flight[16]; // 8 chars flight number. char flight[16]; // 8 chars flight number.

View file

@ -839,6 +839,7 @@ static void decodeExtendedSquitter(struct modesMessage *mm)
mm->heading = ((((msg[5] << 4) | (msg[6] >> 4)) & 0x007F) * 45) >> 4; mm->heading = ((((msg[5] << 4) | (msg[6] >> 4)) & 0x007F) * 45) >> 4;
} }
mm->nuc_p = (14 - metype);
break; break;
} }
@ -879,6 +880,13 @@ static void decodeExtendedSquitter(struct modesMessage *mm)
mm->altitude = decodeAC12Field(AC12Field, &mm->unit); mm->altitude = decodeAC12Field(AC12Field, &mm->unit);
} }
if (metype == 0 || metype == 18 || metype == 22)
mm->nuc_p = 0;
else if (metype < 18)
mm->nuc_p = (18 - metype);
else
mm->nuc_p = (29 - metype);
break; break;
} }
@ -986,11 +994,13 @@ static void displayExtendedSquitter(struct modesMessage *mm) {
printf(" Global CPR decoding used.\n"); printf(" Global CPR decoding used.\n");
printf(" Latitude : %f (%d)\n", mm->fLat, mm->raw_latitude); printf(" Latitude : %f (%d)\n", mm->fLat, mm->raw_latitude);
printf(" Longitude: %f (%d)\n", mm->fLon, mm->raw_longitude); printf(" Longitude: %f (%d)\n", mm->fLon, mm->raw_longitude);
printf(" NUCp: %u\n", mm->nuc_p);
} else { } else {
if (!(mm->bFlags & MODES_ACFLAGS_LLEITHER_VALID)) if (!(mm->bFlags & MODES_ACFLAGS_LLEITHER_VALID))
printf(" Bad position data, not decoded.\n"); printf(" Bad position data, not decoded.\n");
printf(" Latitude : %d (not decoded)\n", mm->raw_latitude); printf(" Latitude : %d (not decoded)\n", mm->raw_latitude);
printf(" Longitude: %d (not decoded)\n", mm->raw_longitude); printf(" Longitude: %d (not decoded)\n", mm->raw_longitude);
printf(" NUCp: %u\n", mm->nuc_p);
} }
} else if (mm->metype == 28) { // Extended Squitter Aircraft Status } else if (mm->metype == 28) { // Extended Squitter Aircraft Status
if (mm->mesub == 1) { if (mm->mesub == 1) {