Anybody can hear me? When should to pass a need flush flag to response_exception() and when shouldn't?

11 views
Skip to first unread message

孙世龙 sunshilong

unread,
May 16, 2021, 9:35:01 PM5/16/21
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
Reply all
Reply to author
Forward
0 new messages