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

5 views
Skip to first unread message

孙世龙

unread,
May 7, 2021, 10:56:23 PM5/7/21
to libmodbus
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

孙世龙 sunshilong

unread,
May 9, 2021, 5:49:14 AM5/9/21
to libm...@googlegroups.com, stephane....@gmail.com
Reply all
Reply to author
Forward
0 new messages