This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我的 LWIP 1.4.1 示例使用 staic IP 运行,但不使用 DHCP 运行。
我的网络中有一台 DHCP 服务器、我还在 lwipopts.h 中设置了该服务器
#define LWIP_DHCP 1.
#define DHCP_do_ARP_CHECK 1.
但尝试 DHCP 时、我始终会得到以下结果:
Hercules 微控制器
应用工程师
小端字节序器件
初始化以太网(DHCP)
调试-获取 PHY ID ...成功
调试-使 PHY 处于活动状态...成功
调试-获取 PHY 链路状态...成功
调试-设置链接...成功
已完成
---- 初始化硬件时出错---
对我有什么建议?
尊敬的 Armin:
错误消息"error initializing hardware"(初始化硬件时出错)表示未提供 IP 地址。
您可以尝试这种设置吗?
uint8 ip_addr[4]={192、168、2、44};
uint8网络掩码[4]={255、255、255、0};
uint8 gateway[4]={192、168、2、254};
ipaddr = lwIPInit (0、macAddress、*((uint32_t *) ip_addr)、*(((uint32_t *) netmask)、*(((uint32_t *) gateway)、 ipaddr_use_static);
如果再次出现错误、请尝试使用 DHCP 获取动态 IP 地址:
ipaddr = lwIPInit (0、macAddress、0、0、0、 ipaddr_use_dhcp);
您好、QJ Wang、
当我n‘t 静态 IP 工作时、使用 DHCP 获取动态 IP 确实有效。
在 lwiplib.c 的 lwIPInit 函数中、有以下代码:
dhcp_start(&hdkNetIF[instNum]); count = 10; /* Check for DHCP completion for 'count' number of times, each for the given delay. */ while(count--)
在我使用的 DHCP 服务器(在宽带路由器中)中、发现必须将计数从10增加到100、否则 LwIP 代码无法在超时内获取 IP 地址。
也许增加计数值对您的情况有所帮助。
切斯特、您好!
是的、提高价值可以解决问题、谢谢