主题中讨论的其他器件:DP83640
您好!
我有 Lwip 驱动程序、如何将其用于 TCP/IP?
您能不能与我分享 TCP/IP 的演示应用程序代码。
此致、
伊曼纽尔
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.
您好、Wang、
函数
EMAC_LwIP_Main (emacAddress);;正在进行许多服务器配置。
我们已经包括了您提到的标题。
int main()
{
struct pbuf *Tx;
uint16_t length=0;
char msg[5]、error、PCB;
_enable_IRQ ();
EMAC_LwIP_Main (emacAddress);
IP4_ADDR (&src、162、192、37、29);
IP4_ADDR (&dst、162、192、37、28);
IP4_ADDR (&SNET、255、255、0);
IP4_ADDR (_nnet、0、0、0、0);
pc=udp_new();
error=udp_bind (PCB、&src、6031);
error=udp_connect (PCB、&D、49668);
长度= 5;
tx=pbuf_alloc (PBUF_transport、length、PBUF_RAM);
Tx->NEX=0;
tx->len=tx->t_tlen=length;
memcpy (Tx->PAYLOAD, msg, Tx->len);
udp_sendto (PCB、Tx、&dst、49668);
pbuf_free (Tx);
}
void EMAC_LwIP_Main (uint8_t * macAddress)
{
unsigned int ipaddr;
uint8_t testChar;
struct in_addr devIPAddress;
//iommUnlock();
//iommMuxEnableMdio();
//iommMuxEnableMii ();
//iommLock();
sciInit();
/*启用 CPSR 寄存器中的中断生成*/
IntMasterIRQEnable();
_enable_FIQ ();
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
sciDisplayText (scilinREG、txtTitle、sizeof (txtTitle));
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
sciDisplayText (scilinREG、txtTI、sizeof (txtTI));
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
#ifdef __little_endian__
sciDisplayText (scilinREG、txtLittleEndian、sizeof (txtLittleEndian));
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
其他
sciDisplayText (scilinREG、txtBigEndian、sizeof (txtBigEndian));
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
#endif
/*使用 DHCP 初始化 lwIP 库。*/
sciDisplayText (scilinREG、txtEnetInit、sizeof (txtEnetInit));
ipaddr = lwIPInit (0、macAddress、0xA2C0251C、0xFFFFFF0000、0、IPADDR_USE_STATIC);
sciDisplayText (scilinREG、(uint8_t*)"..done"、sizeof ("..done");
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
如果(0 = ipaddr){
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
sciDisplayText (scilinREG、txtErrorInit、sizeof (txtErrorInit));
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
}否则{
/*将 IP 地址转换为字符串*/
devIPAddress.s_addr = ipaddr;
TxtIPAddrItoA =(uint8_t *) inet_ntoA (devIPAddress);
LocatorConfig (macAddress、"HDK enet_lwip");
/*初始化示例 httpd 服务器。 *
sciDisplayText(scilinREG,(uint8_t*)“正在启动 Web 服务器”,sizeof ("Starting Web Server");
httpd_init();
sciDisplayText (scilinREG、(uint8_t*)"..done"、sizeof ("..done");
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
/*永久循环。 所有工作都在中断处理程序中完成。 *
//while (1)
{
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
sciDisplayText (scilinREG、txtTitle、sizeof (txtTitle));
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
sciDisplayText (scilinREG、txtTI、sizeof (txtTI));
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
#ifdef __little_endian__
sciDisplayText (scilinREG、txtLittleEndian、sizeof (txtLittleEndian));
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
其他
sciDisplayText (scilinREG、txtBigEndian、sizeof (txtBigEndian));
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
#endif
sciDisplayText (scilinREG、txtIPAddrTxt、sizeof (txtIPAddrTxt));
sciDisplayText (scilinREG、txtIPAddrItoA、16);
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
sciDisplayText (scilinREG、txtNote1、sizeof (txtNote1));
sciDisplayText (scilinREG、txtIPAddrItoA、16);
sciDisplayText (scilinREG、txtCRLF、sizeof (txtCRLF));
/*在打印下一组之前,请等待终端上的字符*/
// sciReceive (scilinREG、1、testChar);
}
}
}
UDP 不起作用。 DP83640正在生成与 src 和 dst IP 地址相同的 ARP。
我们对这一问题没有任何了解,请提出您的建议。
此致、
伊曼纽尔
您好!
我的注释为蓝色:
int main()
{
extern unsigned int len、tot_len;
struct udp_pcb *pcb;
struct ip_addr ipaddr、netmask、gw、src、dst;
struct pbuf *Tx;
uint16_t length=0;
char msg[5]、error、PCB;
_enable_IRQ ();
EMAC_LwIP_Main (emacAddress);
// IP 地址应为电路板的 IP 地址
IP4_ADDR (&src、162、192、37、29);
IP4_ADDR (&dst、162、192、37、28);
IP4_ADDR (&SNET、255、255、0);
IP4_ADDR (_nnet、0、0、0、0);
//这适用于 gatway
IP4_ADDR (&GW、192、168、 0、1);
pc=udp_new();
//这些数字是否对您有效?
error=udp_bind (PCB、&src、6031);
error=udp_connect (PCB、&D、49668); //不是 UDP 的有效数字
长度= 5;
tx=pbuf_alloc (PBUF_transport、length、PBUF_RAM);
Tx->NEX=0;
tx->len=tx->t_tlen=length;
memcpy (Tx->PAYLOAD, msg, Tx->len);
udp_sendto (PCB、Tx、&dst、49668); //不是 UDP 的有效数字
pbuf_free (Tx);
}