summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 089eb4f)
raw | patch | inline | side by side (parent: 089eb4f)
author | Nicolas JOURDEN <nicolas.jourden@laposte.net> | |
Thu, 3 Dec 2015 15:33:24 +0000 (16:33 +0100) | ||
committer | Nicolas JOURDEN <nicolas.jourden@laposte.net> | |
Thu, 3 Dec 2015 15:33:24 +0000 (16:33 +0100) |
src/collectd.conf.pod | patch | blob | history | |
src/gps.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 5193701dd88ab9e9a2c0208a167ccabb083b4449..bbee6b130e61f3010ef9ff9dd0d9b86c1d850536 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
The GPS data stream is fetch by the plugin form the daemon.
It waits for data to be available, if none arrives it times out
and loop for another reading.
-Mind to put a low value gpsd expects value in the micro-seconds area (500 us) since
-the waiting function is blocking.
+Mind to put a low value gpsd expects value in the micro-seconds area
+(recommended is 500 us) since the waiting function is blocking.
+Value must be between 500 us and 5 sec., if outside that range the
+default value is applied.
This only applies from gpsd release-2.95.
diff --git a/src/gps.c b/src/gps.c
index 82d491892834ac522f2ca19539984e41583111ab..e43af4a4e55b2256af5846f81c3f0a8d9f157ef4 100644 (file)
--- a/src/gps.c
+++ b/src/gps.c
#define CGPS_FALSE 0
#define CGPS_DEFAULT_HOST "localhost"
#define CGPS_DEFAULT_PORT "2947" /* DEFAULT_GPSD_PORT */
-#define CGPS_DEFAULT_TIMEOUT TIME_T_TO_CDTIME_T (0.015)
+#define CGPS_DEFAULT_TIMEOUT MS_TO_CDTIME_T (15)
#define CGPS_DEFAULT_PAUSE_CONNECT TIME_T_TO_CDTIME_T (5)
#define CGPS_MAX_ERROR 100
#define CGPS_CONFIG "?WATCH={\"enable\":true,\"json\":true,\"nmea\":false}\r\n"
WARNING ("gps plugin: Ignoring unknown config option \"%s\".", child->key);
}
+ // Controlling the value for timeout:
+ // If set too high it blocks the reading (> 5 s), too low it gets not reading (< 500 us).
+ // To avoid any issues we replace "out of range" value by the default value.
+ if (
+ cgps_config_data.timeout > TIME_T_TO_CDTIME_T(5)
+ ||
+ cgps_config_data.timeout < US_TO_CDTIME_T(500)
+ )
+ {
+ WARNING ("gps plugin: timeout set to %.6f sec. setting to default (%.6f).",
+ CDTIME_T_TO_DOUBLE(cgps_config_data.timeout),
+ CDTIME_T_TO_DOUBLE(CGPS_DEFAULT_TIMEOUT)
+ );
+ cgps_config_data.timeout = CGPS_DEFAULT_TIMEOUT;
+ }
+
return (0);
}