ConnectME - Is the network cable plugged in?

I’ve tried using customizeMiiCheckLink to check if a network cable is attached, and recently switched to naEthGetPhyStatus instead. Both have a fatal flaw. They both often cause my system to crash if you pull the network plug. It happens probably 75% of the time. My code is in a loop looking for incoming network messages or incoming serial messages, and checks the link status once each time through the loop. My guess is that pulling the cable during the check is what causes it to crash, and why sometimes it does and sometimes it doesn’t.

Anyone else seen this? Anyone have a better way to check if my network connection is up and connected?

I found naEthRegisterLinkStatusCallback (NET+OS 7.0 only). It seems to be better, but I still get crashes occasionally. This is very frustrating.

Just a brainstorm (I just check at startup), but how about just checking for data, and only doing the disconnect check when there is no data for a set amount of time (say 5 seconds)? That will give things a chance to stabilize before doing the disconnect check. It would be very rare to have the crash then…

-Erik

It’s not a very busy network. It’s a vending machine, and there is only traffic when there is a sale in progress, or if sales data is being pulled. The main reason for checking is to change the idle message of the device so that the customer doesn’t even bother to try when the network is down.

However, it looks like I may have been hasty on blaming the code. I moved to another board and the problem went away. I could plug and unplug at will without a crash. I think the board I’d been using for a long time had developed a cold solder joint (well, it must have had it all along, but you know what I mean). I’d not had trouble with it for a long time, but just when I needed to test transactions handling a network disconnect, of course that’s when it fails on me. I’m more the type to blame software first, especially when I’ve been using a piece of hardware for months without trouble.

Cool… A vending machine that takes plastic… Finally!