diff --git a/dump1090.c b/dump1090.c index e8d0179..8e84a60 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")) {