Rockwell Automation 1771-DMC_DMC1_DMC4_DXPS Control Coprocessor User Manual User Manual
Page 234

API Library of Routines
Appendix B
MSG_WAIT
B-103
w_rslt_mask
Bit map of the results from the requested write message instructions.
Bit 0 = message 0; bit 31 = message 31. If the bit is set, this message
has completed I/O or has timed out.
Returns
Status
Symbolic Name
Meaning
0
CC_SUCCESS
Operation successful
Description
Use MSG_WAIT to wait for one or more asynchronous message
operations to complete. MSG_WAIT will check for the completion of any
combination of pending read/write message numbers. The message
numbers are encoded in a read and write mask. The corresponding
message entry is checked for I/O completion. If the message has
completed, the iostat entry for that message is updated and the
corresponding bit in the read/write result mask is set. If none of the
requested messages have completed I/O and the sync parameter is 0, this
function will return immediately to the caller (asynchronous).
Otherwise, this function will wait until at least one of the requested
messages has completed.
Important: If both r_mask and w_mask are 0 or if none of the messages
for which bits are set were requested, the calling process will wait forever
(only if sync=1).
C Example
@_sysedit: equ 1 /* Edition 1. */
@_sysattr: equ 0x8000 /* Revision 00 (re-entrant 0x80 << 8 + revision 00) */
#include
main ()
{
int read_var,write_var,one_shot,iostat,status;
unsigned rm,wm,ret_rm,ret_wm;
read_var = 1;
one_shot = 42;
CC_INIT(); /* initialize copro */
status = MSG_ZERO_MASK(&rm); /* clear out read and write masks */
status = MSG_ZERO_MASK(&wm);
status = MSG_SET_MASK(&rm,0); /* wait for read msg 0 & 1, write msg 1 */
status = MSG_SET_MASK(&rm,1);
status = MSG_SET_MASK(&wm,1);
/* post initial message handlers */
status = MSG_READ_HANDLER ( &one_shot, sizeof (one_shot), 1, 1, 45,
CC_LONG, PLC_WORD, &iostat);
status = MSG_READ_HANDLER ( &read_var, sizeof (read_var), 0, 1, 45,
CC_LONG, PLC_WORD, &iostat);