Function that imposes the NMT operating mode of the indicated EtherCAT line.
|
i32 ecat_set_state (i32 nEth, i32 desState [, bool doBopex=FALSE])
|
|
EtherCAT line number.
If 0 means all EtherCAT lines present.
|
|
State of the network you wish to impose:
|
|
1
|
INIT
|
2
|
PREOPERATIONAL
|
4
|
SAFEOPERATIONAL
|
8
|
OPERATIONAL
|
|
|
Se uguale a TRUE, attende di essere in SAFEOPERATIONAL prima di eseguire il file comandi bopex.stp. Altrimenti non verrà eseguito il file. (opzionale, default FALSE)
|
|
Returns:
|
|
2
|
OK:
SAFEOPERATIONAL reached, bopex.stp executed
|
1
|
OK:
SAFEOPERATIONAL achieved, bopex.stp not present
|
0
|
OK:
desired state imposed
|
-1
|
EtherCAT line index illegal
|
-2
|
Ethernet port not configured EtherCAT
|
-3
|
Illegal status code
|
-4
|
Network not started due to configuration error. (use mreport -a)
|
-5
|
Function used not in a timesharing task with doBopex TRUE flag.
|
-6
|
Timeout for waiting for SAFEOPERATIONAL status to then execute bopex.stp: operation not executed
|
|
|
Rule, Task
|
|
|
Example of use:
....
result = ecat_set_state(2, 1)
if (result < 0)
alarm_set(UNABLE_TO_SET_ECAT, 0, 1)
return
endif
result = ecat_set_state(2, 8)
if (result < 0)
alarm_set(UNABLE_TO_SET_ECAT, 0, 2)
return
endif
mt_wait(ecat_get_state(2) = 8 )
...
|
NOTE: This example can only be used in the task, as the mt_wait() instruction is used.
|