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

Appendix A
Sample Applications
A-33
if (status.plc540vStatus != 0)
{
printf(”\nChecking the PLC for faults failed.”);
exit(1);
}
else
{
// Check for major faults...
if (replyPacket.plcStatus.majorFault != 0)
{
printf(”\nProcessor has major faults so we cannot continue.”);
exit(1);
}
// Check for bad RAM...
if (replyPacket.plcStatus.ramInvalid != 0)
{
printf(”\nProcessor has bad RAM so we cannot continue.”);
exit(1);
}
}
}
/***************************************************************************/
/*********************** WRITE_FILEPACKET_TO_PLC ***************************/
/***************************************************************************/
void write_filepacket_to_plc(FILE_PACKET_TYPE *filePacket, UWORD writeCounter)
{
// Write the file packet to the PLC.
PLC540V_STATUS_TYPE status;
PLC540V_PCCC_WBP_RPY_TYPE replyPacket;
// Display the address we are writing...
printf(”\n\tCnt: %d, Downloading Address: 0x%08.8lx, Size: %u”,
writeCounter, filePacket->plcAddress, filePacket->plcDataLength);
// Send the write command and wait for the reply
plc540v_pccc_write_bytes_physical(kvmeSlaveAddress,
kplc540vUla,
kVME_D16_DATA_WIDTH,
kVME_A24_ADDR_SPACE,
filePacket->plcAddress,
&filePacket->plcData[0],
filePacket->plcDataLength,
&replyPacket,
&status);
if (status.plc540vStatus != 0)
{
printf(”\n%s %s 0x%08.8lx”,
”Write Bytes Physical reply failed”,
”at address:”,
filePacket->plcAddress);
exit(1);
}
}
/***************************************************************************/
/************************** DOWNLOAD_IS_COMPLETE ***************************/
/***************************************************************************/
void download_is_complete(void)
{
// Tell the processor that the download is now completed.