diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2012-03-26 00:16:59 +0100 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2012-03-26 00:16:59 +0100 |
commit | 67b3bfe5cf9b13820c934687d8930aa51c2dd902 (patch) | |
tree | df7afe4557683d5d631f57e777b1f6d4d6403d63 | |
parent | 9c16df0e5201b4e36cbfaab00d23534d0d9148f9 (diff) | |
download | verteco-67b3bfe5cf9b13820c934687d8930aa51c2dd902.tar.gz |
modbuslog: ensure no logs recorded if libmodbus errors
Diffstat (limited to '')
-rw-r--r-- | src/modbuslog.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/modbuslog.c b/src/modbuslog.c index 112f9c8..46a1516 100644 --- a/src/modbuslog.c +++ b/src/modbuslog.c @@ -268,7 +268,12 @@ int main(int argc, char *argv[]) { modbus_strerror(errno)); } retry++; - } while ((rc != -1) && (retry < (modbus_retry + 1))); + } while ((rc == -1) && (retry < (modbus_retry + 1))); + + if (rc == -1){ + // retried, but still no luck + continue; + } //MODBUS_GET_HIGH_BYTE(data); //MODBUS_GET_LOW_BYTE(data); @@ -325,15 +330,11 @@ int main(int argc, char *argv[]) { // bitshifting magic switch (numbytes) { case 1: - registervalue = byte[0]; + registervalue = (startbyte % 2 == 0) ? byte[0] : byte[1]; break; case 2: registervalue = ((byte[0]) << 8) + byte[1]; break; - case 3: - registervalue = ((byte[0]) << 16) + ((byte[1]) << 8) - + byte[2]; - break; case 4: registervalue = ((byte[0]) << 24) + ((byte[1]) << 16) + ((byte[2]) << 8) + byte[3]; |