X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fgps.c;h=19f317cb03690a8ef3f8104d5609f67e7b1455eb;hb=e5e5d99350fa54e22f07b90fbc3102df51565ad9;hp=82d491892834ac522f2ca19539984e41583111ab;hpb=089eb4f23a447427172601125bc65116b5f0a661;p=collectd.git diff --git a/src/gps.c b/src/gps.c index 82d49189..19f317cb 100644 --- a/src/gps.c +++ b/src/gps.c @@ -36,7 +36,7 @@ #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" @@ -239,7 +239,7 @@ static void cgps_submit (const char *type, gauge_t value, const char *type_insta /** * Read the data and submit by piece. */ -static int cgps_read () +static int cgps_read (void) { cgps_data_t data_copy; @@ -278,6 +278,22 @@ static int cgps_config (oconfig_item_t *ci) 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); }