aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/modbuslog.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/modbuslog.c b/src/modbuslog.c
index d967e4a..cb509ea 100644
--- a/src/modbuslog.c
+++ b/src/modbuslog.c
@@ -268,10 +268,12 @@ int main(int argc, char *argv[]) {
if (rc == -1) {
syslog(LOG_ERR, "libmodbus error: [%s]",
modbus_strerror(errno));
- sleep(1);
+ // back off for 2 secs, increasing by 2 for each
+ // incorrect reply
+ sleep(2+retry*2);
}
retry++;
- } while ((rc == -1) && (retry < (modbus_retry + 1)));
+ } while ((rc == -1) && (retry <= modbus_retry));
if (rc == -1){
// retried, but still no luck