ipcfg_get_link_active not working

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ipcfg_get_link_active not working

837 Views
vines
Contributor III

Hi,

When I used the following code the function works correctly. It will trap the sequence as long as cable is disconnected. Once I connect the cable it will exit my while loop.

error = RTCS_create();

if (error != 0)

     _task_block();

if ((ipcfg_init_device(BSP_DEFAULT_ENET_DEVICE, enet_address)) != IPCFG_OK)

     _task_block();

while((ipcfg_get_link_active(BSP_DEFAULT_ENET_DEVICE) == FALSE))

     _time_delay(100);

However if I use the below code it is not working. It is always on the _time_delay whether I plug in/out my cable.

error = RTCS_create();

if (error != 0)

     _task_block();

if (ENET_initialize(BSP_DEFAULT_ENET_DEVICE, enet_address, 0, &ehandle) != ENET_OK)

     _task_block();

if (RTCS_if_add(ehandle, RTCS_IF_ENET, &ihandle) != RTCS_OK)

     _task_block();

if (RTCS_if_bind(ihandle, ip.ip, ip.mask) != RTCS_OK)

     _task_block(); 

while((ipcfg_get_link_active(BSP_DEFAULT_ENET_DEVICE) == FALSE))

     _time_delay(100);

I am wondering why it is not working when I used the latter code compare to the first code. Do I need to set anything?

Thanks.

0 Kudos
2 Replies

481 Views
vines
Contributor III

I think I know why this is not working.

Tracing back to the function ipcfg_get_link_active in RTCS

{

if (ipcfg_data[device].actual_state != IPCFG_STATE_INIT)

            return ENET_link_status (((IP_IF_PTR)(ipcfg_data[device].ihandle))->HANDLE);

}

return false;

actual_state is always in IPCFG_STATE_INIT state in the second code. Thus, it won't enter the ENET_link_status checking. It will always return FALSE.

Now actual_state value is modified in ipcfg_init_interface which is being called by ipcfg_init_device. That is the reason the first code is working because actual_state is no longer in IPCFG_STATE_INIT. It is already in IPCFG_STATE_UNBOUND state.

However my question is why is MQX designed such a way? Is there a work around to initiate the handle without using ipcfg_init_device? I would rather do it in the application layer if there is an API, rather than changing something on the hardware layer. Is ipcfg_get_link_active only bounded in high level network management commands IPCFG?

Thanks.

0 Kudos

481 Views
vines
Contributor III

Solve! Just used ENET_link_status instead. I guess this is not designed to be used in APP layer because it is not included on RTCS documentation at least on my MQX version.

0 Kudos