lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Using both sequential and raw APIs


From: ckchan
Subject: Re: [lwip-users] Using both sequential and raw APIs
Date: Thu, 06 Nov 2008 01:45:18 +0800
User-agent: Thunderbird 2.0.0.12 (Windows/20080213)


i'm trying to workaround the netconn_recv blocking since i'm using lwIP 1.1.0. i want to send tcp packet at fixed interval (say every 1 sec) to the server, while still be able to received (non fixed interval) tcp packet from server. using only netconn APIs, i could only do "either" and not "both".

no, the FreeRTOS didnt mix the APIs. i meant to say that the first half of the init is based and referred from the example supplied.

Date: Wed, 05 Nov 2008 17:34:48 +0100
From: "address@hidden" <address@hidden>
Subject: Re: [lwip-users] Using both sequential and raw APIs
To: Mailing list for lwIP users <address@hidden>
Message-ID: <address@hidden>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Your code will most certainly NOT work and mixing the APIs in this way is absolutely not supported. If you tried long enough (and maybe changed some lwIP code), you might get it working, but I don't see the point in that. Why do you want to mix the APIs anyway?

Oh, and does the "basic web server supplied with FreeRTOS" also mix the APIs? If so, it's a bad example of using lwIP...

Simon



CK Chan wrote:
i'm building a TCP client with lwIP 1.1.0 on top of FreeRTOS.
i tried to use both APIs but have problem receiving TCP packet. if i use netconn_recv() APIs, i can receive the packet. i'm trying to use tcp_recv() instead

most of the codes is from basic web server supplied with FreeRTOS.

will this work ?

/********************************************************/
static err_t
recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
   LWIP_UNUSED_ARG(arg);
   LWIP_UNUSED_ARG(err);

   printf("recv...\r\n");
   // Inform TCP that we have taken the data
   tcp_recved(pcb, p->tot_len);

   return  ERR_OK;
}

/********************************************************/
void vBasicTCPClient( void *pvParameters )
{
struct netconn *pxTCPListener;// *pxTCPNewConnection;
struct ip_addr xIpAddr, xNetMast, xGateway, xIPHost, addr;
extern err_t ethernetif_init( struct netif *netif );
static struct netif EMAC_if;
err_t err;

   /* Parameters are not used - suppress compiler error. */
   ( void ) pvParameters;

   /* Create and configure the EMAC interface. */
   IP4_ADDR(&xIpAddr,emacIPADDR0,emacIPADDR1,emacIPADDR2,emacIPADDR3);
IP4_ADDR(&xNetMast,emacNET_MASK0,emacNET_MASK1,emacNET_MASK2,emacNET_MASK3); IP4_ADDR(&xGateway,emacGATEWAY_ADDR0,emacGATEWAY_ADDR1,emacGATEWAY_ADDR2,emacGATEWAY_ADDR3); netif_add(&EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input);

   /* make it the default interface */
       netif_set_default(&EMAC_if);

   /* bring it up */
       netif_set_up(&EMAC_if);
     /* Create a new tcp connection handle */
       pxTCPListener = netconn_new( NETCONN_TCP );

       tcp_arg(pxTCPListener->pcb.tcp, NULL);
       tcp_recv(pxTCPListener->pcb.tcp, recv_tcp);  // set a callback

       IP4_ADDR(&xIPHost,192,168,1,101);      // IP of TCP server
       netconn_bind(pxTCPListener, NULL, tcpSERVER_PORT );
       err = netconn_connect(pxTCPListener, &xIPHost, tcpSERVER_PORT);
       if (err == ERR_OK)
       {
           printf("connected...\r\n");
       }
         for( ;; )
       {
       }
}



thanks for your time !




_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users






------------------------------

_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users

End of lwip-users Digest, Vol 63, Issue 5
*****************************************
------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - http://www.avg.com Version: 8.0.175 / Virus Database: 270.8.6/1769 - Release Date: 11/5/2008 7:17 AM






reply via email to

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