lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Connection timeout and issue with LWIP_DEBUGF


From: Jonathan Larmour
Subject: Re: [lwip-users] Connection timeout and issue with LWIP_DEBUGF
Date: Wed, 30 Jan 2008 12:12:41 +0000
User-agent: Thunderbird 1.5.0.12 (X11/20070530)

Muhamad Ikhwan Ismail wrote:
> Hi..
> 
> I ported lwIP 1.2.0 into MPC852T running on SMX real time OS. It works
> really great and I would have to say its a great product.
> I have however 2 issues I could use some help with.
> 
> 1. I would like to know what happens internally within the stack and to
> the socket state if e.g. the cable is plugged out ? Will the pcb and the
> socket and conn be
> automatically closed after certain interval ? I was thinking of
> implementing on the tcpip thread a timeout with a handler, which
> monitors this by counting the carrier sense losses errors
> during the interval of the timeout in transmitted frames. The handler
> will in case of a high volume of carrier sense loss error set a certain
> global flag, and all application
> instead of using while(1) loop will use (while this flag not set). This
> would work if  the application is running, not waiting on read  or
> connect, which is why I wanna know
> what happens to the listen pcb e.g. when the connection is plugged out.

What Kieran said. Also from 1.3.0, it is possible for low-level drivers to
indicate the link status using a flag NETIF_FLAG_LINK_UP. The stack does
not behave differently depending on this flag though - there is a
difference between whether an interface is logically up and physically up.

Whether a driver supports this flag depends entirely on the driver. Only
recent driver implementations will have it (and maybe not even then).

> 2. I had a massive problem using LWIP_DEBUGF due to the way my compiler
> interpretes the macro invokation.
> 
> in debug.h #  define LWIP_DEBUGF(debug,x) do { if (((debug) & DBG_ON) &&
> ((debug) & DBG_TYPES_ON) && ((s16_t)((debug) & DBG_MASK_LEVEL) >=
> DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT)
> while(1); } } while(0)
> 
> and in any of the invokation the x is a string with the formats in a
> closed bracket e.g.  LWIP_DEBUGF1(UDP_DEBUG, ("udp_input: received
> datagram of length %"U16_F"\n", p->tot_len));
> and my compiler interprets x as ("udp_input: received datagram of length
> %"U16_F"\n", p->tot_len) including the brackets. In my case I need to
> convert this to a string using sprintf

The idea is that LWIP_PLATFORM_DIAG is defined as something like:
#define LWIP_PLATFORM_DIAG(_x_) do { printf _x_; } while (0)

Note the absence of brackets after the printf.

Given you want to use sprintf, in your environment it would be better to
use vsprintf specifically in fact, with something like:
#define LWIP_PLATFORM_DIAG(_x_) do { my_printf _x_; } while (0)

and you would write my_printf as something like:
int my_printf(const char *fmt, ...)
{
   int ret;
   va_list va;
   va_start(va, fmt);
   ret = vsprintf(some_buffer, fmt, va);
   va_end(va);
   return ret;
}

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
Visit us @ Embedded World 2008, Nürnberg, Germany, 26-28 Feb:Stand 11-336
------["Si fractum non sit, noli id reficere"]------       Opinions==mine




reply via email to

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