Modbus RTU Read multiple registers at once
Posted: Mon Jan 23, 2023 7:43 pm
Hi,
I'm looking for a way how to read multiple input registers at once to reduce bus load. As basis i use the Master example. As long i read only one register it works fine.
As soon i change the parameter descriptor to read 4 words the ESP reboots when the data is received.
The request is sent out OK and also the response of the slave is ok but the ESP reboots when data is received. I also defined the input data as an array so there shall be enough space to hold the received data. Also tried with different PARM_TYPE's
I have disabled all the received data handling i do only call:
Works fine
crashes as soon as the slave answers.
I'm looking for a way how to read multiple input registers at once to reduce bus load. As basis i use the Master example. As long i read only one register it works fine.
Code: Select all
{ CID_UL1N, STR("UL1N"), STR("V"), MB_DEVICE_ADDR1, MB_PARAM_INPUT, 0, 2, INPUT_OFFSET(input_data0), PARAM_TYPE_ASCII, 4, OPTS( 0, 0, 0 ), PAR_PERMS_READ_WRITE_TRIGGER }
Code: Select all
{ CID_UL1N, STR("UL1N"), STR("V"), MB_DEVICE_ADDR1, MB_PARAM_INPUT, 0, 4, INPUT_OFFSET(input_data), PARAM_TYPE_ASCII, 8, OPTS( 0, 0, 0 ), PAR_PERMS_READ_WRITE_TRIGGER }
Code: Select all
typedef struct
{
uint16_t input_data[16]; // 0
} input_reg_params_t;
Code: Select all
err = mbc_master_get_cid_info(cid, ¶m_descriptor);
Code: Select all
mbc_master_get_parameter(cid, (char*)param_descriptor->param_key,(uint8_t*)&value, &type);
Any help is appreciated as it looks like that i did not get something. crashing the device by receiving some data is quite strange to me.request: 0x01 0x04 0x00 0x00 0x00 0x04 0xf1 0xc9
answer: 0x01 0x04 0x08 0x43 0x69 0xa0 0xba 0x00 0x00 0x00 0x00 0x58 0x55