Appendix b – Rockwell Automation 1785-Vx0B, D17856.5.9 PLC-5 VME VMEbus Programmable Controllers User Manual User Manual
Page 196

Sample API Modules
Appendix B
B-38
/* Let’s initialize the status variable to success. */
memset((char *) status, 0x0, sizeof(PLC540V_STATUS_TYPE));
/* Build the command block. */
hintCmdBlk.commandWord = hintCmd;
hintCmdBlk.responseWord = 0;
hintCmdBlk.cmdIntLevel = cmdIntLevel;
hintCmdBlk.cmdStatusId = cmdStatusId;
hintCmdBlk.transferInfo.enable = hintMode;
hintCmdBlk.operationIntLevel = operationIntLevel;
hintCmdBlk.operationStatusId = operationStatusId;
/* Copy the command block to VME memory. */
status->epcStatus = EpcToVmeAm((BM_MBO|A24SD),
BM_W16,
(char far *) &hintCmdBlk,
vmeCmdBlkAddr,
sizeof(PLC540V_HINT_CMD_TYPE));
if (status->epcStatus == EPC_SUCCESS)
{
/* Send the command block address to the PLC-5/40V’s command
register.
*/
plc540v_send_cmd(baseAddress, vmeCmdBlkAddr,
kVME_A24_ADDR_SPACE,
status);
if (status->plc540vStatus == kPLC540V_SUCCESS)
{
/* If sending the command block address didn’t fail, then the
PLC-5/40V has started processing the command.
If the user of this function hasn’t set up any VME interrupts
to be generated, then we will poll the PLC-5/40V until the
its done processing the command. This is indicated by a
non-zero value in the response word of the command block.
If the user has set up VME interrupts, then we will simply
return to the caller.
*/
if ((cmdIntLevel == kVME_NO_INT_LEVEL) &&
(operationIntLevel == kVME_NO_INT_LEVEL))
{
/* Let’s poll the PLC-5/40V until its done. */
poll_plc540v_until_response(vmeCmdBlkAddr,
kVME_A24_ADDR_SPACE,
status);
}
}
}
else
{
/* Signal that we have an EPC error. */
status->plc540vStatus = kPLC540V_COPY_CMDBLK_TO_VME_FAILED;
status->statusCategory = kEPC_STATUS;
}
}