Skip to content

Commit

Permalink
Log error in read input registers if debug (closes #755)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane committed Jul 16, 2024
1 parent 1c1ccc3 commit a6202ad
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/modbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1354,10 +1354,12 @@ int modbus_read_input_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest)
}

if (nb > MODBUS_MAX_READ_REGISTERS) {
fprintf(stderr,
"ERROR Too many input registers requested (%d > %d)\n",
nb,
MODBUS_MAX_READ_REGISTERS);
if (ctx->debug) {
fprintf(stderr,
"ERROR Too many input registers requested (%d > %d)\n",
nb,
MODBUS_MAX_READ_REGISTERS);
}
errno = EMBMDATA;
return -1;
}
Expand Down

0 comments on commit a6202ad

Please sign in to comment.