From 4ecd6958a1683bc726b6393a559c25d1c76b53e6 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sun, 8 Feb 2015 18:00:18 +0000 Subject: [PATCH] If we squelch the first message from an aircraft, emit it when we see a second message. This is possible now that the SBS output doesn't rely on the global block timestamp; the output will look like this: MSG,8,111,11111,4AC954,111111,2015/02/08,17:57:53.917,2015/02/08,17:57:53.936,,,,,,,,,,,,0 MSG,7,111,11111,392AEB,111111,2015/02/08,17:57:53.744,2015/02/08,17:57:53.936,,15375,,,,,,,,,,0 MSG,8,111,11111,392AEB,111111,2015/02/08,17:57:53.917,2015/02/08,17:57:53.936,,,,,,,,,,,,0 MSG,6,111,11111,800387,111111,2015/02/08,17:57:53.919,2015/02/08,17:57:53.936,,,,,,,,4745,0,0,0,0 where the "receive timestamp" (first time column) goes backwards to reflect the original reception time of the delayed message, but the "forwarded timestamp" (second time column) reflects the actual forwarding time. --- dump1090.h | 4 +++- mode_s.c | 12 +++++++++++- track.c | 4 ++++ track.h | 2 ++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/dump1090.h b/dump1090.h index e9487dc..9ceafae 100644 --- a/dump1090.h +++ b/dump1090.h @@ -218,7 +218,6 @@ #include "stats.h" #include "cpr.h" #include "icao_filter.h" -#include "track.h" //======================== structure declarations ========================= @@ -406,6 +405,9 @@ struct modesMessage { int bFlags; // Flags related to fields in this structure }; +// This one needs modesMessage: +#include "track.h" + // ======================== function declarations ========================= #ifdef __cplusplus diff --git a/mode_s.c b/mode_s.c index 1a5db10..9c4cda0 100644 --- a/mode_s.c +++ b/mode_s.c @@ -1212,8 +1212,18 @@ void useModesMessage(struct modesMessage *mm) { // see a second message? if (Modes.net) { - if (Modes.net_verbatim || a->messages > 1) + if (Modes.net_verbatim || a->messages > 1) { + // If this is the second message, and we + // squelched the first message, then re-emit the + // first message now. + if (!Modes.net_verbatim && a->messages == 2) { + fprintf(stderr, "reemit first message for %06x\n", a->addr); + displayModesMessage(&a->first_message); + modesQueueOutput(&a->first_message); + } + modesQueueOutput(mm); + } } } diff --git a/track.c b/track.c index 48dda6d..593dc0c 100644 --- a/track.c +++ b/track.c @@ -80,6 +80,10 @@ struct aircraft *trackCreateAircraft(struct modesMessage *mm) { mm->bFlags |= MODES_ACFLAGS_ALTITUDE_VALID; } } + + // Copy the first message so we can emit it later when a second message arrives. + a->first_message = *mm; + return (a); } diff --git a/track.h b/track.h index b7c7535..4647f32 100644 --- a/track.h +++ b/track.h @@ -90,6 +90,8 @@ struct aircraft { double lat, lon; // Coordinated obtained from CPR encoded data int bFlags; // Flags related to valid fields in this structure struct aircraft *next; // Next aircraft in our linked list + + struct modesMessage first_message; // A copy of the first message we received for this aircraft. };