// //========================================================================= // int main(int argc, char **argv) { int j; int stdout_option = 0; char *bo_connect_ipaddr = "127.0.0.1"; int bo_connect_port = MODES_NET_OUTPUT_BEAST_PORT; struct client *c; struct net_service *beast_input, *fatsv_output; // Set sane defaults faupInitConfig(); // Parse the command line options for (j = 1; j < argc; j++) { int more = j+1 < argc; // There are more arguments if (!strcmp(argv[j],"--net-bo-port") && more) { bo_connect_port = atoi(argv[++j]); } else if (!strcmp(argv[j],"--net-bo-ipaddr") && more) { bo_connect_ipaddr = argv[++j]; } else if (!strcmp(argv[j],"--lat") && more) { Modes.fUserLat = atof(argv[++j]); } else if (!strcmp(argv[j],"--lon") && more) { Modes.fUserLon = atof(argv[++j]); } else if (!strcmp(argv[j],"--max-range") && more) { Modes.maxRange = atof(argv[++j]) * 1852.0; // convert to metres } else if (!strcmp(argv[j],"--help")) { showHelp(); exit(0); } else if (!strcmp(argv[j],"--stdout")) { stdout_option = 1; } else { fprintf(stderr, "Unknown or not enough arguments for option '%s'.\n\n", argv[j]); showHelp(); exit(1); } } if (!stdout_option) { fprintf(stderr, "--stdout is required, output always goes to stdout.\n"); showHelp(); exit(1); } // Initialization faupInit(); modesInitNet(); // Set up input connection beast_input = makeBeastInputService(); c = serviceConnect(beast_input, bo_connect_ipaddr, bo_connect_port); if (!c) { fprintf (stderr, "faup1090: failed to connect to %s:%d (is dump1090 running?): %s\n", bo_connect_ipaddr, bo_connect_port, Modes.aneterr); exit (1); } // Set up output connection on stdout fatsv_output = makeFatsvOutputService(); createGenericClient(fatsv_output, STDOUT_FILENO); // Run it until we've lost either connection while (!Modes.exit && beast_input->connections && fatsv_output->connections) { backgroundTasks(); usleep(100000); } return 0; }
// //========================================================================= // int main(int argc, char **argv) { int j; struct client *c; struct net_service *s; char *bo_connect_ipaddr = "127.0.0.1"; int bo_connect_port = 30005; // Set sane defaults view1090InitConfig(); signal(SIGINT, sigintHandler); // Define Ctrl/C handler (exit program) // Parse the command line options for (j = 1; j < argc; j++) { int more = ((j + 1) < argc); // There are more arguments if (!strcmp(argv[j],"--net-bo-port") && more) { bo_connect_port = atoi(argv[++j]); } else if (!strcmp(argv[j],"--net-bo-ipaddr") && more) { bo_connect_ipaddr = argv[++j]; } else if (!strcmp(argv[j],"--modeac")) { Modes.mode_ac = 1; } else if (!strcmp(argv[j],"--interactive-rows") && more) { Modes.interactive_rows = atoi(argv[++j]); } else if (!strcmp(argv[j],"--no-interactive")) { Modes.interactive = 0; } else if (!strcmp(argv[j],"--show-only") && more) { Modes.show_only = (uint32_t) strtoul(argv[++j], NULL, 16); Modes.interactive = 0; } else if (!strcmp(argv[j],"--interactive-ttl") && more) { Modes.interactive_display_ttl = (uint64_t)(1000 * atof(argv[++j])); } else if (!strcmp(argv[j],"--interactive-rtl1090")) { Modes.interactive = 1; Modes.interactive_rtl1090 = 1; } else if (!strcmp(argv[j],"--lat") && more) { Modes.fUserLat = atof(argv[++j]); } else if (!strcmp(argv[j],"--lon") && more) { Modes.fUserLon = atof(argv[++j]); } else if (!strcmp(argv[j],"--metric")) { Modes.metric = 1; } else if (!strcmp(argv[j],"--no-crc-check")) { Modes.check_crc = 0; } else if (!strcmp(argv[j],"--fix")) { Modes.nfix_crc = 1; } else if (!strcmp(argv[j],"--no-fix")) { Modes.nfix_crc = 0; } else if (!strcmp(argv[j],"--aggressive")) { Modes.nfix_crc = MODES_MAX_BITERRORS; } else if (!strcmp(argv[j],"--max-range") && more) { Modes.maxRange = atof(argv[++j]) * 1852.0; // convert to metres } else if (!strcmp(argv[j],"--help")) { showHelp(); exit(0); } else { fprintf(stderr, "Unknown or not enough arguments for option '%s'.\n\n", argv[j]); showHelp(); exit(1); } } #ifdef _WIN32 // Try to comply with the Copyright license conditions for binary distribution if (!Modes.quiet) {showCopyright();} #define MSG_DONTWAIT 0 #endif #ifndef _WIN32 // Setup for SIGWINCH for handling lines if (Modes.interactive) {signal(SIGWINCH, sigWinchCallback);} #endif // Initialization view1090Init(); modesInitNet(); // Try to connect to the selected ip address and port. We only support *ONE* input connection which we initiate.here. s = makeBeastInputService(); c = serviceConnect(s, bo_connect_ipaddr, bo_connect_port); if (!c) { fprintf(stderr, "Failed to connect to %s:%d: %s\n", bo_connect_ipaddr, bo_connect_port, Modes.aneterr); exit(1); } // Keep going till the user does something that stops us while (!Modes.exit) { icaoFilterExpire(); trackPeriodicUpdate(); modesNetPeriodicWork(); if (Modes.interactive) interactiveShowData(); if (s->connections == 0) { // lost input connection, try to reconnect usleep(1000000); c = serviceConnect(s, bo_connect_ipaddr, bo_connect_port); continue; } usleep(100000); } return (0); }