int modbus_reply(modbus_t *ctx, const uint8_t *req,
int req_length, modbus_mapping_t *mb_mapping)
{
case MODBUS_FC_READ_HOLDING_REGISTERS:
{
...
if (nb < 1 || MODBUS_MAX_READ_REGISTERS < nb) {
rsp_length = response_exception(
ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp, TRUE,
^^^^
"Illegal nb of values %d in %s (max %d)\n",
nb, name, MODBUS_MAX_READ_REGISTERS);
} else if (mapping_address < 0 || (mapping_address + nb) > nb_registers) {
rsp_length = response_exception(
ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp, FALSE,
^^^^^
"Illegal data address 0x%0X in %s\n",
mapping_address < 0 ? address : address + nb, name);
}
else {
...
}
Why the former one passes TRUE whereas the latter one passes FALSE?
Best Regards
Sunshilong