UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
1,232 Views
Registered: ‎05-13-2016

LWIP support for SO_SNDTIMEOUT

Does Xilinx's distribution of LWIP (1.4.1) support SO_SNDTIMEOUT? If so, how do you set the value, as it is not visible in the GUI settings. 

 

At issue is I am using  LWIP_write()  on a TCPIP connection.  If the cable becomes disconnected, the LWIP_WRITE enters the block state indefinitely!  I have noticed that if I reconnect the cable, the write sometimes becomes unblocked, returns an error code, and I can successfully close the socket.  Other times when reconnecting the cable,  the write continues to be blocked, and as such I cannot recover.

 

Searching has led me to the SO_SNDTIMEOUT which seems to indicate that I can set a timeout value which will unblock the write, return an error code, and thus allow me to detect the error and safely close the socket.

0 Kudos
4 Replies
1,222 Views
Registered: ‎05-13-2016

Re: LWIP support for SO_SNDTIMEOUT

Looking at the LWIP I found the following where it checks for  SO_SNDTIMEOUT being defined.

 

Where should I define this? Also, where does the timeout values get set.

 

 

netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size,

u8_t apiflags, size_t *bytes_written)

 

{

struct api_msg msg;

err_t err;

u8_t dontblock;

 

 

LWIP_ERROR("netconn_write: invalid conn", (conn != NULL), return ERR_ARG;);

LWIP_ERROR("netconn_write: invalid conn->type", (conn->type == NETCONN_TCP), return ERR_VAL;);

if (size == 0) {

return ERR_OK;

 

}

dontblock = netconn_is_nonblocking(conn) || (apiflags & NETCONN_DONTBLOCK);

if (dontblock && !bytes_written) {

/* This implies netconn_write() cannot be used for non-blocking send, since

 

it has no way to return the number of bytes written. */

return ERR_VAL;

 

}

 

/* non-blocking write sends as much */

msg.function = do_write;

msg.msg.conn = conn;

msg.msg.msg.w.dataptr = dataptr;

msg.msg.msg.w.apiflags = apiflags;

msg.msg.msg.w.len = size;

#if LWIP_SO_SNDTIMEO

if (conn->send_timeout != 0) {

/* get the time we started, which is later compared to

 

sys_now() + conn->send_timeout */

msg.msg.msg.w.time_started = sys_now();

} else {

 

msg.msg.msg.w.time_started = 0;

}

#endif /* LWIP_SO_SNDTIMEO */

 

 

/* For locking the core: this _can_ be delayed on low memory/low send buffer,

 

but if it is, this is done inside api_msg.c:do_write(), so we can use the

non-blocking version here. */

err = TCPIP_APIMSG(&msg);

if ((err == ERR_OK) && (bytes_written != NULL)) {

if (dontblock

#if LWIP_SO_SNDTIMEO

 

|| (conn->send_timeout != 0)

#endif /* LWIP_SO_SNDTIMEO */

 

) {

/* nonblocking write: maybe the data has been sent partly */

*bytes_written = msg.msg.msg.w.len;

} else {

/* blocking call succeeded: all data has been sent if it */

 

*bytes_written = size;

}

}

 

0 Kudos
1,216 Views
Registered: ‎05-13-2016

Re: LWIP support for SO_SNDTIMEOUT

I found where to change the SO_SNDTIMEO seting in opt.h.

 

looking at the comment in the code, doe SO_SNDTIMEO just delay sending the data out, or is it a timeout that occurs when id the date does not go out in that amount of time.

 

#if LWIP_SO_SNDTIMEO

/** timeout to wait for sending data (which means enqueueing data for sending

 

in internal buffers) */

s32_t send_timeout;

#endif /* LWIP_SO_RCVTIMEO */

 

0 Kudos
1,199 Views
Registered: ‎05-13-2016

Re: LWIP support for SO_SNDTIMEOUT

It looks like the timeout get initialized in api_msg.c, as follows!

 

#ifdef LWIP_SO_SNDTIMEO

conn->send_timeout = 0;

#endif /* LWIP_SO_SNDTIMEO */

 

Its a pain that I have to go back to the install directory to make the change, so that it does not get overwritten when I generate the local BSP.  Is there a way to add settings to the BSP GUI?

0 Kudos
Xilinx Employee
Xilinx Employee
1,141 Views
Registered: ‎02-01-2008

Re: LWIP support for SO_SNDTIMEOUT

You can make a local copy and customize as follows:

  • copy <sdk install>\data\embeddedsw\ThirdParty\sw_services\lwip141_v1_9 to a local directory such as <local>\sdkRepo\sw_services\lwip141_v1_9
  • Add <local>\sdkRepo as a repo to your SDK project
  • modify local copy of lwip141_v1_9\data\lwip141.mld to add your new parameter name. This entry will add your parameter to the gui when configuring the bsp.
  • modify local copy of lwip141_v1_9\data\lwip141.tcl to get the value from the gui, and populate an include file

You could use something simple such as 'linkspeed' as an example.

 

When changing the .mld, you will need to rescan the repository, or just to make sure the new .mld is read, close and reopen the sdk workspace. Sounds like you already know how the new src is pulled into the sdk workspace bsp project.

0 Kudos