From 089eb4f23a447427172601125bc65116b5f0a661 Mon Sep 17 00:00:00 2001 From: Nicolas JOURDEN Date: Thu, 3 Dec 2015 15:59:22 +0100 Subject: [PATCH] Removed the reading pause, added more details in the documentation. --- src/collectd.conf.in | 3 +-- src/collectd.conf.pod | 22 ++++++++++++---------- src/gps.c | 16 ++-------------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/collectd.conf.in b/src/collectd.conf.in index ebfc3ed5..21cb1111 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -560,8 +560,7 @@ # Host "127.0.0.1" # Port "2947" # Timeout 0.015 -# PauseRead 10 -# PauseConnect 1 +# PauseConnect 5 # # diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index ef8256bb..5193701d 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -2503,9 +2503,9 @@ instance "visible"). 0 means no GPS satellites are visible. =item B -Vertical and horizontal dilution. +Vertical and horizontal dilution (type instance "horizontal" or "vertical"). It should be between 0 and 3. -Look at the documentaiton of your GPS to know more. +Look at the documentation of your GPS to know more. =back @@ -2518,10 +2518,8 @@ Synopsis: Port "2947" # 15 ms timeout Timeout 0.015 - # PauseRead of 5 sec. between readings: - PauseRead 5 - # PauseConnect of 1 sec. between connection tentatives: - PauseConnect 1 + # PauseConnect of 5 sec. between connection attempts. + PauseConnect 5 Available configuration options: @@ -2530,7 +2528,7 @@ Available configuration options: =item B I -The host on which gpsd runs. Defaults to B. +The host on which gpsd daemon runs. Defaults to B. =item B I @@ -2540,13 +2538,17 @@ Port to connect to gpsd on the host machine. Defaults to B<2947>. Timeout in seconds (default 0.015 sec). -=item B I +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. -Pause to apply between readings in seconds (default 1 sec). +This only applies from gpsd release-2.95. =item B I -Pause to apply between tentative of connection in seconds (default 1 sec). +Pause to apply between attempts of connection to gpsd in seconds (default 5 sec). =back diff --git a/src/gps.c b/src/gps.c index d0cec6c4..82d49189 100644 --- a/src/gps.c +++ b/src/gps.c @@ -35,9 +35,8 @@ #define CGPS_TRUE 1 #define CGPS_FALSE 0 #define CGPS_DEFAULT_HOST "localhost" -#define CGPS_DEFAULT_PORT "2947" +#define CGPS_DEFAULT_PORT "2947" /* DEFAULT_GPSD_PORT */ #define CGPS_DEFAULT_TIMEOUT TIME_T_TO_CDTIME_T (0.015) -#define CGPS_DEFAULT_PAUSE_READ TIME_T_TO_CDTIME_T (1) #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" @@ -49,7 +48,6 @@ typedef struct { char *host; char *port; cdtime_t timeout; - cdtime_t pause_read; cdtime_t pause_connect; } cgps_config_t; @@ -157,11 +155,6 @@ static void * cgps_thread (void * pData) if (!gps_waiting (&gpsd_conn)) #endif { - if (cgps_thread_pause(cgps_config_data.pause_read) == CGPS_FALSE) - { - goto stop; - } - continue; } @@ -279,8 +272,6 @@ static int cgps_config (oconfig_item_t *ci) cf_util_get_service (child, &cgps_config_data.port); else if (strcasecmp ("Timeout", child->key) == 0) cf_util_get_cdtime (child, &cgps_config_data.timeout); - else if (strcasecmp ("Pauseread", child->key) == 0) - cf_util_get_cdtime (child, &cgps_config_data.pause_read); else if (strcasecmp ("PauseConnect", child->key) == 0) cf_util_get_cdtime (child, &cgps_config_data.pause_connect); else @@ -303,11 +294,9 @@ static int cgps_init (void) return 0; } - DEBUG ("gps plugin: config{host: \"%s\", port: \"%s\", timeout: %.6f sec., \ -pause read: %.3f sec, pause connect: %.3f sec.}", + DEBUG ("gps plugin: config{host: \"%s\", port: \"%s\", timeout: %.6f sec., pause connect: %.3f sec.}", cgps_config_data.host, cgps_config_data.port, CDTIME_T_TO_DOUBLE (cgps_config_data.timeout), - CDTIME_T_TO_DOUBLE (cgps_config_data.pause_read), CDTIME_T_TO_DOUBLE (cgps_config_data.pause_connect)); status = plugin_thread_create (&cgps_thread_id, NULL, cgps_thread, NULL); @@ -354,7 +343,6 @@ void module_register (void) cgps_config_data.host = sstrdup (CGPS_DEFAULT_HOST); cgps_config_data.port = sstrdup (CGPS_DEFAULT_PORT); cgps_config_data.timeout = CGPS_DEFAULT_TIMEOUT; - cgps_config_data.pause_read = CGPS_DEFAULT_PAUSE_READ; cgps_config_data.pause_connect = CGPS_DEFAULT_PAUSE_CONNECT; plugin_register_complex_config ("gps", cgps_config); -- 2.11.0