- if (status > 0)
- break;
-
- if (host->is_connected)
- {
-#if LEGACY_LIBMODBUS
- modbus_close (&host->connection);
- host->is_connected = 0;
-#else
- modbus_close (host->connection);
- modbus_free (host->connection);
- host->connection = NULL;
-#endif
- }
-
- /* If we already tried reconnecting this round, give up. */
- if (host->have_reconnected)
- {
- ERROR ("Modbus plugin: modbus_read_registers (%s) failed. "
- "Reconnecting has already been tried. Giving up.", host->host);
- return (-1);
- }
-
- /* Maybe the device closed the connection during the waiting interval.
- * Try re-establishing the connection. */
- status = mb_init_connection (host);
- if (status != 0)
- {
- ERROR ("Modbus plugin: modbus_read_registers (%s) failed. "
- "While trying to reconnect, connecting to \"%s\" failed. "
- "Giving up.",
- host->host, host->node);
- return (-1);
- }
-
- DEBUG ("Modbus plugin: Re-established connection to %s", host->host);
-
- /* try again */
- continue;
- } /* for (i = 0, 1) */
+ if (status != values_num)
+ {
+ ERROR ("Modbus plugin: modbus_read_registers (%s) failed. "
+ "Giving up.", host->host);
+ return (-1);
+ }