Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
9 years ago

How to detect Ethernet cable connection before start a Network Interface?

Hello,

I am using Altera Cyclone-V and uC/OS-II OS & TCP/IP package building a Network Interface in this way:

  1. Call Net_Init();

  2. Call NetIF_Add();

  3. Call NetIF_Start();

  4. Call NetIPv4_CfgAddrAdd();

Everything works fine except if I by accident forgot to plug in the Ethernet cable. If the cable is missing, Step C NetIF_Start() will return “NET_PHY_ERR_TIMEOUT_AUTO_NET” error. This error is not recoverable even with the cable plugging back to the device. I will have to reboot the device.

Is there any way I can check the cable connection before Step C? I tried functions like NetIF_LinkStateGet(), NetIF_IO_Ctrl(), but they only report the Link status after the interface is established. BTW, the HW is done and I can’t physically check the Ethernet port status.

Another option is when function NetIF_Start() returns an error due to the missing of the cable, what is a correct procedure to re-initialize the Network interface and wait for the cable connection.

Thanks,

Chad

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I also met this issues if I plug out the cable. Immediately I plug in cable and can't PING the board.