lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] uneven UDP transfer


From: Andrey Skladchikov
Subject: Re: [lwip-users] uneven UDP transfer
Date: Fri, 23 Sep 2011 08:58:51 +0500

Thanks for answer! Sorry for multiple messages, I do not specifically.

My ST32F207 use DMA-enabled stack i guess. And transmit works fine
(even and without failure) when I'm looped these lines:

void udpSendArray(uint16_t data[])
{
        err_t err;
        uint16_t len = udpPackageSize + headerSize;
  while (1)
  {
        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);
  }
}

And a udp server example from ST works fine. What can i do?

2011/9/22 address@hidden <address@hidden>:
> First, please don't just post the same thing multiple times. Not getting an
> answer most often means noone has an idea what's wrong. By just posting
> multiple times you risk annoying people and then not getting any answer at
> all...
>
> As to your problem, if not freeing the pbuf helps, that might be a problem
> in your netif driver. If the driver does not send packets right away
> (meaning they are already sent when the driver's 'linkoutput' function
> returns; this is most often not the case for DMA-enabled ethernet MACs), it
> has to pbuf_ref() a pbuf and then pbuf_free() it after it has been copied to
> MAC buffers. Failing to do so, a the pbuf can get freed before sending and
> re-used by the next call to pbuf_alloc(), which could result in the problem
> you are seeing.
>
> Simon
>
>
> Huston007 wrote:
>>
>> 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? I cant
>> kill
>> this bug
>
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>



-- 
С уважением,
Складчиков Андрей



reply via email to

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