Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12599 Discussions

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

Honored Contributor II



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. 



0 Kudos
1 Reply
Honored Contributor II

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

0 Kudos