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

Page 170

Advertising
background image

Sample API Modules

Appendix B

B-12

/*****************************************************************************
*
* PURPOSE: This function will continually poll the command block’s
* response word to determine when the PLC-5/40V has completed
* processing a command. When the response word becomes
* non-zero OR if we time out then this function will return
* to the caller.
* INPUT: ULONG vmeCmdBlkAddr contains the VME address of the command
* block.
* VME_ADDRESS_MODIFIER_TYPE addrSpace contains an indicator
* as to which address space contains the command block.
* OUTPUT: PLC540V_STATUS_TYPE *status will contain the final status
* of requesting this function. This status could be and EPC
* or PLC-5/40V value.
* RETURNS: Nothing.
* EXAMPLE: ULONG vmeCmdBlkAddr = 0x80000;
* VME_ADDRESS_MODIFIER_TYPE addrSpace = kVME_A24_ADDR_SPACE;
* PLC540V_STATUS_TYPE *status;
* poll_plc540v_until_response(vmeCmdBlkAddr,
* addrSpace,
* &status);
* Copyright Allen-Bradley Company, Inc. 1993
*
****************************************************************************/
void poll_plc540v_until_response(ULONG vmeCmdBlkAddr,

VME_ADDRESS_MODIFIER_TYPE addrSpace,
PLC540V_STATUS_TYPE *status)

{
/* Poll the response word until it is non-zero. */
ULONG i;

/* The value read from the response word in the command block. */
UWORD response = 0;

/* Let’s initialize the status variable to success. */
memset((char *) status, 0x0, sizeof(PLC540V_STATUS_TYPE));

/* Loop until we timeout or the response word is non-zero. */
for (i=0;

((i<kTIMEOUT_COUNT) && (status->plc540vStatus == kPLC540V_SUCCESS));
i++)

{

status->epcStatus = EpcFromVmeAm((UWORD) (BM_MBO|addrSpace),

BM_W16,
vmeCmdBlkAddr+2,
(char far *) &response,
sizeof(UWORD));

if (status->plc540vStatus == kPLC540V_SUCCESS)
{
/* Determine if the reponse word has been changed. */
if (response != kPLC540V_DEFAULT_RESPONSE)

break;

}

}

if (i > kTIMEOUT_COUNT)
{

/* Signal that we timed out. */
status->plc540vStatus = kPLC540V_RESPONSE_TIMEOUT;
status->statusCategory = kPLC540V_STATUS;

}
}

Advertising