Page 1 of 1

LWIP netconn_sendto() blocking function?

Posted: Wed Apr 09, 2014 10:11 am
by rubenswerk
Hello,

I just wonder if netconn_sendto is a blocking function call, which returns AFTER the packet was sent, or if it returns immediately?
Since sending an UDP packet can lead to several subsequent actions (like ARP requests for unknown hosts), I guess that this happens in a background task, but I'm not sure about that.

If it is a background activity, how can I know when my packet was successfully sent?
I know there's no flow control for UDP, so when I say 'successfully', I mean that ARP was successful and the packet was put onto the media.

Is there some kind of callback or flag when the STM32 MAC FIFO is available for new outgoing packets?

Reason for my question is, I have a small test program which sends UDP packets in 10ms interval. When removing the network cable, a reset occurs after a few seconds.

Thank you,
Ruwe

Re: LWIP netconn_sendto() blocking function?

Posted: Wed Apr 09, 2014 10:30 am
by Giovanni
For sure you cannot know when the packet has been physically transmitted, the stack is asynchronous, the MAC driver itself does not notify about a sent frame.

Giovanni

Re: LWIP netconn_sendto() blocking function?

Posted: Thu Apr 10, 2014 12:48 pm
by rubenswerk
Okay, so I have to deal with that on my own.
Is this specific to the MAC driver, or do the ChibiOS drivers not support TX complete callbacks in general, also for other serial peripherals like USART, USB... ?

The number of MAC TX buffers is cofigurable, so I guess there's somewhere a variable counting the used/available buffers inside the driver. So if I want to send packets at maximum speed, would it make sense to watch this counter?

Re: LWIP netconn_sendto() blocking function?

Posted: Thu Apr 10, 2014 1:21 pm
by Giovanni
This is specific of the MAC driver but it is also intrinsic on how the MAC peripheral works probably, after a buffer has been inserted in the chain of buffers there is no way to know when it has been physically transmitted unless you poll a "done" bit in memory.

Giovanni

Re: LWIP netconn_sendto() blocking function?

Posted: Thu Apr 10, 2014 1:40 pm
by rubenswerk
Thank you Giovanni for explanation!
Have a nice day.