From 298afdaa8f15a47c0955c934c8862c237283c300 Mon Sep 17 00:00:00 2001 From: Karl Lehenbauer Date: Mon, 18 Aug 2014 17:59:46 -0500 Subject: [PATCH] faup1090 startup and logging improvements * If faup1090 can't start because the 10001 port is already in use it will now exit with an exit status of 98 (EADDRINUSE). * Emit the faup1090 version number if faup1090 is run with the --help argument. * Make wicked sure we don't come up on any other ports that we shouldn't be on. * Add "install" argument to faup1090 makefile makefaup1090. BUGZID: --- faup1090.c | 16 ++++++++-------- faup1090.h | 9 +++++---- makefaup1090 | 6 ++++++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/faup1090.c b/faup1090.c index a8803b5..4e02411 100644 --- a/faup1090.c +++ b/faup1090.c @@ -160,7 +160,7 @@ void faupInitNet(void) { // {"Beast TCP input", &Modes.bis, Modes.net_input_beast_port, 0}, // {"HTTP server", &Modes.https, Modes.net_http_port, 0}, // {"Basestation TCP output", &Modes.sbsos, Modes.net_output_sbs_port, 0}, - {"FlightAware TSV output", &Modes.fatsvos, MODES_NET_OUTPUT_FA_TSV_PORT, 1} + {"FlightAware TSV output", &Modes.fatsvos, Modes.net_fatsv_port, 1} }; memcpy(&services, &svc, sizeof(svc));//services = svc; @@ -183,8 +183,11 @@ void faupInitNet(void) { if (services[j].enabled) { int s = anetTcpServer(Modes.aneterr, services[j].port, NULL); if (s == -1) { - fprintf(stderr, "Error opening the listening port %d (%s): %s\n", + fprintf(stderr, "faup1090: error opening the listening port %d (%s): %s\n", services[j].port, services[j].descr, strerror(errno)); + if (errno == EADDRINUSE) { + exit(98); + } exit(1); } anetNonBlock(Modes.aneterr, s); @@ -205,9 +208,8 @@ void faupInitNet(void) { void showHelp(void) { printf( "-----------------------------------------------------------------------------\n" -"| faup1090 ModeS Forwarder Ver : " FAUP1090_VERSION " |\n" -" \n" -"| dump1090 reference build Ver : " MODES_DUMP1090_VERSION " |\n" +"| FlightAware faup1090 Ver : "FAUP1090_VERSION " |\n" +"| dump1090 ModeS Receiver Ver : " MODES_DUMP1090_VERSION " |\n" "-----------------------------------------------------------------------------\n" "--interactive Interactive mode refreshing data on screen\n" "--interactive-rows Max number of rows in interactive mode (default: 15)\n" @@ -235,9 +237,7 @@ void showCopyright(void) { printf( "-----------------------------------------------------------------------------\n" -"| faup1090 ModeS Forwarder Ver : " FAUP1090_VERSION " |\n" -" \n" -"| dump1090 reference build Ver : " MODES_DUMP1090_VERSION " |\n" +"| dump1090 ModeS Receiver Ver : " MODES_DUMP1090_VERSION " |\n" "-----------------------------------------------------------------------------\n" "\n" " Copyright (C) 2012 by Salvatore Sanfilippo \n" diff --git a/faup1090.h b/faup1090.h index 9e485bf..cb352ac 100644 --- a/faup1090.h +++ b/faup1090.h @@ -1,16 +1,17 @@ -#define FAUP1090_VERSION 1.4 #include "dump1090.h" +#define FAUP1090_VERSION "1.6" + #undef MODES_NET_INPUT_RAW_PORT -#define MODES_NET_INPUT_RAW_PORT 20001 +#define MODES_NET_INPUT_RAW_PORT 0 #undef MODES_NET_INPUT_BEAST_PORT -#define MODES_NET_INPUT_BEAST_PORT 20004 +#define MODES_NET_INPUT_BEAST_PORT 0 #undef MODES_NET_OUTPUT_FA_TSV_PORT -#define MODES_NET_OUTPUT_FA_TSV_PORT 10002 +#define MODES_NET_OUTPUT_FA_TSV_PORT 10001 struct { char net_input_beast_ipaddr[32]; diff --git a/makefaup1090 b/makefaup1090 index 1a3c868..0c4784c 100644 --- a/makefaup1090 +++ b/makefaup1090 @@ -20,8 +20,14 @@ all: faup1090 %.o: %.c $(CC) $(CFLAGS) $(EXTRACFLAGS) -c $< +faup1090.o: faup1090.c faup1090.h + +faup1090: faup1090.o + faup1090: faup1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o $(CC) -g -o faup1090 faup1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o coaa1090.obj $(LIBS) $(LDFLAGS) +install: faup1090 + install faup1090 /usr/bin/faup1090 clean: rm -f *.o faup1090