diff options
Diffstat (limited to 'src')
-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]; |