Commit 0c131f83302dd7ef41dee58a6a1d7a120f544a82

Authored by Stéphane Raimbault
1 parent 9c809805

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

This change has introduced by 83c34102.
Fix unit tests on some systems.
Showing 1 changed file with 1 additions and 4 deletions
src/modbus.c
... ... @@ -708,6 +708,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
708 708 sft.function = function;
709 709 sft.t_id = ctx->backend->prepare_response_tid(req, &req_length);
710 710  
  711 + /* Data are flushed on illegal number of values errors. */
711 712 switch (function) {
712 713 case MODBUS_FC_READ_COILS: {
713 714 int nb = (req[offset + 3] << 8) + req[offset + 4];
... ... @@ -850,8 +851,6 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
850 851 "Illegal data address 0x%0X in write_bit\n",
851 852 address);
852 853 }
853   - _sleep_response_timeout(ctx);
854   - modbus_flush(ctx);
855 854 rsp_length = response_exception(
856 855 ctx, &sft,
857 856 MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp);
... ... @@ -880,8 +879,6 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
880 879 fprintf(stderr, "Illegal data address 0x%0X in write_register\n",
881 880 address);
882 881 }
883   - _sleep_response_timeout(ctx);
884   - modbus_flush(ctx);
885 882 rsp_length = response_exception(
886 883 ctx, &sft,
887 884 MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp);
... ...