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

Page 146

Advertising
background image

Appendix A

Sample Applications

A-24

printf(”\n\tSegment 1 Start Pointer: %x %x %x %x”,

replyPointer->optionalData[1],
replyPointer->optionalData[2],
replyPointer->optionalData[3],
replyPointer->optionalData[4]);

printf(”\n\tSegment 1 End Pointer: %x %x %x %x”,

replyPointer->optionalData[5],
replyPointer->optionalData[6],
replyPointer->optionalData[7],
replyPointer->optionalData[8]);

printf(”\n\tCompare 1 lng: %x”, replyPointer->optionalData[9]);
printf(”\n\tCompare 1 Start Pointer: %x %x %x %x”,

replyPointer->optionalData[10],
replyPointer->optionalData[11],
replyPointer->optionalData[12],
replyPointer->optionalData[13]);

printf(”\n\tCompare 1 End Pointer: %x %x %x %x”,

replyPointer->optionalData[14],
replyPointer->optionalData[15],
replyPointer->optionalData[16],
replyPointer->optionalData[17]);

printf(”\n\nUploading Log:\n”);

}

/***************************************************************************/
/*************************** READ_PLC_TO_FILE ******************************/
/***************************************************************************/
void read_plc_to_file(unsigned long readAddr, FILE *out,

unsigned short readSize, unsigned short readCount)

{

// Read the specified memory and write it to the output file.

PLC540V_STATUS_TYPE status;
PLC540V_PCCC_RBP_RPY_TYPE replyPacket;
FILE_PACKET_TYPE filePacket;

// Initialize the file packet
memset((char *) &filePacket, 0x0, sizeof(FILE_PACKET_TYPE));

// Display the address we are reading.
printf(”\n\tCnt: %d, Uploading Address: 0x%08.8lx, Size: %d”,
readCount, readAddr, readSize);

// Send the read command and wait for the reply
plc540v_pccc_read_bytes_physical(kvmeSlaveAddress,

kplc540vUla,
kVME_D16_DATA_WIDTH,
kVME_A24_ADDR_SPACE,
readAddr,
readSize,
&replyPacket,
&status);

if (status.plc540vStatus != 0)
{

printf(”\n%s %s 0x%08.8lx”,
”Read Bytes Physical reply failed”,
”at address:”,
readAddr);
exit(1);

}
else
{

// Write the read packet and address to
// the output file.

Advertising