Rockwell Automation 1771-DMC_DMC1_DMC4_DXPS Control Coprocessor User Manual User Manual

Page 113

Advertising
background image

Chapter 7

Using the Serial Ports

7-5

You can use the serial ports for ASCII and other serial communication.
Examples of ASCII peripheral devices that you can use are:

ASCII

terminals

bar-code

readers

Allen-Bradley

Dataliner

weigh

scales

printers

Accessing a Port

When you use a serial port for ASCII and other serial communication, use
standard C library calls. You can use C calls such as:

getc()
read()
write()

Your C program can get and change port parameters using the OS-9 library
calls _gs_opt() and _ss_opt().

See the OS-9 C User Manual, publication 1771-6.5.104, for more
information on C library calls.

Example Program

The following program sets up the COMM2 port (/t2) with the proper
parameters for receiving data from a bar-code reader. The program:

clears the input buffer on the COMM2 port

loops forever, waiting for carriage-return-terminated lines

of ASCII characters indicating that a bar code has been read

places bar-code data in a buffer

calls a subroutine to handle decision-making (based

on the content of the bar code)

Using a Serial Port for ASCII

and Other Serial

Communication

Advertising