Commit 1da0c2d683a4d21a7b1df3cb1b06ab9586c18c6f

Authored by Stéphane Raimbault
1 parent f3329dda

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

Showing 1 changed file with 5 additions and 5 deletions
tests/unit-test-server.c
@@ -105,7 +105,7 @@ int main(int argc, char*argv[]) @@ -105,7 +105,7 @@ int main(int argc, char*argv[])
105 } 105 }
106 106
107 if (mb_mapping->nb_input_registers != UT_INPUT_REGISTERS_ADDRESS + UT_INPUT_REGISTERS_NB) { 107 if (mb_mapping->nb_input_registers != UT_INPUT_REGISTERS_ADDRESS + UT_INPUT_REGISTERS_NB) {
108 - printf("Invalid bb input registers: %d\n", UT_INPUT_REGISTERS_ADDRESS + UT_INPUT_REGISTERS_NB); 108 + printf("Invalid nb input registers: %d\n", UT_INPUT_REGISTERS_ADDRESS + UT_INPUT_REGISTERS_NB);
109 modbus_free(ctx); 109 modbus_free(ctx);
110 return -1; 110 return -1;
111 } 111 }
@@ -145,10 +145,10 @@ int main(int argc, char*argv[]) @@ -145,10 +145,10 @@ int main(int argc, char*argv[])
145 /* Filtered queries return 0 */ 145 /* Filtered queries return 0 */
146 } while (rc == 0); 146 } while (rc == 0);
147 147
148 - if (rc == -1) {  
149 - /* Connection closed by the client or error */  
150 - /* We could answer with an exception on EMBBADDATA to indicate  
151 - illegal data for example */ 148 + /* The connection is not closed on errors which require on reply such as
  149 + bad CRC in RTU. */
  150 + if (rc == -1 && errno != EMBBADCRC) {
  151 + /* Quit */
152 break; 152 break;
153 } 153 }
154 154