孙世龙 sunshilong
unread,May 16, 2021, 9:35:01 PM5/16/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to libm...@googlegroups.com, stephane....@gmail.com
Hi, list
Here are the related code snippets:
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