A – output to a communication port, B – input from a communication port – Rockwell Automation 2708-DH5B2L_DH5B4L Attended Workstation User Manual

Page 108

Advertising
background image

Chapter 12

Special Devices in A-B VBASIC

12–12

A – Output to a Communication Port

The BASIC Language Development Kit (Catalog No. 2708-NBD) contains
subroutines SendCom, ReadEvent and Test Event for accessing the COM
port when the terminal is configured as a NORMAL workstation type. If you
need more immediate control of the port, use the following programming
instructions:

The PRINT and WRITE statements are available for output to the
communications ports. Unless a semicolon is placed at the end of the PRINT
statement, a carriage return will be output. When enabled through the menu,
a line feed is also output.

Each of the communications lines has an output buffer. The LOF function
returns the number of bytes free in this buffer. When less than the size of the
message, output to the corresponding port will result in a wait until all
characters can be enqueued. This wait will be short in a workstation which is
able to transmit. However, for a workstation which has received an XOFF,
the wait can be long (or even infinite)!

B – Input from a Communication Port

All COM and AUX input is performed with the INPUT$ function. If more
characters are requested than have been accepted by INPUT$, the program
waits until the count is satisfied.

LINE INPUT is not valid with the COM or AUX device.

The LOC function returns the number of bytes currently in the port’s
communication input buffer bytes. A program will never wait if LOC is used
to get the byte count, and that count is used in INPUT$.

For example:

CONST AuxDev = 1
OPEN “AUX” FOR INPUT AS #AuxDev ‘ Cound also be “COM”
J$ – INPUT$ (LOC(5), #5

NOTE
Receipt of Control-C (or whatever control code was
specified in the Setup Menu) will cause the workstation to
enter the menu mode. Receipt of Control-R will reboot the
workstation.

Devices: Communication
Ports, Primary and
Auxiliary (cont’d)

Advertising
This manual is related to the following products: