Modbus TCP/IP, Slave Adress, IP Adress
Posted: Wed Jan 04, 2023 9:03 am
Hello,
can someone tell me how I can assign an individual IP address and slave ID to a Modbus slave?
For me, the address is always assigned automatically. In addition, I can use the master to address the slave with any desired slave ID, no matter which one I enter there.
The description for the master states that I can do this with
char* slave_ip_address_table[MB_DEVICE_COUNT] = {
"192.168.1.21", // Address corresponds to MB_DEVICE_ADDR1 and set to predefined value by user
"192.168.1.22", // Address corresponds to MB_DEVICE_ADDR2 of slave device in the Modbus data dictionary
NULL // Marker of end of list
};
But where do I enter that?
As master I use "Simply Modbus TCP"
--------
In "esp_modbus_common.h"
I tried it with
// TCP/UDP communication structure
structure {
mb_mode_type_tip_mode; /*!< Modbus communication mode */
uint16_t ip_port; /*!< Modbus port */
mb_tcp_addr_type_t ip_addr_type; /*!< Modbus address type */
void* ip_addr; /*!< Modbus address table for connection */
void* ip_netif_ptr; /*!< Modbus network interface */
};
} mb_communication_info_t;
But when I write in the app_main()
mb_communication_info_t comm_info = { 0 };
comm_info.ip_addr = "192.168.1.21";
nothing changes. The IP is assigned automatically again and the slave ID still doesn't matter.
Greeting
Michael
PS: everything works fine with Modbus RTU.
can someone tell me how I can assign an individual IP address and slave ID to a Modbus slave?
For me, the address is always assigned automatically. In addition, I can use the master to address the slave with any desired slave ID, no matter which one I enter there.
The description for the master states that I can do this with
char* slave_ip_address_table[MB_DEVICE_COUNT] = {
"192.168.1.21", // Address corresponds to MB_DEVICE_ADDR1 and set to predefined value by user
"192.168.1.22", // Address corresponds to MB_DEVICE_ADDR2 of slave device in the Modbus data dictionary
NULL // Marker of end of list
};
But where do I enter that?
As master I use "Simply Modbus TCP"
--------
In "esp_modbus_common.h"
I tried it with
// TCP/UDP communication structure
structure {
mb_mode_type_tip_mode; /*!< Modbus communication mode */
uint16_t ip_port; /*!< Modbus port */
mb_tcp_addr_type_t ip_addr_type; /*!< Modbus address type */
void* ip_addr; /*!< Modbus address table for connection */
void* ip_netif_ptr; /*!< Modbus network interface */
};
} mb_communication_info_t;
But when I write in the app_main()
mb_communication_info_t comm_info = { 0 };
comm_info.ip_addr = "192.168.1.21";
nothing changes. The IP is assigned automatically again and the slave ID still doesn't matter.
Greeting
Michael
PS: everything works fine with Modbus RTU.