LWIP netconn_sendto() blocking function?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

LWIP netconn_sendto() blocking function?

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: LWIP netconn_sendto() blocking function?

Post 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
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

Re: LWIP netconn_sendto() blocking function?

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: LWIP netconn_sendto() blocking function?

Post 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
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

Re: LWIP netconn_sendto() blocking function?

Post by rubenswerk »

Thank you Giovanni for explanation!
Have a nice day.
Post Reply