[En-Nut-Discussion] detecting an unplugged network cable

elbric0 elbric0 at f-m.fm
Mon Nov 8 15:15:26 CET 2010


Hi!

Thanks for your answers. It's a good idea to run network stuff in a thread. However I still have a problem with NutRegisterDevice. When the network cable is unplugged, it takes a little more than three minutes before it returns an error. And it doesn't seems to yield the cpu as long as it is running. 

I have this code in my network thread:

NutThreadSetPriority(128);    
while (NutRegisterDevice(&DEV_ETHER, 0, 0)) 
{
        puts("\tFailed. Retrying in 10 sec.");
        NutSleep(10000);	/* Sleep for 10 sec */
}

I didn't change the priority of the main task. So I assume it is 64. The main task should print the time every minute. 

When the network cable is unplugged, the "Failed" message and the time are both printed every 3 minutes. So I am quite sure that NutRegisterDevice blocks for all that time.

Is it the normal behavior?

Best regards

Jasmin


Le 2010-11-08 à 06:16, Ulrich Prinz a écrit :

> Hi!
> 
> The driver itself detects that fact and does not start ethernet. To not 
> get blocked by DHCP you should run DHCP as a thread. The httpd example 
> is not a good reference or that, I think.
> I am actually reworkign that part... The new PHY driver can give you 
> the information if the cable is connected. But it can take a while for 
> AutoNegotiation to link up and you have to wait that time until the 
> system times out....
> 
> Nope, the best way is to start network an DHCP in a thread. Anything 
> else doesn't work.
> 
> Best Regards
> Ulrich
> 
> 
> -----Original Message-----
> From: elbric0 <elbric0 at f-m.fm>
> To: en-nut-discussion at egnite.de
> Sent: Mon, Nov 8, 2010 1:47 am
> Subject: [En-Nut-Discussion] detecting an unplugged network cable
> 
> 
> Hi,I would like to detect if a network cable is unplugged at boot time 
> and skip everything related to network when it is the case. 
> NutRegisterDevice(&DEV_ETHER, 0, 0) returns an error after a long while 
> when the cable is unplugged. It is possible to use that, but it is a 
> little annoying as is makes boot time quite long. Is there another way 
> to make the check or a way to make NutRegisterDevice return faster?Best 
> RegardsJasmin_______________________________________________http://lists.
> egnite.de/mailman/listinfo/en-nut-discussion
> 
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion




More information about the En-Nut-Discussion mailing list