From 9fd0c822f6605c8c22cc1c4ec5c8df4da06e0b64 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Mon, 9 Feb 2015 14:14:12 +0000 Subject: [PATCH] Extract NUCp from message type; needed for #16. --- dump1090.h | 1 + mode_s.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dump1090.h b/dump1090.h index 9ceafae..9e0d862 100644 --- a/dump1090.h +++ b/dump1090.h @@ -381,6 +381,7 @@ struct modesMessage { int heading; // Reported by aircraft, or computed from from EW and NS velocity int raw_latitude; // Non decoded latitude. 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 fLon; // Coordinates obtained from CPR encoded data if/when decoded char flight[16]; // 8 chars flight number. diff --git a/mode_s.c b/mode_s.c index 87bdfcc..2f70f1f 100644 --- a/mode_s.c +++ b/mode_s.c @@ -838,7 +838,8 @@ static void decodeExtendedSquitter(struct modesMessage *mm) mm->bFlags |= MODES_ACFLAGS_HEADING_VALID; mm->heading = ((((msg[5] << 4) | (msg[6] >> 4)) & 0x007F) * 45) >> 4; } - + + mm->nuc_p = (14 - metype); break; } @@ -878,6 +879,13 @@ static void decodeExtendedSquitter(struct modesMessage *mm) mm->bFlags |= MODES_ACFLAGS_ALTITUDE_VALID; 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; } @@ -986,11 +994,13 @@ static void displayExtendedSquitter(struct modesMessage *mm) { printf(" Global CPR decoding used.\n"); printf(" Latitude : %f (%d)\n", mm->fLat, mm->raw_latitude); printf(" Longitude: %f (%d)\n", mm->fLon, mm->raw_longitude); + printf(" NUCp: %u\n", mm->nuc_p); } else { if (!(mm->bFlags & MODES_ACFLAGS_LLEITHER_VALID)) printf(" Bad position data, not decoded.\n"); printf(" Latitude : %d (not decoded)\n", mm->raw_latitude); 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 if (mm->mesub == 1) {