The B<modbus plugin> connects to a Modbus "slave" via Modbus/TCP or Modbus/RTU and
reads register values. It supports reading single registers (unsigned 16E<nbsp>bit
--values), large integer values (unsigned 32E<nbsp>bit values) and floating point
--values (two registers interpreted as IEEE floats in big endian notation).
++values), large integer values (unsigned 32E<nbsp>bit and 64E<nbsp>bit values) and
++floating point values (two registers interpreted as IEEE floats in big endian
++notation).
B<Synopsis:>
RegisterCmd ReadHolding
Type voltage
Instance "input-1"
++ #Scale 1.0
++ #Shift 0.0
</Data>
<Data "voltage-input-2">
=item B<Instance> I<Instance>
--Sets the type instance to use when dispatching the value to I<collectd>. If
++Sets the type instance to use when dispatching the value to I<Instance>. If
unset, an empty string (no type instance) is used.
-The values taken from collectd are multiplied by I<Value>. The field is optional
+ =item B<Scale> I<Value>
+
-I<Value> is added to values from collectd after they have been multiplied by
++The values taken from device are multiplied by I<Value>. The field is optional
+ and the default is B<1.0>.
+
+ =item B<Shift> I<Value>
+
++I<Value> is added to values from device after they have been multiplied by
+ B<Scale> value. The field is optional and the default value is B<0.0>.
+
=back
=item E<lt>B<Host> I<Name>E<gt> blocks
"Returned uint32 value is %" PRIu32,
v32);
- CAST_TO_VALUE_T(ds, vt, v32);
+ CAST_TO_VALUE_T(ds, vt, v32, data->scale, data->shift);
mb_submit(host, slave, data, vt);
- CAST_TO_VALUE_T(ds, vt, v64);
+ } else if (data->register_type == REG_TYPE_UINT64) {
+ uint64_t v64;
+ value_t vt;
+
+ v64 = (((uint64_t)values[0]) << 48) | (((uint64_t)values[1]) << 32) |
+ (((uint64_t)values[2]) << 16) | (((uint64_t)values[3]));
+ DEBUG("Modbus plugin: mb_read_data: "
+ "Returned uint64 value is %" PRIu64,
+ v64);
+
- CAST_TO_VALUE_T(ds, vt, v.i64);
++ CAST_TO_VALUE_T(ds, vt, v64, data->scale, data->shift);
+ mb_submit(host, slave, data, vt);
+ } else if (data->register_type == REG_TYPE_INT64) {
+ union {
+ uint64_t u64;
+ int64_t i64;
+ } v;
+ value_t vt;
+
+ v.u64 = (((uint64_t)values[0]) << 48) | (((uint64_t)values[1]) << 32) |
+ (((uint64_t)values[2]) << 16) | ((uint64_t)values[3]);
+ DEBUG("Modbus plugin: mb_read_data: "
+ "Returned uint64 value is %" PRIi64,
+ v.i64);
+
++ CAST_TO_VALUE_T(ds, vt, v.i64, data->scale, data->shift);
+ mb_submit(host, slave, data, vt);
} else /* if (data->register_type == REG_TYPE_UINT16) */
{
value_t vt;