#include <netdb.h>
-#include <modbus/modbus.h>
+#include <modbus.h>
#ifndef LIBMODBUS_VERSION_CHECK
/* Assume version 2.0.3 */
/*
* <Data "data_name">
* RegisterBase 1234
+ * RegisterCmd ReadHolding
* RegisterType float
* Type gauge
- * ModbusRegisterType holding
* Instance "..."
* </Data>
*
uint16_t values[2];
int values_num;
const data_set_t *ds;
- int status;
+ int status = 0;
if ((host == NULL) || (slave == NULL) || (data == NULL))
return (EINVAL);
else
values_num = 1;
- status = 0;
if (host->connection == NULL)
{
status = EBADF;
for (i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
- status = 0;
if (strcasecmp ("Type", child->key) == 0)
status = cf_util_get_string_buffer (child,
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
{
for (i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
- status = 0;
if (strcasecmp ("Instance", child->key) == 0)
status = cf_util_get_string_buffer (child,
status = cf_util_get_string_buffer (ci, host->host, sizeof (host->host));
if (status != 0)
+ {
+ sfree (host);
return (status);
+ }
if (host->host[0] == 0)
+ {
+ sfree (host);
return (EINVAL);
+ }
for (i = 0; i < ci->children_num; i++)
{