Skip to content

Commit

Permalink
fix exception message
Browse files Browse the repository at this point in the history
  • Loading branch information
Su-Yuming authored Jan 2, 2025
1 parent bb13443 commit 580c18e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/modbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ int modbus_reply(modbus_t *ctx,
rsp,
FALSE,
"Illegal data address 0x%0X in %s\n",
mapping_address < 0 ? address : address + nb,
mapping_address < 0 ? address : address + nb - 1,
name);
} else {
rsp_length = ctx->backend->build_response_basis(&sft, rsp);
Expand Down Expand Up @@ -878,7 +878,7 @@ int modbus_reply(modbus_t *ctx,
rsp,
FALSE,
"Illegal data address 0x%0X in %s\n",
mapping_address < 0 ? address : address + nb,
mapping_address < 0 ? address : address + nb - 1,
name);
} else {
int i;
Expand Down Expand Up @@ -1002,7 +1002,7 @@ int modbus_reply(modbus_t *ctx,
rsp,
FALSE,
"Illegal data address 0x%0X in write_bits\n",
mapping_address < 0 ? address : address + nb);
mapping_address < 0 ? address : address + nb - 1);
} else {
/* 6 = byte count */
modbus_set_bits_from_bytes(
Expand Down Expand Up @@ -1038,7 +1038,7 @@ int modbus_reply(modbus_t *ctx,
rsp,
FALSE,
"Illegal data address 0x%0X in write_registers\n",
mapping_address < 0 ? address : address + nb);
mapping_address < 0 ? address : address + nb - 1);
} else {
int i, j;
for (i = mapping_address, j = 6; i < mapping_address + nb; i++, j += 2) {
Expand Down Expand Up @@ -1149,7 +1149,7 @@ int modbus_reply(modbus_t *ctx,
"Illegal data read address 0x%0X or write address 0x%0X "
"write_and_read_registers\n",
mapping_address < 0 ? address : address + nb,
mapping_address_write < 0 ? address_write : address_write + nb_write);
mapping_address_write < 0 ? address_write : address_write + nb_write - 1);
} else {
int i, j;
rsp_length = ctx->backend->build_response_basis(&sft, rsp);
Expand Down

0 comments on commit 580c18e

Please sign in to comment.