EmbeddedRelated.com
Forums

unplug Ethernet cable, ifstatus() and ifpending() don't return the error

Started by Tecnowatt - Massimo Sala March 24, 2005
Hi

I am using a RCM2110.

I code a small "server", it opens a Tcp socket in listen.
Until a client connects to the Rabbit, it doesn't transmit/receive packets.

So the application has to check the Ethernet connectivity. I unplug the Ethernet cable from the RCM2110 RJ45 socket, the network LED
turns off, but the two APIs ifstatus() and ifpending() don't return the
error.
I tried both ways : under the Dynamic C 9.21 environment, and also with the
application running stand-alone.
Also the event error handling (instead of polling with ifstatus() and
ifpending() ), is unsuccesfull:

in the main(), at startup:

ifconfig(IF_ETH0,
IFS_DOWN,
IFS_IPADDR, aton("192.168.10.100"),
IFS_NETMASK, aton("255.255.255.0"),
// IFS_ROUTER_SET, aton("192.168.10.1"),
IFS_IF_CALLBACK, &ifcallback,
IFS_UP,
IFS_END);
ifcallback is this function:

void ifcallback(int iface, int up)
{
if (up == 0)
{
logg("ifcallback", LOG_STATUS_error);
forceSoftReset();
}
}
Any suggestion ?

ciao, Massimo


On Mar 24, 2005, at 3:26 PM, Tecnowatt - Massimo Sala wrote:
> I unplug the Ethernet cable from the RCM2110 RJ45 socket, the network
> LED
> turns off, but the two APIs ifstatus() and ifpending() don't return
> the
> error.
> I tried both ways : under the Dynamic C 9.21 environment, and also
> with the
> application running stand-alone.

if_havelink() should tell you if the networking cable is unplugged.

--
Tom Collins - tom@tom@...
QmailAdmin: http://qmailadmin.sf.net/ Vpopmail: http://vpopmail.sf.net/
You don't need a laptop to troubleshoot high-speed Internet:
sniffter.com


> On Mar 24, 2005, at 3:26 PM, Tecnowatt - Massimo Sala wrote:
>> I unplug the Ethernet cable from the RCM2110 RJ45 socket, the network
>> LED
>> turns off, but the two APIs ifstatus() and ifpending() don't return
>> the
>> error.


> Tom Collins - tom@tom@...
> if_havelink() should tell you if the networking cable is unplugged.


Tom, many thanks for your answer.

However both in the Dynamic C printed manual and also hitting [CTRL] [H] I
cannot find any if_ function...

Is there a mistype ? I already tried with pd_havelink(), but it doesn't seem to work.

I unplug the Ethernet cable, the return code is still != 0 (link
established), also after about one minute.

Possibilities:
- the timeout is very long... how much ?

- the Rabbit tcp/ip stack tests the NIC status only if certain operations
are called (for example, tx or rx data on socket ?).

I have to check the NIC status also when my app is idle on the sockets but
doing other tasks... I am using Dynamic C 9.21.

ciao, Massimo


The function Tom was referring to is pd_havelink(). I
have occasional problems with pd_havelink() as well.
But I've come to the conclusion that its not the
function but the core module. I will occasionally get
a core module where pd_havelink() always returns true
whether a cable is connected or not, which causes
havic with my program. I throw the board away and grab
another and it works fine. In my opinion, its a
hardware problem on the core module. But because the
core modules are so cheap, and the failures so few,
its not worth the time and money to go beyond throwing
them away - at least for us.

Steve --- Tecnowatt - Massimo Sala
<massimo.sala@mass...> wrote:
> > On Mar 24, 2005, at 3:26 PM, Tecnowatt - Massimo
> Sala wrote:
> >> I unplug the Ethernet cable from the RCM2110
> RJ45 socket, the network
> >> LED
> >> turns off, but the two APIs ifstatus() and
> ifpending() don't return
> >> the
> >> error. > > Tom Collins - tom@tom@...
> > if_havelink() should tell you if the networking
> cable is unplugged. > Tom, many thanks for your answer.
>
> However both in the Dynamic C printed manual and
> also hitting [CTRL] [H] I
> cannot find any if_ function...
>
> Is there a mistype ? > I already tried with pd_havelink(), but it doesn't
> seem to work.
>
> I unplug the Ethernet cable, the return code is
> still != 0 (link
> established), also after about one minute.
>
> Possibilities:
> - the timeout is very long... how much ?
>
> - the Rabbit tcp/ip stack tests the NIC status only
> if certain operations
> are called (for example, tx or rx data on socket ?).
>
> I have to check the NIC status also when my app is
> idle on the sockets but
> doing other tasks... > I am using Dynamic C 9.21.
>
> ciao, Massimo



On Mar 29, 2005, at 1:13 PM, Steve Trigero wrote:
> The function Tom was referring to is pd_havelink().

Thanks for the correction.

> I
> have occasional problems with pd_havelink() as well.
> But I've come to the conclusion that its not the
> function but the core module. I will occasionally get
> a core module where pd_havelink() always returns true
> whether a cable is connected or not, which causes
> havic with my program. I throw the board away and grab
> another and it works fine. In my opinion, its a
> hardware problem on the core module. But because the
> core modules are so cheap, and the failures so few,
> its not worth the time and money to go beyond throwing
> them away - at least for us.

I have found that you may need to delay for 1/2 to 1 second after
initializing the ethernet interface before pd_havelink() will report
accurate results.

I have not run into problems with it always returning true on the
RCM2200s I've used. Then again, I'm not sure I've thoroughly tested
that assumption. I'll start watching for it in my Q.C.

--
Tom Collins - tom@tom@...
QmailAdmin: http://qmailadmin.sf.net/ Vpopmail: http://vpopmail.sf.net/
You don't need a laptop to troubleshoot high-speed Internet:
sniffter.com


I wait 5-seconds from when I first initialize ethernet to when I start checking pd_havelink(). We are only using the RCM3000 for ethernet, the RCM2200's may be more robust in this area.
Like I said, its not a big problem, in that only a few boards have had the problem. But each time pd_havelink()  gave false status replacing the core module solved the problem.
 
Steve

Tom Collins <t...@tomlogic.com> wrote:
On Mar 29, 2005, at 1:13 PM, Steve Trigero wrote:
> The function Tom was referring to is pd_havelink().

Thanks for the correction.

>  I
>  have occasional problems with pd_havelink() as well.
>  But I've come to the conclusion that its not the
>  function but the core module. I will occasionally get
>  a core module where pd_havelink() always returns true
>  whether a cable is connected or not, which causes
>  havic with my program. I throw the board away and grab
>  another and it works fine. In my opinion, its a
>  hardware problem on the core module. But because the
>  core modules are so cheap, and the failures so few,
>  its not worth the time and money to go beyond throwing
>  them away - at least for us.

I have found that you may need to delay for 1/2 to 1 second after
initializing the ethernet interface before pd_havelink() will report
accurate results.

I have not run into problems with it always returning true on the
RCM2200s I've used.  Then again, I'm not sure I've thoroughly tested
that assumption.  I'll start watching for it in my Q.C.

--
Tom Collins  -  t...@tomlogic.com
QmailAdmin: http://qmailadmin.sf.net/  Vpopmail: http://vpopmail.sf.net/
You don't need a laptop to troubleshoot high-speed Internet:
sniffter.com