read multiple registers in modbus RTU
Posted: Thu May 16, 2024 12:02 pm
I want to read 4 register values together , I am successful in getting a response. But I am only able to read the first 2 register values.
This is how I have defined my values
{ CID_INP_DATA_0, STR("active_energy"), STR(" "), MB_DEVICE_ADDR1, MB_PARAM_INPUT, 01127, 4,
INPUT_OFFSET(data_block1), PARAM_TYPE_U16, 8, OPTS( 0, 0, 0 ), PAR_PERMS_READ_WRITE_TRIGGER },
if(param_descriptor->cid == 0){
ESP_LOGI(TAG, "Characteristic #%d %s (%s) value = %08lX read successful.",
param_descriptor->cid,
(char*)param_descriptor->param_key,
(char*)param_descriptor->param_units,
value);
}
where am I making a mistake.
This is how I have defined my values
{ CID_INP_DATA_0, STR("active_energy"), STR(" "), MB_DEVICE_ADDR1, MB_PARAM_INPUT, 01127, 4,
INPUT_OFFSET(data_block1), PARAM_TYPE_U16, 8, OPTS( 0, 0, 0 ), PAR_PERMS_READ_WRITE_TRIGGER },
if(param_descriptor->cid == 0){
ESP_LOGI(TAG, "Characteristic #%d %s (%s) value = %08lX read successful.",
param_descriptor->cid,
(char*)param_descriptor->param_key,
(char*)param_descriptor->param_units,
value);
}
where am I making a mistake.