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

Page 138

Advertising
background image

Appendix A

Sample Applications

A-16

// PLC-5/40V is using ULA0 which is 0xFC00
const unsigned short kplc540vUla = 0xFC00;

// This is the number of bytes to be read from the PLC-5/40V.
const unsigned short kReadSize = kPLC540V_PCCC_MAX_RBP_DATA;

/***************************************************************************/
/************************* PRIVATE TYPE DEFINITIONS ************************/
/***************************************************************************/
// The ”bucket” that we are using to writing the PLC data, address and length
// to the output file.
#pragma pack(1)
typedef struct
{

// The PLC memory address
unsigned long plcAddress;

// The number of bytes of PLC data in this packet.
unsigned short plcDataLength;

// The PLC data...
unsigned char plcData[kReadSize];

}FILE_PACKET_TYPE;
#pragma pack()

/***************************************************************************/
/********************* PRIVATE FUNCTIONS DEFINITIONS ***********************/
/***************************************************************************/
unsigned long extract_start_pointer(char far *data);
unsigned long extract_end_pointer(char far *data);
unsigned long calc_segment_size(unsigned long startPointer, unsigned long endPointer);
unsigned short calc_physical_read_count(unsigned long segmentSize);
unsigned short calc_final_phys_read_size(unsigned long segmentSize);
void show_upload_statistics(PLC540V_PCCC_ULA_RPY_TYPE *replyPacket);
void read_plc_to_file(unsigned long readAddr, FILE *out,

unsigned short readSize, unsigned short readCount);

void upload_is_complete(void);
void upload_all(PLC540V_PCCC_ULA_RPY_TYPE *replyPacket);
void get_edit_resource(void);
void return_edit_resource(void);
void restore_port_configuration(void);
void plc_in_remote_program_mode(void);
void check_for_faults(void);

Advertising