From 392054a27b80af01bc6150856f0d890ca83d1883 Mon Sep 17 00:00:00 2001 From: maxried Date: Mon, 14 Sep 2015 19:58:59 +0200 Subject: [PATCH 1/9] Add --html-dir option --- dump1090.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dump1090.c b/dump1090.c index 72b3e08..0f72add 100644 --- a/dump1090.c +++ b/dump1090.c @@ -154,6 +154,7 @@ void modesInitConfig(void) { Modes.net_fatsv_port = MODES_NET_OUTPUT_FA_TSV_PORT; Modes.interactive_rows = getTermRows(); Modes.interactive_display_ttl = MODES_INTERACTIVE_DISPLAY_TTL; + Modes.html_dir = "./public_html"; Modes.json_interval = 1000; Modes.json_location_accuracy = 1; Modes.maxRange = 1852 * 300; // 300NM default max range @@ -713,6 +714,7 @@ void showHelp(void) { "--quiet Disable output to stdout. Use for daemon applications\n" "--show-only Show only messages from the given ICAO on stdout\n" "--ppm Set receiver error in parts per million (default 0)\n" +"--html-dir Use as base directory for the internal HTTP server. Defaults to ./public_html\n" "--write-json Periodically write json output to (for serving by a separate webserver)\n" "--write-json-every Write json output every t seconds (default 1)\n" "--json-location-accuracy Accuracy of receiver location in json metadata: 0=no location, 1=approximate, 2=exact\n" @@ -1060,6 +1062,8 @@ int main(int argc, char **argv) { Modes.interactive_rtl1090 = 1; } else if (!strcmp(argv[j],"--oversample")) { Modes.oversample = 1; + } else if (!strcmp(argv[j], "--html-dir") && more) { + Modes.html_dir = strdup(argv[++j]); #ifndef _WIN32 } else if (!strcmp(argv[j], "--write-json") && more) { Modes.json_dir = strdup(argv[++j]); From 37677f155739639e414c1113e22db524cd93715b Mon Sep 17 00:00:00 2001 From: maxried Date: Mon, 14 Sep 2015 19:59:27 +0200 Subject: [PATCH 2/9] --html-dir --- dump1090.h | 1 + 1 file changed, 1 insertion(+) diff --git a/dump1090.h b/dump1090.h index c175bea..23ece25 100644 --- a/dump1090.h +++ b/dump1090.h @@ -325,6 +325,7 @@ struct { // Internal state int interactive_rtl1090; // flight table in interactive mode is formatted like RTL1090 char *json_dir; // Path to json base directory, or NULL not to write json. uint64_t json_interval; // Interval between rewriting the json aircraft file, in milliseconds; also the advertised map refresh interval + char *html_dir; // Path to www base directory. int json_location_accuracy; // Accuracy of location metadata: 0=none, 1=approx, 2=exact int throttle; // When reading from a file, throttle file playback to realtime? From 267e5d690909860efe8c5e7b4c2bfdde1ae95f8f Mon Sep 17 00:00:00 2001 From: maxried Date: Mon, 14 Sep 2015 19:59:50 +0200 Subject: [PATCH 3/9] Update net_io.c --- net_io.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/net_io.c b/net_io.c index 26601f4..d39d8e8 100644 --- a/net_io.c +++ b/net_io.c @@ -514,7 +514,7 @@ static void modesSendSBSOutput(struct modesMessage *mm) { p += sprintf(p, "MSG,%d,111,11111,%06X,111111,", msgType, mm->addr); // Find current system time - clock_gettime(CLOCK_REALTIME, &now); +// clock_gettime(CLOCK_REALTIME, &now); localtime_r(&now.tv_sec, &stTime_now); // Find message reception time @@ -691,7 +691,7 @@ static int decodeBinMessage(struct client *c, char *p) { } // record reception time as the time we read it. - clock_gettime(CLOCK_REALTIME, &mm.sysTimestampMsg); +// clock_gettime(CLOCK_REALTIME, &mm.sysTimestampMsg); ch = *p++; // Grab the signal level mm.signalLevel = ((unsigned char)ch / 256.0); @@ -817,7 +817,7 @@ static int decodeHexMessage(struct client *c, char *hex) { } // record reception time as the time we read it. - clock_gettime(CLOCK_REALTIME, &mm.sysTimestampMsg); +// clock_gettime(CLOCK_REALTIME, &mm.sysTimestampMsg); if (l == (MODEAC_MSG_BYTES * 2)) { // ModeA or ModeC Modes.stats_current.remote_received_modeac++; @@ -1315,15 +1315,15 @@ static int handleHTTPRequest(struct client *c, char *p) { char getFile[1024]; if (strlen(url) < 2) { - snprintf(getFile, sizeof getFile, "%s/gmap.html", HTMLPATH); // Default file + snprintf(getFile, sizeof getFile, "%s/gmap.html", Modes.html_dir); // Default file } else { - snprintf(getFile, sizeof getFile, "%s/%s", HTMLPATH, url); + snprintf(getFile, sizeof getFile, "%s/%s", Modes.html_dir, url); } if (!realpath(getFile, rp)) rp[0] = 0; - if (!realpath(HTMLPATH, hrp)) - strcpy(hrp, HTMLPATH); + if (!realpath(Modes.html_dir, hrp)) + strcpy(hrp, Modes.html_dir); clen = -1; content = strdup("Server error occured"); @@ -1342,7 +1342,7 @@ static int handleHTTPRequest(struct client *c, char *p) { if (clen < 0) { content = realloc(content, 128); - clen = snprintf(content, 128,"Error opening HTML file: %s", strerror(errno)); + clen = snprintf(content, 128, "Error opening HTML file: %s", strerror(errno)); statuscode = 404; statusmsg = "Not Found"; } From 90adaf22f70863cf49a513e36fa800dd493bfd8b Mon Sep 17 00:00:00 2001 From: maxried Date: Mon, 14 Sep 2015 20:03:19 +0200 Subject: [PATCH 4/9] Update net_io.c --- net_io.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net_io.c b/net_io.c index d39d8e8..3c9374d 100644 --- a/net_io.c +++ b/net_io.c @@ -514,7 +514,7 @@ static void modesSendSBSOutput(struct modesMessage *mm) { p += sprintf(p, "MSG,%d,111,11111,%06X,111111,", msgType, mm->addr); // Find current system time -// clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_REALTIME, &now); localtime_r(&now.tv_sec, &stTime_now); // Find message reception time @@ -691,7 +691,7 @@ static int decodeBinMessage(struct client *c, char *p) { } // record reception time as the time we read it. -// clock_gettime(CLOCK_REALTIME, &mm.sysTimestampMsg); + clock_gettime(CLOCK_REALTIME, &mm.sysTimestampMsg); ch = *p++; // Grab the signal level mm.signalLevel = ((unsigned char)ch / 256.0); @@ -817,7 +817,7 @@ static int decodeHexMessage(struct client *c, char *hex) { } // record reception time as the time we read it. -// clock_gettime(CLOCK_REALTIME, &mm.sysTimestampMsg); + clock_gettime(CLOCK_REALTIME, &mm.sysTimestampMsg); if (l == (MODEAC_MSG_BYTES * 2)) { // ModeA or ModeC Modes.stats_current.remote_received_modeac++; From 541f12fb214f8742cf11ae814ef61097b359254c Mon Sep 17 00:00:00 2001 From: maxried Date: Mon, 14 Sep 2015 20:11:00 +0200 Subject: [PATCH 5/9] Update dump1090.h --- dump1090.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dump1090.h b/dump1090.h index 23ece25..58c0950 100644 --- a/dump1090.h +++ b/dump1090.h @@ -200,10 +200,6 @@ typedef struct rtlsdr_dev rtlsdr_dev_t; #define MODES_NET_SNDBUF_SIZE (1024*64) #define MODES_NET_SNDBUF_MAX (7) -#ifndef HTMLPATH -#define HTMLPATH "./public_html" // default path for gmap.html etc -#endif - #define HISTORY_SIZE 120 #define HISTORY_INTERVAL 30000 From 217e6f9216bbf6050b90e772cf981259806f218d Mon Sep 17 00:00:00 2001 From: maxried Date: Mon, 14 Sep 2015 20:44:52 +0200 Subject: [PATCH 6/9] Update dump1090.h --- dump1090.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dump1090.h b/dump1090.h index 58c0950..23ece25 100644 --- a/dump1090.h +++ b/dump1090.h @@ -200,6 +200,10 @@ typedef struct rtlsdr_dev rtlsdr_dev_t; #define MODES_NET_SNDBUF_SIZE (1024*64) #define MODES_NET_SNDBUF_MAX (7) +#ifndef HTMLPATH +#define HTMLPATH "./public_html" // default path for gmap.html etc +#endif + #define HISTORY_SIZE 120 #define HISTORY_INTERVAL 30000 From f66420b275078506e33ee158be1a1d9447f63b8b Mon Sep 17 00:00:00 2001 From: maxried Date: Mon, 14 Sep 2015 20:47:30 +0200 Subject: [PATCH 7/9] Update dump1090.c --- dump1090.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dump1090.c b/dump1090.c index 0f72add..f02b9c5 100644 --- a/dump1090.c +++ b/dump1090.c @@ -154,7 +154,7 @@ void modesInitConfig(void) { Modes.net_fatsv_port = MODES_NET_OUTPUT_FA_TSV_PORT; Modes.interactive_rows = getTermRows(); Modes.interactive_display_ttl = MODES_INTERACTIVE_DISPLAY_TTL; - Modes.html_dir = "./public_html"; + Modes.html_dir = HTMLPATH; Modes.json_interval = 1000; Modes.json_location_accuracy = 1; Modes.maxRange = 1852 * 300; // 300NM default max range From f8c6513294fa8894b78f71e474281c2ff5a1b8cc Mon Sep 17 00:00:00 2001 From: maxried Date: Mon, 14 Sep 2015 20:48:17 +0200 Subject: [PATCH 8/9] Update dump1090.c --- dump1090.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dump1090.c b/dump1090.c index f02b9c5..f52d0b4 100644 --- a/dump1090.c +++ b/dump1090.c @@ -154,7 +154,7 @@ void modesInitConfig(void) { Modes.net_fatsv_port = MODES_NET_OUTPUT_FA_TSV_PORT; Modes.interactive_rows = getTermRows(); Modes.interactive_display_ttl = MODES_INTERACTIVE_DISPLAY_TTL; - Modes.html_dir = HTMLPATH; + Modes.html_dir = HTMLPATH; Modes.json_interval = 1000; Modes.json_location_accuracy = 1; Modes.maxRange = 1852 * 300; // 300NM default max range From 3d4455948f18b710b8f21288296f096e013fe2a7 Mon Sep 17 00:00:00 2001 From: maxried Date: Mon, 14 Sep 2015 21:05:27 +0200 Subject: [PATCH 9/9] Update dump1090.c --- dump1090.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dump1090.c b/dump1090.c index f52d0b4..8df3059 100644 --- a/dump1090.c +++ b/dump1090.c @@ -714,7 +714,7 @@ void showHelp(void) { "--quiet Disable output to stdout. Use for daemon applications\n" "--show-only Show only messages from the given ICAO on stdout\n" "--ppm Set receiver error in parts per million (default 0)\n" -"--html-dir Use as base directory for the internal HTTP server. Defaults to ./public_html\n" +"--html-dir Use as base directory for the internal HTTP server. Defaults to " HTMLPATH "\n" "--write-json Periodically write json output to (for serving by a separate webserver)\n" "--write-json-every Write json output every t seconds (default 1)\n" "--json-location-accuracy Accuracy of receiver location in json metadata: 0=no location, 1=approximate, 2=exact\n"