Returns, Description, C example – Rockwell Automation 1771-DMC_DMC1_DMC4_DXPS Control Coprocessor User Manual User Manual
Page 242
API Library of Routines
Appendix B
MSG_WRITE_W_HANDLER
B-111
Returns
Status
Symbolic Name
Meaning
0
CC_SUCCESS
Operation successful
124
CC_E_FAIL
I/O completed with errors
133
CC_E_BAD_MSGID
Message ID out of range
157
CC_E_NOTCONNECT
PLC is not connected or offline
160
CC_E_INV_TO
Invalid timeout value
162
CC_E_INV_CTYPE
Invalid coprocessor data type
163
CC_E_INV_PTYPE
Invalid PLCĆ5 data type
181
CC_E_MSGPEND
Message already pending
182
CC_E_MSG_ABORT
Message aborted
190
CC_E_SIZE
Invalid size for operation
191
CC_E_TOOSMALL
Size of buffer too small
Description
Use the MSG_WRITE_W_HANDLER function to initiate the processing
of unsolicited message-write instructions from the PLC-5 programmable
controller. This function puts an entry in the Message Control Table
(MCT) for the requested message number (0-31). When the PLC-5
programmable controller executes that message number, data from the
PLC-5 programmable controller is transferred to the specified user buffer.
This function is synchronous. When this function is initiated, the
application program stops until the function completes or fails. For the
asynchronous version of this command, see MSG_WRITE_HANDLER.
C Example
.
.
.
short variable [4]
/* buffer to receive write data */
unsigned timeout = 45;
/* 45 second timeout */
unsigned msgnum = 10;
/* plc message number 10 */
unsigned cc_type = 3;
/* CC_WORD = 3; */
unsigned plc_type = 3;
/* PLC_WORD = 3; */
unsigned items = 4;
/* 4 words of data to be written by PLC-5 */
int iostat;
/* iostatus return value */
int rtn_val;
/* function return value */
rtn_val = MSG_WRITE_W_HANDLER (&variable, sizeof (variable), msgnum, items,
timeout, cc_type, PLC_type, &iostat);
.
.
.