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

Page 151

Advertising
background image

Appendix A

Sample Applications

A-29

/*****************************************************************************
*
* PURPOSE: This is the main function for the download demonstration
* program. This program implements the algorithm to
* successfully restore the entire physical processor memory of
* the PLC-5/40V from a disk file on the Radisys EPC-4. Please
* note that this implementation will also restore the saved
* port configurations.
*
* INPUT: You must supply a filename on the command line. This name
* is the image of processor memory which was created using
* the upload sample application.
*
* OUTPUT: When this program exits to the shell (under normal and error
* conditions), it will have restored the processor’s memory
* and port configurations.
*
* RETURNS: This program will return 1 to the DOS shell if there is an
* error and 0 if the program completed normally.
*
* EXAMPLE:
* download procmem.sav <CR>
*
* where:
* procmen.sav is the processor image file
* <CR> is a carrage return
*
* BUILD ENVIRONENT:
*

Borland C++ 3.0 compiler

*

Use the DOWNLOAD.MAK makefile to build the executable.

*
* EDIT HISTORY:
*
* Copyright Allen-Bradley Company, Inc. 1994
*
****************************************************************************/
main(int argc, char *argv[])
{

// A ”bucket” of information from the physical save image file.
FILE_PACKET_TYPE filePacket;

// A counter of the number of writes being done.
UWORD writeCounter = 1;

// The output file pointer
FILE *in;

// A flag indicating that more filePackets exist to be read from
// the input file.
int moreFilePackets = 0;

// Validate the command line...
if (argc != 2)
{

printf(”\nUSAGE: download save_file_name”);
exit(1);

}

// Open the input file for restoring PLC memory.
if ((in = fopen(argv[1], ”r+b”)) == NULL)
{

printf(”\n\nFailed to open %s file”, argv[1]);
exit(1);

}

Advertising