lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] uneven UDP transfer


From: Huston007
Subject: [lwip-users] uneven UDP transfer
Date: Wed, 21 Sep 2011 02:14:36 -0700 (PDT)

Hello there.
so look. I use LwIP 1.3.2 on ST32F207 ARM microcontroller. I want to send a lot of data from ST32 to PC using UDP, in standalone application.

I make a application basic on udp-server demo. Its great work, if _i dont free the pbuf in udp_receive callback_.

if i add a pbuf_free(p); at end of callback, the data transfer corrupting, it going to be uneven, fragmentary. This is my code:


//my receive callback:
void udp_echoserver_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
{
  //remember the structures to use it in send function
  upcb1 = upcb;
  addr1 = addr;

  parseIncomingMessage(p); //searching for commands in incoming messages

  /* Free the p buffer */

  pbuf_free(p); //this is it! if i use it, it is uneven transmit! If not, app receive only few messages and going to corrupt
}

And there is my send function:

void udpSendArray(uint16_t data[])
{
	err_t err;
        uint16_t len = udpPackageSize + headerSize;

	struct pbuf *pb = pbuf_alloc(PBUF_TRANSPORT,len, PBUF_REF);
        
	pb->payload = data; 
	
	udp_connect(upcb1, addr1, UDP_CLIENT_PORT);
        err = udp_send(upcb1, pb);
	if(err!=ERR_OK)	{
		//do something. But application never enter this block
	}
	udp_disconnect(upcb1);
	pbuf_free(pb);
} 

this function periodically calling from main cycle (main.c):


  while (1)
  {
    /* check if any packet received */
    if (ETH_CheckFrameReceived())
    {
      /* process received ethernet packet */
      LwIP_Pkt_Handle();
    }
    /* handle periodic timers for LwIP */
    LwIP_Periodic_Handle(LocalTime);  
	
	if (full_transmit) udpSendArray(bufADC1);
  }

My code is correct, i think. or not? How to make it work normal?


View this message in context: uneven UDP transfer
Sent from the lwip-users mailing list archive at Nabble.com.

reply via email to

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