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

Page 152

Advertising
background image

Appendix A

Sample Applications

A-30

// Make certain the processor is in remote program mode
plc_in_remote_program_mode();

// Make certain there are no faults...
check_for_faults();

// Issue the download all request.
download_all();

// Let’s read the file ”bucket”...
memset((char *) &filePacket, 0x0, sizeof(FILE_PACKET_TYPE));

// Now let’s attempt to read the first filePacket...
moreFilePackets = fread((char *) &filePacket, 1,

sizeof(FILE_PACKET_TYPE), in);

// While there are filePackets to process... Let’s do them!
while (moreFilePackets)
{
// Let’s download each kWriteSize chunk of memory from the
// file to the PLC.
write_filepacket_to_plc(&filePacket, writeCounter);
writeCounter++;

// Let’s clear and read the file ”bucket”...
memset((char *) &filePacket, 0x0, sizeof(FILE_PACKET_TYPE));
moreFilePackets = fread((char *) &filePacket, 1,

sizeof(FILE_PACKET_TYPE), in);

}

// Close the input file
fclose(in);

// Download Complete command.
download_is_complete();

// Get the edit resource from the processor.
get_edit_resource();

// Apply the port configuration
apply_port_configuration();

// Return the edit resource to the processor.
return_edit_resource();

printf(”\n\nDownload was successfully completed.”);

return 0;

}

/***************************************************************************/
/*************************** PRIVATE FUNCTIONS *****************************/
/***************************************************************************/

/***************************************************************************/
/*************************** GET_EDIT_RESOURCE *****************************/
/***************************************************************************/
void get_edit_resource(void)
{
// This function will ask the processor for the edit resource.

PLC540V_PCCC_GER_RPY_TYPE replyPacket;
PLC540V_STATUS_TYPE status;

Advertising