From 95ab1c0faa2a76e9e5cccaf7b60b9cbabcf6892b Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Thu, 29 Jul 2021 19:04:53 +0800 Subject: [PATCH] faup1090: upload unknown-format Comm-B messages on demand --- dump1090.h | 1 + net_io.c | 19 ++++++++++++++++++- track.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/dump1090.h b/dump1090.h index edcd43b..0ec6def 100644 --- a/dump1090.h +++ b/dump1090.h @@ -385,6 +385,7 @@ struct _Modes { // Internal state uint64_t json_stats_interval; // Interval between rewriting the json stats file, in milliseconds int json_location_accuracy; // Accuracy of location metadata: 0=none, 1=approx, 2=exact double faup_rate_multiplier; // Multiplier to adjust rate of faup1090 messages emitted + bool faup_upload_unknown_commb; // faup1090: should we upload Comm-B messages that weren't in a recognized format? int json_aircraft_history_next; struct { diff --git a/net_io.c b/net_io.c index 61b7f65..eb56672 100644 --- a/net_io.c +++ b/net_io.c @@ -1126,7 +1126,7 @@ static int handleFaupCommand(struct client *c, char *p) { // Traverse through message for commands while (msg_field != NULL) { - if (strcmp(msg_field, "upload_rate_multiplier") == 0) { + if (!strcmp(msg_field, "upload_rate_multiplier")) { msg_field = strtok (NULL, "\t"); multiplier = atof(msg_field); @@ -1140,6 +1140,14 @@ static int handleFaupCommand(struct client *c, char *p) { Modes.faup_rate_multiplier = multiplier; break; } + + if (!strcmp(msg_field, "upload_unknown_commb")) { + msg_field = strtok (NULL, "\t"); + unsigned enable = atoi(msg_field); + fprintf(stderr, "handleFaupCommand(): %s upload of unknown Comm-B messages\n", enable ? "Enabling" : "Disabling"); + Modes.faup_upload_unknown_commb = enable; + break; + } msg_field = strtok (NULL, "\t"); } @@ -2360,6 +2368,15 @@ static void writeFATSVEvent(struct modesMessage *mm, struct aircraft *a) } break; + case COMMB_UNKNOWN: + // If enabled, upload raw unrecognized Comm-B messages + // for server-side analysis + if (Modes.faup_upload_unknown_commb && memcmp(mm->MB, a->fatsv_emitted_unknown_commb, 7) != 0) { + memcpy(a->fatsv_emitted_unknown_commb, mm->MB, 7); + writeFATSVEventMessage(mm, "unknown_commb", mm->MB, 7); + } + break; + default: // nothing break; diff --git a/track.h b/track.h index 4bad096..5fc04f4 100644 --- a/track.h +++ b/track.h @@ -252,6 +252,7 @@ struct aircraft { unsigned char fatsv_emitted_bds_10[7]; // -"- BDS 1,0 message unsigned char fatsv_emitted_bds_17[7]; // -"- BDS 1,7 message unsigned char fatsv_emitted_bds_30[7]; // -"- BDS 3,0 message + unsigned char fatsv_emitted_unknown_commb[7]; // -"- unrecognized Comm-B message unsigned char fatsv_emitted_es_status[7]; // -"- ES operational status message unsigned char fatsv_emitted_es_acas_ra[7]; // -"- ES ACAS RA report message char fatsv_emitted_callsign[9]; // -"- callsign