aboutsummaryrefslogtreecommitdiffstats
path: root/modbuslog.c
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2011-12-05 01:48:03 +0000
committerJonathan McCrohan <jmccrohan@gmail.com>2011-12-05 01:48:03 +0000
commit18dd11d1c2201418198d142ae5b2822722e65458 (patch)
tree6438c83b3fa9367f7261b369e5796306e1131188 /modbuslog.c
parent38f7f2cf0fdda2971b244ce19162921c05c8c0b1 (diff)
downloadverteco-18dd11d1c2201418198d142ae5b2822722e65458.tar.gz
add custom modbus retry.
Diffstat (limited to '')
-rw-r--r--modbuslog.c6
-rw-r--r--modbuslog.cfg1
2 files changed, 5 insertions, 2 deletions
diff --git a/modbuslog.c b/modbuslog.c
index 248b8cc..be7a4d1 100644
--- a/modbuslog.c
+++ b/modbuslog.c
@@ -88,6 +88,7 @@ int main(int argc, char *argv[]) {
int modbus_data_bits;
const char *modbus_parity;
int modbus_stop_bits;
+ int modbus_retry;
config_init(&cfg);
@@ -103,7 +104,8 @@ int main(int argc, char *argv[]) {
&& config_lookup_int(&cfg, "modbus.baud", &modbus_baud_rate)
&& config_lookup_int(&cfg, "modbus.data_bits", &modbus_data_bits)
&& config_lookup_string(&cfg, "modbus.parity", &modbus_parity)
- && config_lookup_int(&cfg, "modbus.stop_bits", &modbus_stop_bits))) {
+ && config_lookup_int(&cfg, "modbus.stop_bits", &modbus_stop_bits)
+ && config_lookup_int(&cfg, "modbus.retry", &modbus_retry))) {
fprintf(stderr,
"Incomplete modbus configuration. Check configuration file.\n");
return -1;
@@ -219,7 +221,7 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "ERROR: %s\n", modbus_strerror(errno));
}
retry++;
- } while ((rc != -1) && (retry < 2));
+ } while ((rc != -1) && (retry < (modbus_retry+1)));
//MODBUS_GET_HIGH_BYTE(data);
//MODBUS_GET_LOW_BYTE(data);
diff --git a/modbuslog.cfg b/modbuslog.cfg
index 2451b3f..615cea4 100644
--- a/modbuslog.cfg
+++ b/modbuslog.cfg
@@ -8,6 +8,7 @@ modbus = {
data_bits = 8;
parity = "E"
stop_bits = 1;
+ retry = 2;
};
reading= (