X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmodbus.c;h=51447b162e0e2240386a8b01c7d94702d3e83af6;hb=db35efb33e81d0a013e09a8a6ffa362ad5962f7c;hp=d2b0a535ff9a0dd135f05fe2b217145ccc9c0315;hpb=4d6ff066b1c60a8e6654e4c74370ef951f37b5f3;p=collectd.git diff --git a/src/modbus.c b/src/modbus.c index d2b0a535..51447b16 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -80,7 +80,7 @@ enum mb_register_type_e /* {{{ */ REG_TYPE_UINT32, REG_TYPE_FLOAT }; /* }}} */ -enum mb_mreg_type_e /* {{{ */ +enum mb_mreg_type_e /* {{{ */ { MREG_HOLDING, MREG_INPUT @@ -310,7 +310,9 @@ static int mb_init_connection (mb_host_t *host) /* {{{ */ if (host == NULL) return (EINVAL); +#if COLLECT_DEBUG modbus_set_debug (&host->connection, 1); +#endif /* We'll do the error handling ourselves. */ modbus_set_error_handling (&host->connection, NOP_ON_ERROR); @@ -390,7 +392,9 @@ static int mb_init_connection (mb_host_t *host) /* {{{ */ } } +#if COLLECT_DEBUG modbus_set_debug (host->connection, 1); +#endif /* We'll do the error handling ourselves. */ modbus_set_error_recovery (host->connection, 0); @@ -499,7 +503,7 @@ static int mb_read_data (mb_host_t *host, mb_slave_t *slave, /* {{{ */ modbus_free (host->connection); #endif } - + #if LEGACY_LIBMODBUS /* Version 2.0.3: Pass the connection struct as a pointer and pass the slave * id to each call of "read_holding_registers". */ @@ -934,10 +938,9 @@ static int mb_config_add_host (oconfig_item_t *ci) /* {{{ */ int status; int i; - host = malloc (sizeof (*host)); + host = calloc (1, sizeof (*host)); if (host == NULL) return (ENOMEM); - memset (host, 0, sizeof (*host)); host->slaves = NULL; status = cf_util_get_string_buffer (ci, host->host, sizeof (host->host));