Basic example, References – Rockwell Automation 1771-DMC_DMC1_DMC4_DXPS Control Coprocessor User Manual User Manual
Page 235

API Library of Routines
Appendix B
MSG_WAIT
B-104
status = MSG_WRITE_HANDLER ( &write_var, sizeof (write_var), 1, 1, 45,
CC_LONG, PLC_WORD, &iostat);
while (1)
{
status = MSG_WAIT (rm,wm,1,&ret_rm,&ret_wm); /* wait for either message */
if (MSG_TST_MASK (&ret_rm,1)) /* read msg 1 completed - one_shot */
{
printf (”One shot data was read\n”);
status = MSG_CLR_MASK(&rm,1); /* dont wait for it any more */
}
if (MSG_TST_MASK (&ret_rm,0)) /* read msg 0 completed */
{
printf (”Read message 0 occurred\n”);
status = MSG_READ_HANDLER ( &read_var, sizeof (read_var), 0, 1, 45,
CC_LONG, PLC_WORD, &iostat);
}
if (MSG_TST_MASK (&ret_wm,1)) /* write msg 1 completed */
{
printf (”Write message 1 occurred\n”);
status = MSG_WRITE_HANDLER ( &write_var, sizeof (write_var), 1, 1,
45, CC_LONG, PLC_WORD, &iostat);
}
}
}
BASIC Example
The BASIC function code is 48.
DIM status : INTEGER
DIM iostat : INTEGER
DIM rm : INTEGER
DIM wm : INTEGER
DIM ret_rm : INTEGER
DIM ret_wm : INTEGER
.
.
.
rem * MSG_WAIT - wait for completion of messages based on bit pattern
rem * in rm (read mask) and wm (write mask). The value 1
rem * indicates that this function will wait until at least
rem * one of the requested messages is complete. The results
rem * of the wait are stored in ret_rm (read) and ret_wm (write).
RUN AB_BAS (48,status,rm,wm,1,ADDR(ret_rm),ADDR(ret_wm))
.
.
.
References
MSG_READ_HANDLER(); MSG_WRITE_HANDLER();
MSG_SET_MASK(); MSG_CLR_MASK(); MSG_TST_MASK();
MSG_ZERO_MASK();