Df1 programming example (cont’d) – Rockwell Automation 5370 Color CVIM Communications Manual User Manual

Page 131

Advertising
background image

Chapter 5
Using the RS–232 Ports

5–63

/* This sample program was Compiled using Microsoft C Verision 6.0 */

/* Color CVIM RS–232 Comminication example program using DF1 protocol */

/* Copyright Allen–Bradley 09–10–92 jrm, aes, dms */

#include <stdio.h>

#include <stdlib.h>

#include <bios.h>

#define STX 0x02 /* Start of Text character */

#define ETX 0x03 /* End of Text character */

#define DLE 0x10 /* Data Link Escape (Control char) */

#define ACK 0x06 /* Positive acknowledgement */

#define NAK 0x15 /* Negative acknowledgement */

#define COMMFLAGS 0x8000 /* defines bits to check for comm error */

unsigned char config[213][128]; /* define storage for configuration data

*/

unsigned char configlen[213]; /* define storage for configuration length

*/

unsigned char last_response = 0; /* define the last responce counter */

void main()

{

int x, op_num, portnum, err, replen, reslen, numblocks;

unsigned char reply[200], results[128];

/* Display Program Execution and Description. */

printf (”\nColor CVIM RS–232 Communication example program using ”);

printf (”DF1 protocol.\n”);

printf (”Copyright Allen–Bradley 09–10–92 jrm, aes, dms.\n”);

printf (”This program was used and tested on an Allen–Bradley ”);

printf (”T47 computer.\n”);

printf (”The Color CVIM communication Parameters for this program

are:\n”);

printf (” CFG Host: RS–232 A\n”);

printf (” SYS Host: RS232 A\n”);

printf (” Trigger Source = (Hosted)\n”);

printf (” RS232 A Protocol = DF1\n”);

printf (” RS232 A Baud Rate = 9600\n”);

printf (” Color CVIM must be in RUNMODE\n”);

/* Get Serial port number from the user */

printf (”\nEnter port number (1 for COM1 or 2 for COM2): ”);

scanf (”%d”, &portnum);

/* Open comm channel to Color CVIM at 9600 baud */

_bios_serialcom (_COM_INIT, portnum–1, _COM_CHR8 | _COM_STOP1 |

_COM_NOPARITY | _COM_9600);

DF1 Programming Example
(cont’d)

Advertising