[collectd] [PATCH] modbus: rename register types once more
Eric Sandeen
sandeen at sandeen.net
Wed Jan 28 05:36:05 CET 2015
As I was looking over my config files again, ModbusRegisterType
kind of stuck out like a sore thumb.
Modbus does talk about "read holding" and "read input" as "commands";
perhaps renaming it as this patch does is more intuitive, so that all
of the Modbus register configurations start with Register.
I'm not wedded to it, but if you like it & agree, here you go.
Thanks,
-Eric
---
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index dda4fcc..18b1c33 100644
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
@@ -627,8 +627,8 @@
#<Plugin modbus>
# <Data "data_name">
# RegisterBase 1234
+# RegisterCmd ReadHolding
# RegisterType float
-# ModbusRegisterType holding
# Type gauge
# Instance "..."
# </Data>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 12269ae..dd66486 100644
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
@@ -2890,7 +2890,7 @@ B<Synopsis:>
<Data "voltage-input-1">
RegisterBase 0
RegisterType float
- ModbusRegisterType holding
+ RegisterCmd ReadHolding
Type voltage
Instance "input-1"
</Data>
@@ -2898,7 +2898,7 @@ B<Synopsis:>
<Data "voltage-input-2">
RegisterBase 2
RegisterType float
- ModbusRegisterType holding
+ RegisterCmd ReadHolding
Type voltage
Instance "input-2"
</Data>
@@ -2906,7 +2906,7 @@ B<Synopsis:>
<Data "supply-temperature-1">
RegisterBase 0
RegisterType Int16
- ModbusRegisterType holding
+ RegisterCmd ReadHolding
Type temperature
Instance "temp-1"
</Data>
@@ -2957,10 +2957,10 @@ Specifies what kind of data is returned by the device. If the type is B<Int32>,
B<Uint32> or B<Float>, two 16E<nbsp>bit registers will be read and the data is
combined into one value. Defaults to B<Uint16>.
-=item B<ModbusRegisterType> B<holding>|B<input>
+=item B<RegisterCmd> B<ReadHolding>|B<ReadInput>
Specifies register type to be collected from device. Works only with libmodbus
-2.9.2 or higher. Defaults to B<holding>.
+2.9.2 or higher. Defaults to B<ReadHolding>.
=item B<Type> I<Type>
diff --git a/src/modbus.c b/src/modbus.c
index 5891938..e24f2ec 100644
--- a/src/modbus.c
+++ b/src/modbus.c
@@ -47,9 +47,9 @@
/*
* <Data "data_name">
* RegisterBase 1234
+ * RegisterCmd ReadHolding
* RegisterType float
* Type gauge
- * ModbusRegisterType holding
* Instance "..."
* </Data>
*
@@ -765,19 +765,19 @@ static int mb_config_add_data (oconfig_item_t *ci) /* {{{ */
status = -1;
}
}
- else if (strcasecmp ("ModbusRegisterType", child->key) == 0)
+ else if (strcasecmp ("RegisterCmd", child->key) == 0)
{
#if LEGACY_LIBMODBUS
- ERROR("Modbus plugin: ModbusRegisterType parameter can not be used "
+ ERROR("Modbus plugin: RegisterCmd parameter can not be used "
"with your libmodbus version");
#else
char tmp[16];
status = cf_util_get_string_buffer (child, tmp, sizeof (tmp));
if (status != 0)
/* do nothing */;
- else if (strcasecmp ("holding", tmp) == 0)
+ else if (strcasecmp ("ReadHolding", tmp) == 0)
data.modbus_register_type = MREG_HOLDING;
- else if (strcasecmp ("input", tmp) == 0)
+ else if (strcasecmp ("ReadInput", tmp) == 0)
data.modbus_register_type = MREG_INPUT;
else
{
More information about the collectd
mailing list