Commit 0c131f83302dd7ef41dee58a6a1d7a120f544a82
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,6 +708,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req, | ||
| 708 | sft.function = function; | 708 | sft.function = function; |
| 709 | sft.t_id = ctx->backend->prepare_response_tid(req, &req_length); | 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 | switch (function) { | 712 | switch (function) { |
| 712 | case MODBUS_FC_READ_COILS: { | 713 | case MODBUS_FC_READ_COILS: { |
| 713 | int nb = (req[offset + 3] << 8) + req[offset + 4]; | 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,8 +851,6 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req, | ||
| 850 | "Illegal data address 0x%0X in write_bit\n", | 851 | "Illegal data address 0x%0X in write_bit\n", |
| 851 | address); | 852 | address); |
| 852 | } | 853 | } |
| 853 | - _sleep_response_timeout(ctx); | ||
| 854 | - modbus_flush(ctx); | ||
| 855 | rsp_length = response_exception( | 854 | rsp_length = response_exception( |
| 856 | ctx, &sft, | 855 | ctx, &sft, |
| 857 | MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp); | 856 | MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp); |
| @@ -880,8 +879,6 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req, | @@ -880,8 +879,6 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req, | ||
| 880 | fprintf(stderr, "Illegal data address 0x%0X in write_register\n", | 879 | fprintf(stderr, "Illegal data address 0x%0X in write_register\n", |
| 881 | address); | 880 | address); |
| 882 | } | 881 | } |
| 883 | - _sleep_response_timeout(ctx); | ||
| 884 | - modbus_flush(ctx); | ||
| 885 | rsp_length = response_exception( | 882 | rsp_length = response_exception( |
| 886 | ctx, &sft, | 883 | ctx, &sft, |
| 887 | MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp); | 884 | MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp); |