From db9f5f34a33c7bac44856367d912650d5b8a3cd7 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 3 Feb 2020 16:15:05 +0100 Subject: [PATCH] --loop option to read input file again and again. --- dump1090.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dump1090.c b/dump1090.c index e8d01799b..8e84a60ac 100644 --- a/dump1090.c +++ b/dump1090.c @@ -155,6 +155,7 @@ struct { /* Configuration */ char *filename; /* Input form file, --ifile option. */ + int loop; /* Read input file again and again. */ int fix_errors; /* Single bit error correction if true. */ int check_crc; /* Only display messages with good CRC. */ int raw; /* Raw output format. */ @@ -274,6 +275,7 @@ void modesInitConfig(void) { Modes.interactive_ttl = MODES_INTERACTIVE_TTL; Modes.aggressive = 0; Modes.interactive_rows = getTermRows(); + Modes.loop = 0; } void modesInit(void) { @@ -434,10 +436,11 @@ void readDataFromFile(void) { while(toread) { nread = read(Modes.fd, p, toread); /* In --file mode, seek the file again from the start - * and re-play it. */ + * and re-play it if --loop was given. */ if (nread == 0 && Modes.filename != NULL && - Modes.fd != STDIN_FILENO) + Modes.fd != STDIN_FILENO && + Modes.loop) { if (lseek(Modes.fd,0,SEEK_SET) != -1) continue; } @@ -2440,6 +2443,7 @@ void showHelp(void) { "--enable-agc Enable the Automatic Gain Control (default: off).\n" "--freq Set frequency (default: 1090 Mhz).\n" "--ifile Read data from file (use '-' for stdin).\n" +"--loop With --ifile, read the same file in a loop.\n" "--interactive Interactive mode refreshing data on screen.\n" "--interactive-rows Max number of rows in interactive mode (default: 15).\n" "--interactive-ttl Remove from list if idle for (default: 60).\n" @@ -2511,6 +2515,8 @@ int main(int argc, char **argv) { Modes.freq = strtoll(argv[++j],NULL,10); } else if (!strcmp(argv[j],"--ifile") && more) { Modes.filename = strdup(argv[++j]); + } else if (!strcmp(argv[j],"--loop")) { + Modes.loop = 1; } else if (!strcmp(argv[j],"--no-fix")) { Modes.fix_errors = 0; } else if (!strcmp(argv[j],"--no-crc-check")) {