Modbus TCP: mb wrong slave ip address table
Posted: Mon Apr 14, 2025 8:28 pm
Hello,
I try to communicate via an ESP32-S3 and MODBUS TCP to my inverter. I am not able to deliver a proper ip address table.
I always get the erro "mb wrong slave ip address table".
I attached the code which I use to connect to a slave.
When it comes to this line: it throws the error
Did I miss a configuration?
Can somebody tell me how to define the ip address table ?
Kind regards,
Kai
I try to communicate via an ESP32-S3 and MODBUS TCP to my inverter. I am not able to deliver a proper ip address table.
I always get the erro "mb wrong slave ip address table".
I attached the code which I use to connect to a slave.
Code: Select all
char* slave_ip_address_table[2] = {
"192.168.2.3",
NULL
};
mb_parameter_descriptor_t descriptors[] = {
{
.cid = 0,
.param_key = "PV1Power",
.param_units = "W",
.param_type = MB_PARAM_HOLDING,
.mb_slave_addr = SLAVE_ADDR,
.mb_reg_start = PV1_REG_ADDR,
.mb_size = PV1_REG_COUNT,
.param_offset = 0,
.access = PAR_PERMS_READ
}
// Du kannst hier mehrere Parameter definieren
};
mb_communication_info_t comm_info = {
.ip_addr_type = MB_IPV4,
.ip_addr = (void*)slave_ip_address_table,
.ip_port = SLAVE_PORT,
.ip_netif_ptr = NULL,
.mode = MB_MODE_TCP
};
void modbus_check(void)
{
void* master_handler = NULL;
ESP_ERROR_CHECK(mbc_master_init_tcp(&master_handler));
ESP_ERROR_CHECK(mbc_master_setup((void*)&comm_info));
ESP_ERROR_CHECK(mbc_master_start());
ESP_LOGI(TAG_ESP, "Modbus TCP Master connected to %s:%d", slave_ip_address_table[0], SLAVE_PORT);
mbc_master_set_descriptor(descriptors, sizeof(descriptors) / sizeof(descriptors[0]));
vTaskDelay(pdMS_TO_TICKS(1000));
esp_err_t err = mbc_master_get_parameter(0, "PV1Power", (uint8_t*)&pv1_power, ®type);
if (err == ESP_OK)
{
ESP_LOGE(TAG_ESP, "PV1 Power: %"PRIu32" W", pv1_power);
}
else
{
ESP_LOGE(TAG_ESP, "Error reading: %s", esp_err_to_name(err));
}
}
When it comes to this line:
Code: Select all
ESP_ERROR_CHECK(mbc_master_setup((void*)&comm_info)); E (6714) MB_CONTROLLER_MASTER: mbc_tcp_master_setup(125): mb wrong slave ip address table.
E (6715) MB_CONTROLLER_MASTER: mbc_master_setup(156): Master setup failure, error=(0x102) (ESP_ERR_INVALID_ARG).
Did I miss a configuration?
Can somebody tell me how to define the ip address table ?
Kind regards,
Kai