beautypg.com

Rockwell Automation 57C610 Enhanced Basic Language, AutoMax User Manual

Page 68

background image

6Ć28

If the default setup or baud rate are not suitable for your application,

use the following OPEN statement format to temporarily allocate the

port for EXCLUSIVE access to change the default setup or baud

rate. This changes the default characteristics of the port until the

next power cycle or StopĆAllĆClear occurs. Use the CLOSE

statement to deĆallocate the port. The CLOSE statement must follow

the OPEN statement with no intervening INPUT, PRINT, GET or PUT

statements. The CLOSE statement must use the same device

number assigned in the OPEN statement.
OPEN PORTA" AS FILE #logical_device_number, SETUP=specs,

baud_rate \&

CLOSE #logical_device_number
Note: When an OPEN statement has a setup parameter, the port is

opened with EXCLUSIVE access. Therefore, specifying

ACCESS=NON_EXCLUSIVE causes a compile error to be logged. It

is not necessary to OPEN port A for NON_EXCLUSIVE access; this is

the default mode of operation. Do NOT use the device number

assigned in the OPEN statement to access the port in any

subsequent INPUT, PRINT, GET or PUT statements because the port

has been deĆallocated by the CLOSE statement above.
Examples:

INPUT INP%
INPUT:EMPTY=line_no, INP%
PRINT MSG$
GET CHAR$
GET:EMPTY=line_no, CHAR$
PUT CHAR$

Port A Ć Application Notes
1. Use port A instead of port B when port A is available because

the operating system manages port allocation and error

handling between tasks.

2. OPEN" the port to set required port characteristics, CLOSE"

the port, then use INPUT, PRINT, GET and PUT statements

without a device number in any task to access port A.

3. All tasks have only NON_EXCLUSIVE access to the port.
4. The port is opened and closed after each operation.
5. StopĆAllĆClear commands and power cycle close all ports. The

port characteristics are set to OS default. The user must set the

port to the required characteristics.

6. Stopping a task does not change the port setup and baud rate.
7. Errors logged to task information (for example, Framing,

Overrun, etc.) will have no major effect because the port is

opened and closed after each operation.

8. The serial port statements Print, Input, Put, and Get will operate

after an error has been logged because the port is opened and

closed after each operation.

Programming Example
The following example uses two tasks on the Processor to transmit

and receive data from port A. KYBD.BAS sets the characteristics for

This manual is related to the following products: