<Data "voltage-input-1">
RegisterBase 0
RegisterType float
+ ModbusRegisterType holding
Type voltage
Instance "input-1"
</Data>
<Data "voltage-input-2">
RegisterBase 2
RegisterType float
+ ModbusRegisterType holding
Type voltage
Instance "input-2"
</Data>
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>
+
+Specifies register type to be collected from device. Works only with libmodbus
+2.9.2 or higher. Defaults to B<holding>.
+
=item B<Type> I<Type>
Specifies the "type" (data set) to use when dispatching the value to
The matched number is a counter. Simply I<sets> the internal counter to this
value. Variants exist for C<COUNTER>, C<DERIVE>, and C<ABSOLUTE> data sources.
+=item B<GaugeAdd>
+
=item B<CounterAdd>
=item B<DeriveAdd>
matched number may be negative, which will effectively subtract from the
internal counter.
+=item B<GaugeInc>
+
=item B<CounterInc>
=item B<DeriveInc>
* RegisterBase 1234
* RegisterType float
* Type gauge
+ * ModbusRegisterType holding
* Instance "..."
* </Data>
*
REG_TYPE_UINT32,
REG_TYPE_FLOAT
}; /* }}} */
+enum mb_mreg_type_e /* {{{ */
+{
+ MREG_HOLDING,
+ MREG_INPUT
+}; /* }}} */
typedef enum mb_register_type_e mb_register_type_t;
+typedef enum mb_mreg_type_e mb_mreg_type_t;
struct mb_data_s;
typedef struct mb_data_s mb_data_t;
char *name;
int register_base;
mb_register_type_t register_type;
+ mb_mreg_type_t modbus_register_type;
char type[DATA_MAX_NAME_LEN];
char instance[DATA_MAX_NAME_LEN];
return (-1);
}
#endif
-
- status = modbus_read_registers (host->connection,
+ if (data->modbus_register_type == MREG_INPUT){
+ status = modbus_read_input_registers (host->connection,
+ /* start_addr = */ data->register_base,
+ /* num_registers = */ values_num, /* buffer = */ values);
+ }
+ else{
+ status = modbus_read_registers (host->connection,
/* start_addr = */ data->register_base,
/* num_registers = */ values_num, /* buffer = */ values);
+ }
if (status != values_num)
{
- ERROR ("Modbus plugin: modbus_read_registers (%s/%s) failed. status = %i, values_num = %i "
- "Giving up.", host->host, host->node, status, values_num);
+ ERROR ("Modbus plugin: modbus read function (%s/%s) failed. "
+ " status = %i, values_num = %i. Giving up.",
+ host->host, host->node, status, values_num);
#if LEGACY_LIBMODBUS
modbus_close (&host->connection);
#else
status = -1;
}
}
+ else if (strcasecmp ("ModbusRegisterType", child->key) == 0)
+ {
+#if LEGACY_LIBMODBUS
+ ERROR("Modbus plugin: ModbusRegisterType 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)
+ data.modbus_register_type = MREG_HOLDING;
+ else if (strcasecmp ("input", tmp) == 0)
+ data.modbus_register_type = MREG_INPUT;
+ else
+ {
+ ERROR ("Modbus plugin: The modbus_register_type \"%s\" is unknown.",
+ tmp);
+ status = -1;
+ }
+#endif
+ }
else
{
ERROR ("Modbus plugin: Unknown configuration option: %s", child->key);
int32_t partition_cnt, void *p, void *m)
{
u_int32_t key = *((u_int32_t *)keydata );
+ u_int32_t target = key % partition_cnt;
+ int32_t i = partition_cnt;
- return key % partition_cnt;
+ while (--i > 0 && !rd_kafka_topic_partition_available(rkt, target)) {
+ target = (target + 1) % partition_cnt;
+ }
+ return target;
}
static int kafka_write(const data_set_t *ds, /* {{{ */