From e7e9cecc1a86d365c18660ad2f68d8eed741f6c2 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Thu, 18 Jun 2015 11:24:01 +0100 Subject: [PATCH] Add --throttle option. This gives access to the existing throttling behaviour when reading from a file with --interactive, without needing to actually have --interactive. This is useful when testing, as without --throttle samples will be processsed much faster than real-time, which can produce different results with e.g. aircraft/filter expiry times and position/speed checks. --- dump1090.c | 9 ++++++--- dump1090.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dump1090.c b/dump1090.c index a8e96af..32e567b 100644 --- a/dump1090.c +++ b/dump1090.c @@ -558,7 +558,7 @@ void readDataFromFile(void) { // Convert the new data convert_samples(readbuf, &outbuf->data[Modes.trailing_samples], slen, &outbuf->total_power); - if (Modes.interactive) { + if (Modes.throttle) { // Wait until we are allowed to release this buffer to the main thread while (clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &next_buffer_delivery, NULL) == EINTR) ; @@ -670,7 +670,8 @@ void showHelp(void) { "--freq Set frequency (default: 1090 Mhz)\n" "--ifile Read data from file (use '-' for stdin)\n" "--iformat Sample format for --ifile: UC8 (default), SC16, or SC16Q11\n" -"--interactive Interactive mode refreshing data on screen\n" +"--throttle When reading from a file, play back in realtime, not at max speed\n" +"--interactive Interactive mode refreshing data on screen. Implies --throttle\n" "--interactive-rows Max number of rows in interactive mode (default: 15)\n" "--interactive-ttl Remove from list if idle for (default: 60)\n" "--interactive-rtl1090 Display flight table in RTL1090 format\n" @@ -997,7 +998,9 @@ int main(int argc, char **argv) { } else if (!strcmp(argv[j],"--aggressive")) { Modes.nfix_crc = MODES_MAX_BITERRORS; } else if (!strcmp(argv[j],"--interactive")) { - Modes.interactive = 1; + Modes.interactive = Modes.throttle = 1; + } else if (!strcmp(argv[j],"--throttle")) { + Modes.throttle = 1; } else if (!strcmp(argv[j],"--interactive-rows") && more) { Modes.interactive_rows = atoi(argv[++j]); } else if (!strcmp(argv[j],"--interactive-ttl") && more) { diff --git a/dump1090.h b/dump1090.h index 67f0c11..12701f8 100644 --- a/dump1090.h +++ b/dump1090.h @@ -339,6 +339,7 @@ struct { // Internal state char *json_dir; // Path to json base directory, or NULL not to write json. uint64_t json_interval; // Interval between rewriting the json aircraft file, in milliseconds; also the advertised map refresh interval int json_location_accuracy; // Accuracy of location metadata: 0=none, 1=approx, 2=exact + int throttle; // When reading from a file, throttle file playback to realtime? int json_aircraft_history_next; struct {