beautypg.com

Example 6008–si program (cont’d) – Rockwell Automation 5370 CVIM Communications Manual User Manual

Page 67

background image

Chapter 4
Using the Remote I/O Link
(Node Adapter)

4–30

/* CVIM to 6008–SI sample communications program */

/* Copyright Allen–Bradley 1–12–90 jrm, */

/* This program was compiled using Microsoft

r

C Version 5.1 */

#include

#include

/* Include the 6008–SI definitions */

#include

#define TRIGGER_1_BIT 0x0400

/* define storage for configuration data */

unsigned config[135][64], configlen[135], template[256][64], templen[256];

void main()

{

QMR mr_pkt;

unsigned segment; /* segment of 6008–SI card

unsigned status, err, CVIM_rack, block_num, numblocks, block1;

unsigned block2, last_blk, x, t;

int op_num, block_1;

/* Prompt – enter address 6008–SI card */

printf (”\n\n\nCVIM to 6008–SI communications sample program\n\n”);

printf (”Enter hex RAM address for 6008–SI card (e.g. 0x000): ”);

scanf (”%x”, &segment)

/* initialize the 6008–SI */

status = setup_6008(baud, 1, l, segment, &mr_pkt);

if (status != OK)

{

printf (”Setup failed: command=%s, status=%s\n”,

xlat_cmd(status), xlat_conf(mr_pkt.qmr_stat));

if (status != C_AUTOCONF && status != C_SETUP)

printf (”Scanner fatal error %d\n”, fatal_6008());

abort();

}

/* Place scanner in RUN mode */

mr_pkt.qmr_data[0] = CM_RUN;

status = mr_wait (C_SETMODE, &mr_pkt);

if (status != OK)

{

printf (”Setup failed: command=%s, status=%s\n”,

xlat_cmd(status), xlat_conf(mr_pkt.qmr_stat));

if (status != C_AUTOCONF && status != C_SETUP)

printf (”Scanner fatal error %d\n”, fatal_6008());

abort();

}

/* Disable host watchdog. For sample program ONLY ––

not recommended for any application programs. */

host_active(–1);

Example 6008–SI Program
(cont’d)