mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/freemodbus_fix_zero_based_reg_address_in_iterator_v43' into 'release/v4.3'
freemodbus: fix mb zero based reg address in the iterator (backport v4.3) See merge request espressif/esp-idf!14551
This commit is contained in:
commit
3a9a208edc
@ -62,7 +62,7 @@ static mb_descr_entry_t* mbc_slave_find_reg_descriptor(mb_param_type_t type, uin
|
||||
if ((addr >= it->start_offset)
|
||||
&& (it->p_data)
|
||||
&& (regs >= 1)
|
||||
&& ((addr + regs) <= (it->start_offset + reg_size + 1))
|
||||
&& ((addr + regs) <= (it->start_offset + reg_size))
|
||||
&& (reg_size >= 1)) {
|
||||
return it;
|
||||
}
|
||||
|
@ -118,7 +118,8 @@ void app_main(void)
|
||||
reg_area.type = MB_PARAM_HOLDING; // Set type of register area
|
||||
reg_area.start_offset = MB_REG_HOLDING_START_AREA0; // Offset of register area in Modbus protocol
|
||||
reg_area.address = (void*)&holding_reg_params.holding_data0; // Set pointer to storage instance
|
||||
reg_area.size = sizeof(float) << 2; // Set the size of register storage instance
|
||||
// Set the size of register storage instance = 150 holding registers
|
||||
reg_area.size = (size_t)(HOLD_OFFSET(holding_data4) - HOLD_OFFSET(test_regs));
|
||||
ESP_ERROR_CHECK(mbc_slave_set_descriptor(reg_area));
|
||||
reg_area.type = MB_PARAM_HOLDING; // Set type of register area
|
||||
reg_area.start_offset = MB_REG_HOLDING_START_AREA1; // Offset of register area in Modbus protocol
|
||||
@ -132,7 +133,6 @@ void app_main(void)
|
||||
reg_area.address = (void*)&input_reg_params.input_data0;
|
||||
reg_area.size = sizeof(float) << 2;
|
||||
ESP_ERROR_CHECK(mbc_slave_set_descriptor(reg_area));
|
||||
// Initialization of Input Registers area
|
||||
reg_area.type = MB_PARAM_INPUT;
|
||||
reg_area.start_offset = MB_REG_INPUT_START_AREA1;
|
||||
reg_area.address = (void*)&input_reg_params.input_data4;
|
||||
|
Loading…
Reference in New Issue
Block a user