- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi :
I am a newbie to nios and i want to use stand-alone lwip stack to transport data form my board (stratix ii ) to PC. My design is modified from a stand-alone lwip example lwip-web server. When i run the code ,it did not send any udp message at all ,all it sent are ARPs:the board and PC all ask who has 10.1.1.52(pc itself's ip address),but PC did not answerd. I 've searched this forum ,however ,no post can help me to resove this problem Here is my code ,could anyone tell me what's wrong? Best Regards the_gadfly -------------------------------------------------------------------------# include "system.h"# include "arch/init.h"# include "lwip/ip_addr.h"# include "lwip/tcpip.h"# include "lwip/netif.h"# include "netif/lan91c111if.h"# include "sys/alt_alarm.h" /* ---------- IP oriented addresses for ethernet adapter ---------- */# define IPADDR0 10 # define IPADDR1 1# define IPADDR2 1# define IPADDR3 51 # define NETMASK0 255# define NETMASK1 255# define NETMASK2 255# define NETMASK3 0 # define GWADDR0 10# define GWADDR1 1# define GWADDR2 1# define GWADDR3 2 int main(void) { //0.6.4 struct netif *netif; struct netif netif; struct ip_addr ipaddr, netmask, gw; struct ip_addr udpDestIpAddr; struct pbuf *p; struct udp_pcb *pcb; err_t err; char Test[]="hello world !"; int i=0; alt_avalon_lan91c111_if* dev_list_ptr = (alt_avalon_lan91c111_if*)alt_ethernet_device_list.next; printf("UDP-server using Light-weight IP (LWIP)\n\n"); /* Initialize lwip */ lwip_init(); printf ("Setting IP address to: %d.%d.%d.%d\n", IPADDR0, IPADDR1, IPADDR2, IPADDR3); printf ("Setting netmask to: %d.%d.%d.%d\n", NETMASK0, NETMASK1, NETMASK2, NETMASK3); printf ("Setting gateway address to: %d.%d.%d.%d\n\n\n", GWADDR0, GWADDR1, GWADDR2, GWADDR3); IP4_ADDR(&ipaddr, IPADDR0, IPADDR1, IPADDR2, IPADDR3); IP4_ADDR(&netmask, NETMASK0, NETMASK1, NETMASK2, NETMASK3); IP4_ADDR(&gw, GWADDR0, GWADDR1, GWADDR2, GWADDR3); //0.6.4 netif = netif_add(&ipaddr, &netmask, &gw, netif_add(&netif, &ipaddr, &netmask, &gw,(void*)dev_list_ptr,lan91c111if_init, ip_input); //0.6.4 netif_set_default(&netif); netif_set_default(&netif); IP4_ADDR(&udpDestIpAddr, 10, 1 ,1, 52); p = pbuf_alloc(PBUF_TRANSPORT,sizeof(Test),PBUF_RAM); memcpy(p->payload, Test, sizeof(Test)); pcb = udp_new(); udp_bind(pcb, IP_ADDR_ANY, 60000); udp_connect(pcb, &udpDestIpAddr, 60000); err=udp_send(pcb,p); if(err==ERR_OK) {printf("send ok !\n");} pbuf_free(p); udp_remove(pcb); while(1) { //0.6.4 lan91c111if_service(netif); lan91c111if_service(&netif); } } -----------------------------------------Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I also added the etharp_tmr()
--------------- ... ... while(1) { //0.6.4 lan91c111if_service(netif); lan91c111if_service(&netif); now = get_milliseconds(); if ((now - lasttime)*1000/alt_ticks_per_second() > ARP_TMR_INTERVAL) { lasttime = now; etharp_tmr(); // Ever 10s execute etharp_tmr() } if (++j==1000) { ip_reass_timer(); j=0; } } ... ... It still didn't work .Is there anything i missing ? Best Regards the_gadfly
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page