WARNING: This function cannot be used in a task if the co_send_sdo()/co_asw_sdo() functions are also present in the task.
This function is used to perform writing of CoE fieldbus objects (information present in source is written).
It can write more data types than the analogous function co_wobj().
Writing can be done in pass-through mode or in blocking mode (usable only in tasks 1-:-8).
Pass-through mode means that the function must be continuously called and simultaneously tested the current state of the task.
Blocking mode means that the function is invoked and returns only when it has completed the write operation.
The function returns a result on the state of execution.
Syntax |
i32 coe_wobj (stru_coe_obj stru, source) |
---|---|
stru |
Structure name of type stru_coe_obj |
source |
Data contained in source will be taken according to the specified data type (if writing a VISIBLE STRING, source will be of type string, if writing an OCTET_STRING, source will be a byte array or structure) |
Result |
Variable of type i32 containing the result. See pass-through mode and/or blocking mode |
Validity |
Rule, Task |
Note |
•Set stru.phase = 1 to initialize the write •The command to write the source value is sent to the remote device and a response is expected. The variable stru.phase is changed. •Waiting for response. •Receiving response with positive result. The value read is written to source. RTE changes stru.phase = 4. •Receive response with negative result. RTE changes stru.phase = 0. o-2, communication handler busy o-3, communication handler crash (restart) o-5, command to a device not present(stru.rid) o-6, no operation running. stru.phase not initialized o-12, illegal value of objcode(alarm 9900 arg 12) o-13, illegal value of subindex (alarm 9900 arg 13) o-14, illegal value of datatype (alarm 9900 arg 4/arg 14) o-15, illegal value of datalen (alarm 9900 arg 5/arg 15) o-16, illegal value of phase (alarm 9900 arg 6) o-21, source not specified (NULL) (alarm 9900 arg 16) o-22, source changed (phase execution) (alarm 9900 arg 32) o2, command for which a positive response has already been received, value available in source o>2, SDO error code, see table below |
•Set stru.phase = -1 to execute the write •The command to write the source value is sent to the remote device and a response is expected. The variable stru.phase is changed •Waiting for response. If the response does not arrive within a maximum of 3 seconds, the function exits with an error (timeout, returns -2) •Receiving response with a positive result. The value read is written to source. RTE changes stru.phase = 4. •Receive response with negative result. RTE changes stru.phase = 0. o-2 communication handler busy o-3 communication handler crash (restart) o-4 blocking mode not allowed in current task(stru.phase = 1) (rule, ladder). Command not accepted o-5 command to a device not present(stru.rid) o-6 no task running. stru.phase not initialized o-12 illegal objcode value(alarm 9900 arg 12) o-13 illegal value of subindex (alarm 9900 arg 13) o-14 illegal value of datatype (alarm 9900 arg 4/arg 14) o-15 illegal value of datalen (alarm 9900 arg 5/arg 15) o-16 illegal phase value (alarm 9900 arg 6) o-21 source not specified (NULL) (alarm 9900 arg 16) o-22 source changed (phase execution) (alarm 9900 arg 32) o2 command for which a positive response has already been received, value available in source o>2 SDO error code, see table below |
Example of use:
|