This function enables/disables a device on the EtherCAT line.
Note: In order to enable/disable the device, the line must be in the INIT state(ecat_set_state(nEth, 1)).
|
i32 ecat_dev_on_off (i32 nEth, i32 cfgAddr , bool sts)
|
|
Ethernet channel number
|
|
Device address
|
|
Desired status:
|
|
TRUE
|
Device enabled
|
FALSE
|
Device not enabled
|
|
|
Returns:
|
|
0
|
Operation completed
|
-1
|
Illegal Ethernet channel number
|
-2
|
Ethernet channel is not EtherCAT
|
-3
|
EtherCAT not in INIT state
|
-4
|
No device in the selected location
|
-5
|
EtherCAT line not properly configured
|
-6
|
Internal sw error. (contact Robox)
|
|
|
Task
|
|
|
Example of use:
FUNCTION int Ecat_Change_Config(int nEth, int addr, bool sts, bool restartEcat, int@ phase)
select(phase)
default
phase = -2
case -2
return -2
case -3
return -3
case -1
return -1
case 0
_if(nEth = 0)
nEth = -1
esitoECC = ecat_set_state(nEth, 1)
if (esitoECC = 0)
phase = 1
endif
return 0
case 1
if(ecat_get_state(nEth) <> 1)
return 0
endif
esitoECC = ecat_dev_on_off(nEth, addr, sts)
if(esitoECC < 0)
phase = -1
return -1
endif
phase = 2
case 2
if(not restartEcat)
return 1
endif
esitoECC = ecat_set_state(nEth, 8)
if(esitoECC = 0)
phase = 3
ecatTimeOut = tfb + 10
endif
return 0
case 3
ecatState = ecat_get_state(nEth)
if(ecatState = 1)
if(tfb < ecatTimeOut)
return 0
endif
phase = -3
return -3
endif
if(ecatState <> 8)
return 0
endif
alarm_reset(18, 0)
alarm_reset(82)
alarm_reset(83)
phase = 4
case 4
return 2
end_select
return -2
END_FUN
|
|