projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Initial support of GPSd in collectd.
[collectd.git]
/
src
/
ted.c
diff --git
a/src/ted.c
b/src/ted.c
index
d2a73a5
..
5dd75bc
100644
(file)
--- a/
src/ted.c
+++ b/
src/ted.c
@@
-104,8
+104,7
@@
static int ted_read_value(double *ret_power, double *ret_voltage)
/* Loop until we find the end of the package */
end_flag = 0;
/* Loop until we find the end of the package */
end_flag = 0;
- escape_flag = 0;
- package_buffer_pos = -1;
+ package_buffer_pos = 0;
while (end_flag == 0)
{
ssize_t receive_buffer_length;
while (end_flag == 0)
{
ssize_t receive_buffer_length;
@@
-164,7
+163,7
@@
static int ted_read_value(double *ret_power, double *ret_voltage)
/* We need to see the begin sequence first. When we receive `ESCAPE
* PKT_BEGIN', we set `package_buffer_pos' to zero to signal that
* the beginning of the package has been found. */
/* We need to see the begin sequence first. When we receive `ESCAPE
* PKT_BEGIN', we set `package_buffer_pos' to zero to signal that
* the beginning of the package has been found. */
- package_buffer_pos = -1;
+
escape_flag = 0;
for (i = 0; i < receive_buffer_length; i++)
{
escape_flag = 0;
for (i = 0; i < receive_buffer_length; i++)
{
@@
-209,16
+208,15
@@
static int ted_read_value(double *ret_power, double *ret_voltage)
} /* while (end_flag == 0) */
/* Check for errors inside the loop. */
} /* while (end_flag == 0) */
/* Check for errors inside the loop. */
- if (
end_flag == 0
)
+ if (
(end_flag == 0) || (package_buffer_pos != EXPECTED_PACKAGE_LENGTH)
)
return (-1);
return (-1);
- /*
+ /*
* Power is at positions 247 and 248 (LSB first) in [10kW].
* Voltage is at positions 251 and 252 (LSB first) in [.1V].
*
* Power is at positions 247 and 248 (LSB first) in [10kW].
* Voltage is at positions 251 and 252 (LSB first) in [.1V].
*
- * According to Eric's patch the power is in 10kW steps, but according to a
- * Python module I've found, it's in 0.01kW == 10W. IMHO the Python scale
- * is more realistic. -octo
+ * Power is in 10 Watt steps
+ * Voltage is in volts
*/
*ret_power = 10.0 * (double) ((((int) package_buffer[248]) * 256)
+ ((int) package_buffer[247]));
*/
*ret_power = 10.0 * (double) ((((int) package_buffer[248]) * 256)
+ ((int) package_buffer[247]));
@@
-265,7
+263,7
@@
static int ted_open_device (void)
return (0);
} /* int ted_open_device */
return (0);
} /* int ted_open_device */
-static void ted_submit (char *type
_instance
, double value)
+static void ted_submit (char *type, double value)
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
@@
-276,8
+274,7
@@
static void ted_submit (char *type_instance, double value)
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "ted", sizeof (vl.plugin));
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "ted", sizeof (vl.plugin));
- sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- sstrncpy (vl.type, "ted", sizeof (vl.type));
+ sstrncpy (vl.type, type, sizeof (vl.type));
plugin_dispatch_values (&vl);
}
plugin_dispatch_values (&vl);
}