Selaa lähdekoodia

Don't flush on illegal address errors in single write functions

This change has introduced by 83c34102.
Fix unit tests on some systems.
Stéphane Raimbault 10 vuotta sitten
vanhempi
commit
0c131f8330
1 muutettua tiedostoa jossa 1 lisäystä ja 4 poistoa
  1. 1 4
      src/modbus.c

+ 1 - 4
src/modbus.c

@@ -708,6 +708,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
     sft.function = function;
     sft.t_id = ctx->backend->prepare_response_tid(req, &req_length);
 
+    /* Data are flushed on illegal number of values errors. */
     switch (function) {
     case MODBUS_FC_READ_COILS: {
         int nb = (req[offset + 3] << 8) + req[offset + 4];
@@ -850,8 +851,6 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
                         "Illegal data address 0x%0X in write_bit\n",
                         address);
             }
-            _sleep_response_timeout(ctx);
-            modbus_flush(ctx);
             rsp_length = response_exception(
                 ctx, &sft,
                 MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp);
@@ -880,8 +879,6 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
                 fprintf(stderr, "Illegal data address 0x%0X in write_register\n",
                         address);
             }
-            _sleep_response_timeout(ctx);
-            modbus_flush(ctx);
             rsp_length = response_exception(
                 ctx, &sft,
                 MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp);