Skip to content

Commit

Permalink
--loop option to read input file again and again.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Feb 3, 2020
1 parent 07d194b commit db9f5f3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dump1090.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -2440,6 +2443,7 @@ void showHelp(void) {
"--enable-agc Enable the Automatic Gain Control (default: off).\n"
"--freq <hz> Set frequency (default: 1090 Mhz).\n"
"--ifile <filename> 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 <num> Max number of rows in interactive mode (default: 15).\n"
"--interactive-ttl <sec> Remove from list if idle for <sec> (default: 60).\n"
Expand Down Expand Up @@ -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")) {
Expand Down

0 comments on commit db9f5f3

Please sign in to comment.