lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] New FreeRTOS/LPC1769/lwIP examples


From: calagan
Subject: Re: [lwip-users] New FreeRTOS/LPC1769/lwIP examples
Date: Mon, 26 Nov 2012 08:19:27 -0800 (PST)

Hi, 

Today I've tried to make an echo server using the netconn Api and monitor
the speed.

here the code I've used:



> int main( void )
> {
>       /* Configure any generic parameters needed to run the demo. */
>       prvSetupHardware();
> 
>       /* This call creates the TCP/IP thread. */
>       tcpip_init( lwIPAppsInit, NULL );
> 
>         /* Initialize tcp echo server */
>       tcpecho_init();
> 
> 
>       /* Start the FreeRTOS scheduler. */
>       vTaskStartScheduler();
> 
>       for( ;; );
> }


> void lwIPAppsInit( void *pvArgument )
> {
> ip_addr_t xIPAddr, xNetMask, xGateway;
> extern err_t ethernetif_init( struct netif *xNetIf );
> static struct netif xNetIf;
> 
>       ( void ) pvArgument;
> 
>       /* Set up the network interface. */
>       ip_addr_set_zero( &xGateway );
>       ip_addr_set_zero( &xIPAddr );
>       ip_addr_set_zero( &xNetMask );
> 
>       LWIP_PORT_INIT_GW(&xGateway);
>       LWIP_PORT_INIT_IPADDR(&xIPAddr);
>       LWIP_PORT_INIT_NETMASK(&xNetMask);
> 
>       netif_set_default( netif_add( &xNetIf, &xIPAddr, &xNetMask, &xGateway,
> NULL, ethernetif_init,     tcpip_input ) );
>       netif_set_up( &xNetIf );
> }


> static void tcpecho_thread(void *arg)
> {
>   struct netconn *conn, *newconn;
>   err_t err;
>   int i=0;
> 
>   LWIP_UNUSED_ARG(arg);
> 
>   /* Create a new connection identifier. */
>   conn = netconn_new(NETCONN_TCP);
> 
>   if (conn!=NULL)
>   {
>     /* Bind connection to well known port number 7. */
>     err = netconn_bind(conn, NULL, 7);
> 
>     if (err == ERR_OK)
>     {
>       printf("bind ok\n");
> 
>       /* Tell connection to go into listening mode. */
>       netconn_listen(conn);
> 
>       while (1)
>       {
>         /* Grab new connection. */
>         err = netconn_accept(conn,&newconn);
>         printf("wait for accept\n");
> 
>         /* Process the new connection. */
>         if (err == ERR_OK)
>         {
>           struct netbuf *buf;
>           void *data;
>           u16_t len;
> 
>           while ((err = netconn_recv(newconn,&buf)) == ERR_OK)
>           {
>             do
>             {
>               netbuf_data(buf, &data, &len);
>               netconn_write(newconn, data, len, NETCONN_COPY);
>               i++;
>               printf("data received : %d \n",i);
> 
>             }
>             while (netbuf_next(buf) >= 0);
>             i=0;
>             netbuf_delete(buf);
>           }
> 
>           /* Close connection and discard connection identifier. */
>           netconn_close(newconn);
>           netconn_delete(newconn);
>         }
>       }
>     }
>     else
>     {
>       printf(" can not bind TCP netconn");
>     }
>   }
>   else
>   {
>     printf("can not create TCP netconn");
>   }
> }
> /*-----------------------------------------------------------------------------------*/
> 
> void tcpecho_init(void)
> {
>   sys_thread_new("tcpecho_thread", tcpecho_thread, NULL,
> DEFAULT_THREAD_STACKSIZE+2048, 3);
> }

Now this tcp server doesn't work. My application can connect to the board,
the client application start sending data, I received aroud 20 packets
(around 88bytes by packets) then the rate goes to 0bps.

I wireshark the connexion and after 20 packets received I only seen "retry"
nothing else.

If someone used netconn API I'am interested to see if the throughput is
better than socket API.

thanks.




--
View this message in context: 
http://lwip.100.n7.nabble.com/New-FreeRTOS-LPC1769-lwIP-examples-tp1115p20680.html
Sent from the lwip-users mailing list archive at Nabble.com.



reply via email to

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