[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] contrib/apps/chargen/chargen.c doesn't receive any pack
From: |
Simon Goldschmidt |
Subject: |
Re: [lwip-users] contrib/apps/chargen/chargen.c doesn't receive any packet |
Date: |
Wed, 30 Jul 2008 14:24:11 +0200 |
>From your post it is not clear whether you understood the principle of using
>threads with lwIP: the core is not protected against concurrent access,
>therefore the RAW api may only be used from one thread at a time, which is the
>tcpip_thread (started in tcpip_init) if you use the other APIs. However, you
>call udp_new etc. from the first thread while the tcpip_thread also works on
>core functions. Hence you will have two threads using the core at the same
>time which will eventually lead to problems.
Also, I think your initialization is wrong, you should take a look at
initialization in the win32 port in CVS for example (I think you have to add
the netif first and then call lwip_init, which calls tcpip_init in turn).
If that still doesn't work I suggest you have a problem with your port (e.g. an
old port for lwIP 1.2.0?). You should check that the tcpip_thread is started
correctly and gets the messages e.g. sent to it when calling socket().
Semaphore initialization (initialized to 0 instead of 1 ignoring the argument
on craetion) has also often been a problem.
Simon
-------- Original-Nachricht --------
> Datum: Wed, 30 Jul 2008 13:17:53 +0800
> Von: "stanliao" <address@hidden>
> An: address@hidden
> Betreff: [lwip-users] contrib/apps/chargen/chargen.c doesn\'t receive any
> packet
> Dear All,
>
>
>
> I downloaded LWIP and added some port code to adapt LWIP to ucOS/II.
> Currently, the overall program can send UDP to network-world; but when I
> use
> "chargen" as the test program, chargen_thread() hangs at i =
> select(maxfdp1,
> &readset, &writeset, 0, 0); statement in "chargen.c". Please refer to the
> following program for the LWIP initialization. I traced into "raw.c"
> raw_input() function and found that the global variable raw_pcbs is 0
> (NULL)
> while receiving a packet. Then, I traced whether any pcb is created! I
> found
> that chargen_thread() calls socket(); socket() calls
> netconn_new_with_proto_and_callback(); the comment for
> netconn_new_with_proto_and_callback() says that the corresponding pcb is
> also created, however, do_newconn() is never called to create pcb. Is
> there
> anything (configuration or initialization) I missed? Thank you very much.
>
>
>
> Best Regards,
>
> Stan Liao
>
>
>
> --- (initialization)
>
> /* initialize lwip */
>
> tcpip_init(NULL,NULL);
>
>
>
> /* initialize net interface (TODO: replace this hard-copy
> address)*/
>
> IP4_ADDR(ð0_ipaddr, 172, 16, 101, 3);
>
> IP4_ADDR(ð0_netmask, 255, 255, 255, 0);
>
> IP4_ADDR(ð0_gw, 172, 16, 101, 254);
>
> #if LWIP_ARP
>
> netif_add(ð0_netif, ð0_ipaddr, ð0_netmask, ð0_gw,
> NULL,
> ethernetif_init, ethernet_input);
>
> #else
>
> netif_add(ð0_netif, ð0_ipaddr, ð0_netmask, ð0_gw, NULL,
> ethernetif_init, ip_input);
>
> #endif
>
> netif_set_default(ð0_netif);
>
> netif_set_up(ð0_netif);
>
>
>
> OSTimeDly(OS_TICKS_PER_SEC);
>
>
>
> /* initialize applications */
>
> #ifdef TE_TEST_CHARGEN
>
> chargen_init();
>
> #endif
>
> //#ifdef TE_TEST_HTTPSERVER_RAW
>
> #if 0
>
> httpd_init();
>
> #endif
>
>
>
> #if 0
>
> {
>
> struct udp_pcb *UDP_PCB;
>
> err_t result;
>
> struct ip_addr remote_ipaddr;
>
> struct pbuf *buffer, *p;
>
> int idx;
>
> char sendString[32];
>
>
>
> IP4_ADDR(&remote_ipaddr, 172, 16, 101, 134);
>
>
>
> UDP_PCB = udp_new();
>
> if (!UDP_PCB)
>
> return;
>
>
>
> result = udp_bind(UDP_PCB, ð0_ipaddr, 333);
>
> if (result != ERR_OK)
>
> {
>
> udp_remove(UDP_PCB);
>
> return;
>
> }
>
>
>
> //udp_recv(UDP_PCB, UDP_Receiver, NULL);
>
> udp_connect(UDP_PCB, &remote_ipaddr, 333);
>
>
>
> buffer = pbuf_alloc(PBUF_RAW, 512, PBUF_POOL);
>
> for (p = buffer; p != NULL; p = p->next)
>
> {
>
> for (idx = 0; idx < p->len; ++idx)
>
> ((char *) (p->payload))[idx] = ' ';
>
> }
>
>
>
> for (idx = 0; ; ++idx)
>
> {
>
> udp_send(UDP_PCB, buffer);
>
> if (idx % 100 == 0)
>
> sysInfo("send packet_%d\r\n", idx);
>
> OSTimeDly(OS_TICKS_PER_SEC/30);
>
> }
>
> }
>
> #endif
>
> ---
>
>
>
--
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/address@hidden