esp32 modbus tcp slave中的get_example_netif() 函数在那里??

yc2168
Posts: 1
Joined: Fri Dec 02, 2022 3:00 am

esp32 modbus tcp slave中的get_example_netif() 函数在那里??

Postby yc2168 » Fri Dec 02, 2022 3:12 am

我将modbus tcp slave中的 result = example_connect(); 替换了标准的wifi 驱动。 之后配合modbus tcp slave 例子编译时找不到 comm_info->ip_netif_ptr = (void*)get_example_netif(); 这个函数, 我查找了这是在例子中的。请问在标准的驱动包中如何实现这个get_example_netif(); 的功能。

ESP_ICY
Posts: 404
Joined: Mon Aug 23, 2021 11:10 am

Re: esp32 modbus tcp slave中的get_example_netif() 函数在那里??

Postby ESP_ICY » Wed Dec 07, 2022 2:30 am

函数的具体实现封装在库文件里了,暂时没法看到

ESP_alisitsyn
Posts: 211
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: esp32 modbus tcp slave中的get_example_netif() 函数在那里??

Postby ESP_alisitsyn » Mon Dec 19, 2022 2:38 pm

The function get_example_netif() returns the pointer to network interface `s_example_esp_netif` returned from esp_netif_new(). See some examples below on how to initialize the netif and get the pointer. Refer to documentation for netif: https://docs.espressif.com/projects/esp ... netif.html for more information.

Code: Select all

	
	esp_netif_config_t netif_config = ESP_NETIF_DEFAULT_WIFI_STA();
	esp_netif_t *netif = esp_netif_new(&netif_config);
	assert(netif);
	esp_netif_attach_wifi_station(netif);
	esp_wifi_set_default_wifi_sta_handlers();
	s_example_esp_netif = netif;

Code: Select all

    esp_netif_config.if_desc = desc;
    esp_netif_config.route_prio = 64;
    esp_netif_config_t netif_config = {
        .base = &esp_netif_config,
        .stack = ESP_NETIF_NETSTACK_DEFAULT_ETH
    };
    esp_netif_t *netif = esp_netif_new(&netif_config);
    s_example_esp_netif = netif;

Who is online

Users browsing this forum: No registered users and 38 guests