lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Raw-api UDP example :Can not receive UDP-messages


From: the_gadfly
Subject: [lwip-users] Raw-api UDP example :Can not receive UDP-messages
Date: Thu, 25 Jun 2009 20:57:05 -0700 (PDT)

hi :
I am a new guy to lwip ,and when i use udp to my design .i hit a big
broblem.After seaching a long time,it is still here .I  can't receive any
udp message at all,though there are ARPs between PC and  NIOS .here is my
code ,Could anyone tell me what's wrong?

I am going crazy overhere.... 
cheers
the_gadfly
-------------------------------------------------
void httpd_init(void)
{ char Test[]="hello world !";
  struct udp_pcb *pcb;
  struct ip_addr ipaddr;
  struct pbuf *p;
  err_t err;
  
  IP4_ADDR(&ipaddr,10,1,1,52);

  p = pbuf_alloc(PBUF_RAW,15,PBUF_RAM);
  p->payload=(void *)Test;
  p->len=p->tot_len=15;
  
  pcb = udp_new();
  err=udp_bind(pcb, IP_ADDR_ANY, 30);
  printf("err= %s",err);
  err=udp_connect(pcb,&ipaddr,30);
  printf("err= %s",err);
 
  err=udp_send(pcb,p);
  printf("err= %s",err);
  pbuf_free(p);
  udp_remove( pcb );
}

int main(void)
{
//0.6.4 struct netif *netif;
        struct netif netif;
        struct ip_addr ipaddr, netmask, gw;
        unsigned int now, lasttime;
        int i;
#if IP_REASSEMBLY
        int j;
#endif

   alt_avalon_lan91c111_if* dev_list_ptr = 
(alt_avalon_lan91c111_if*)alt_ethernet_device_list.next;

        printf("Example web server using Light-weight IP (LWIP)\n");
        printf("and simple RAM-based file system.\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", 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);
        
/*
 * Initialize application(s)
 */
         httpd_init(); 
   //udp_echo_init(); 

  
 /* main loop to service the Ethernet device and expire TCP timers
 */
        lasttime = get_milliseconds();

        i=0;
#if IP_REASSEMBLY
        j=0;
#endif

        while(1)
        {
//0.6.4         lan91c111if_service(netif);
                lan91c111if_service(&netif);
                
                now = get_milliseconds();
                if (now - lasttime > TCP_TMR_INTERVAL) {
                        lasttime = now;
                        tcp_tmr();
                        if (++i==50) {
                                //etharp_tmr();
                                i=0;
                        }                               
                }

#if IP_REASSEMBLY
      if (++j==1000) {
        ip_reass_timer();
        j=0;
      }                         
#endif
                
        }
}
------------------------------------

-- 
View this message in context: 
http://www.nabble.com/Raw-api--UDP-example-%3ACan-not-receive-UDP-messages-tp24214474p24214474.html
Sent from the lwip-users mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]