Hi.
I used KSD + PE and lwip stack. controller MK60DN512 .
I want send udp packets from 192.168.70.110 ip to 192.168.70.111 ip.
/* Write your local variable definition here */ struct netif fsl_netif0; struct netif *ner; ip_addr_t fsl_netif0_ipaddr, fsl_netif0_netmask, fsl_netif0_gw; int err; lwip_init(); IP4_ADDR(&fsl_netif0_ipaddr, 192,168,70,110); IP4_ADDR(&fsl_netif0_netmask, 255,255,255,0); IP4_ADDR(&fsl_netif0_gw, 192,168,70,1); ner = netif_add(&fsl_netif0, &fsl_netif0_ipaddr, &fsl_netif0_netmask, &fsl_netif0_gw, NULL, ethernetif_init, ethernet_input); if ( ner == NULL ) err++; netif_set_default(&fsl_netif0); netif_set_up(&fsl_netif0); { struct udp_pcb * pcb; ip_addr_t ipaddr; struct pbuf *p; err_t err; uint32_t dt = 0; // get new pcb dt |= ENET->EIR >> 27; pcb = udp_new(); if (pcb == NULL) { LWIP_DEBUGF(UDP_DEBUG, ("udp_new failed!\n")); return; } // bind to any IP address on port 7 if (udp_bind(pcb, IP_ADDR_ANY, 9000) != ERR_OK) { LWIP_DEBUGF(UDP_DEBUG, ("udp_bind failed!\n")); return; } dt |= ENET->EIR >> 27; p = pbuf_alloc (PBUF_TRANSPORT, 8, PBUF_RAM); while (1){ OSA_TimeDelay(1000); IP4_ADDR(&ipaddr, 192,168,70,111); err = udp_sendto(pcb, p, &ipaddr, 9000); } // set udp_echo_recv() as callback function // for received packets // udp_recv(pcb, udp_echo_recv, NULL); }
This code doesn't send packets.
Prompt in what an error?
Hi Prof,
have you seen this example? If not please take a look, you will find it useful.
C:\Freescale\KSDK_1.2.0\examples\<board>\demo_apps\lwip\lwip_udpecho_demo
Regards,
Carlos