Browse Source

Fix RTU test by allowing the server to reply on CRC errors

Stéphane Raimbault 10 years ago
parent
commit
1da0c2d683
1 changed files with 5 additions and 5 deletions
  1. 5 5
      tests/unit-test-server.c

+ 5 - 5
tests/unit-test-server.c

@@ -105,7 +105,7 @@ int main(int argc, char*argv[])
     }
 
     if (mb_mapping->nb_input_registers != UT_INPUT_REGISTERS_ADDRESS + UT_INPUT_REGISTERS_NB) {
-        printf("Invalid bb input registers: %d\n", UT_INPUT_REGISTERS_ADDRESS + UT_INPUT_REGISTERS_NB);
+        printf("Invalid nb input registers: %d\n", UT_INPUT_REGISTERS_ADDRESS + UT_INPUT_REGISTERS_NB);
         modbus_free(ctx);
         return -1;
     }
@@ -145,10 +145,10 @@ int main(int argc, char*argv[])
             /* Filtered queries return 0 */
         } while (rc == 0);
 
-        if (rc == -1) {
-            /* Connection closed by the client or error */
-            /* We could answer with an exception on EMBBADDATA to indicate
-               illegal data for example */
+        /* The connection is not closed on errors which require on reply such as
+           bad CRC in RTU. */
+        if (rc == -1 && errno != EMBBADCRC) {
+            /* Quit */
             break;
         }