Require that the JSON refresh interval is at least 1, as it is used

to control the webmap refresh rate even if JSON files are not being written.
This commit is contained in:
Oliver Jowett 2015-01-14 01:15:54 +00:00
parent dc92cfb927
commit 62ec7796d0
4 changed files with 19 additions and 10 deletions

2
debian/changelog vendored
View file

@ -13,6 +13,8 @@ dump1090-mutability (1.10.3010.14mu-11) UNRELEASED; urgency=medium
discard bad position results.
* Display message rate (30 sec average) on the webmap.
* Restart lighttpd on package upgrade if we changed its config files.
* Require that the JSON refresh interval is at least 1, as it is used
to control the webmap refresh rate even if JSON files are not being written.
-- Oliver Jowett <oliver@mutability.co.uk> Sun, 11 Jan 2015 11:53:48 +0000

View file

@ -108,6 +108,10 @@ is_unsigned_int_or_empty() {
else return 1; fi
}
is_positive_int() {
if echo "$1" | grep -Eq '^(+?[1-9][0-9]*)$'; then return 0; else return 1; fi
}
is_signed_int() {
if echo "$1" | grep -Eq '^(0|[+-]?[1-9][0-9]*)$'; then return 0; else return 1; fi
}
@ -201,13 +205,10 @@ db_go || true; db_get $NAME/auto-start; if [ "$RET" = "true" ]; then
db_input_verify medium $NAME/net-bind-address is_ipaddrish_or_empty || true
db_input_verify low $NAME/stats-interval is_unsigned_int || true
db_input_verify low $NAME/json-interval is_unsigned_int || true
db_go || true; db_get $NAME/json-interval; if [ -n "$RET" ] && [ "$RET" -gt 0 ]; then
# only if json-interval was given and non-zero
db_input low $NAME/json-dir || true
db_input low $NAME/json-location-accuracy || true
fi
db_input_verify low $NAME/json-interval is_positive_int || true
db_input low $NAME/json-location-accuracy || true
db_input low $NAME/json-dir || true
db_input low $NAME/log-decoded-messages || true
db_input low $NAME/extra-args || true

View file

@ -235,6 +235,8 @@ Description: Directory to write JSON aircraft state to:
As this can be written frequently, you should select a location
that is not on a sdcard. The default path under /run is on tmpfs
and will not write to the sdcard.
.
A blank path disables writing JSON state.
Type: string
Default: /run/dump1090-mutability
@ -246,8 +248,6 @@ Description: Interval between writing JSON aircraft state, in seconds:
.
Here you can control how often the JSON state is updated, which determines
how frequently the virtual radar view updates.
.
A value of 0 will disable writing JSON state entirely.
Type: string
Default: 1
@ -293,6 +293,10 @@ Template: dump1090-mutability/invalid-is_unsigned_int_or_empty
Description: Value must be an unsigned integer, or blank.
Type: error
Template: dump1090-mutability/invalid-is_positive_int
Description: Value must be a positive integer.
Type: error
Template: dump1090-mutability/invalid-is_signed_int
Description: Value must be an integer.
Type: error

View file

@ -667,7 +667,7 @@ void backgroundTasks(void) {
}
}
if (Modes.json_aircraft_path && Modes.json_interval > 0) {
if (Modes.json_aircraft_path) {
time_t now = time(NULL);
if (now >= next_json) {
writeJsonToFile(Modes.json_aircraft_path, generateAircraftJson);
@ -879,6 +879,8 @@ int main(int argc, char **argv) {
strcat(Modes.json_metadata_path, "/receiver.json");
} else if (!strcmp(argv[j], "--write-json-every") && more) {
Modes.json_interval = atoi(argv[++j]);
if (Modes.json_interval < 1)
Modes.json_interval = 1;
} else if (!strcmp(argv[j], "--json-location-accuracy") && more) {
Modes.json_location_accuracy = atoi(argv[++j]);
#endif
@ -932,7 +934,7 @@ int main(int argc, char **argv) {
}
if (Modes.net) modesInitNet();
if (Modes.json_metadata_path && Modes.json_interval > 0) {
if (Modes.json_metadata_path) {
writeJsonToFile(Modes.json_metadata_path, generateReceiverJson); // once only on startup
}